Little beginner help with counting!

Hi!

I’m working on my first Inform project (the last time I did anything like this was building a text adventure game back in 1987!) and I’m having a few issues!..

First question: I’m trying to prevent my player from moving north based on a number and I’m really struggling to make the logic work right.

The code to prevent the player from moving from the training grounds looks like this:

Instead of going north: if the location of the player is Training Grounds: if dialog of Captain Foley < 3: say "[Captain Foley] says 'Before starting the obstacle course, read each of those important signs.'"; otherwise: move the player to Pathway.

The problem is that now I can’t go north in ANY of the rooms with the logic set up like that ^. I tried adding an extra otherwise condition, but can’t seem to get the syntax right.

I also tried re-arranging this so it looked like this:

if the location of the player is Training Grounds: Instead of going north: if dialog of Captain Foley < 2: say "[Captain Foley] says 'Before starting the obstacle course, read each of these important signs.'"; otherwise: move the player to Pathway.

… but the compiler really hates it like that and doesn’t allow it.

2nd question: Is there a way to say ‘go north’ or ‘move the player north’ rather than having to specify which room to move it to?

Any help would be REALLY appreciated!

Thank you,
Jeff.

For your first question, the problem is that you have an “Instead of going north” rule, which fires whenever the player tries to go north; when the player isn’t in Training Ground, the rule is still firing and keeping them from going north even though none of the rest of the stuff is happening. You could fix this by adding (at the end and with proper tabbing)

otherwise: continue the action.

but the best way to do this is to change the heading of your rule so it only fires when you’re in Training Grounds and going north:

Instead of going north from Training Grounds:

(You might want to check out section 7.13 on the difference between going in and going from.)

Also, instead of manually moving the player to Pathway when dialog is at least 3, you could just write “continue the action” and the player will go north normally (assuming that there isn’t anything preventing them). I guess that’s the answer to your second question? In general, it depends on what you’re trying to do. If you want to allow the player to go north when you’re writing an Instead rule that would otherwise stop them, “continue the action” is the way to go; see section 7.3.

If you’re responding to a different command and you want to have the player go north as if they had typed “Go north,” you want “Try going north,” as in section 7.4. (For instance, if you want “go up” to take them north, you can say "Instead of going up in the Parade ground, try going north.) This will invoke all the usual constraints and rules on going north; if the dialog of Capt. Whosit is less than three, then the instead rule will stop the player from going north.

If you just want a general command that moves the player to the room north of the one they’re in willy-nilly, then you can do something like “if there is a room mapped north of the location: move the player to a random room mapped north of the location” – not sure of the exact syntax, but I don’t think that’s what you want anyway; it sounds like you want “continue the action.”

Some people might argue that this should be written as a Check rule instead, but I don’t know how necessary that would be.

You are a rock star! Thank you so much for the help :slight_smile:

I find it easiest to just put all conditions into the rule header (unless they are very complex) so you don’t have to think about “continue the action”:

Instead of going north from Training grounds when dialog of Captain Foley < 3: say "[Captain Foley] says 'Before starting the obstacle course, read each of these important signs.'"

Oh excellent! Thanks for the reply!

I didn’t realize you could do things like this… I thought it’d all have to be lots of separate conditions.

I really wish I’d had this back in 1987 when I wrote my first adventure game! What an amazing system this is!

Thanks! :smiley:
Jeff.