Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Wondering if this is a design choice, or a bug.....



If you create a :match command, which outputs nothing at all (or the path through the command outputs nothing),  the parser replies "You can't do that".  However, if you return from the match early, it doesn't.  e.g.


: match "guess number" {

: if (is_at("casino")){

  :if (already_guessed){

     :return;

  }

 :else { :print "You guess well!";}

}

if you are not at the casino, it prints "You can't do that" because it fails the first "if". However if you're at the casino, and you've already guessed, nothing is printed out, because it just returns.

(1 edit) (+1)

"You can't do that?"

.. that would be the intended behaviour, as it would fall over to the system command for not handling the input.

What is your desired behaviour?

Oh, no request.. just wondering if it was an oversight.  I was surprised that it changed behaviour even though nothing was printed.   :)  


The game's up to 1500 lines and I'm starting to make some relatively intricate commands..

(+1)

: return; will stop execution, same as : done;

Nothing will be handled by the system is : return or : done are called (both of these are terminators).

You don't need to stop execution if you have an else block for the alternative.

I was thinking about adding a : not_done; command for stopping execution and not falling back to the system handlers, but it's easily avoided by using an else block.

(1 edit)

Cool.   I've restructured it all so that things fall through to the default.  

:) Thanks for the info! :)

(1 edit) (+1)

I've never understood the difference between :done; and :return; The doco implies that :return; is used to return from a subroutine, so that's how I've used it. I now use :done; everywhere else.

When using :done; always make sure you print something beforehand or you'll end up with a blank line. I've also gotten into the habit of liberal use of :done; to make sure that my specific pattern-matching routines do not fall through to the generic pattern-matching routines and ending up with two responses.

(+1)
  • : return will return from a subroutine but continue executing code after the : gosub ""; command that was used to call it.
  • : done will stop the code dead in its tracks (not return to the line after the gosub).

Executing any line (including a terminator) will override the system default handler for the text entered. I plan to add a default message for when done is executed without printing something first (overridable).

(+1)

Aha. That makes sense within the context of subroutines, but don't they act the same in :match{} routines?

No, a return is exactly the same as a done, except in a subroutine. There is nothing to break out of a match specifically.