Actions that affect movement

I’m trying to figure out a way to keep my character from continuing onwards until they’ve talked to the character that’s present. Is there a way to do this? What I have now is:

Instead of going to the Cave: if the player has not talked to the peasant, move the player to the Forest without printing a room description; otherwise say "The peasant says 'Hurry back.'"

Also, if there’s a way to keep someone from visiting a place after they’ve visited it once, I would love to know how to do that, too.

What happens when you try that code?

I’m going to start with your second question, because it’ll help me to explain some of the problems you’re having with the first. I’m presuming that you want a room you visit only once ever and then can’t get back to, as opposed to a one-way passage. As rooms come with a visited/unvisited property built-in that flips when the player first goes there, you can check with “if {a room} is visited” if the player has been there. Even better, you can use “Instead of {action} when {a room} is visited” to make a conditional rule that’ll only run when the player’s been to a room. Such as:

Instead of going to the Glade when the Glade is visited, say "You can't go back."

Now, your first question. For starters, you haven’t applied the colon-semicolon style fully. If you’re using it, all conditionals need to have a colon after them (not a comma) and everything needs to be indented. As an example, your code should look like this:

Instead of going to the Cave: if the player has not talked to the peasant: move the player to the Forest without printing a room description; otherwise: say "The peasant says 'Hurry back.'";

Next, Inform doesn’t really keep track of what actions have been performed (at least not in any way that’ll be useful here), so we can’t check “if the player has not talked to the peasant”. We can check properties though, as the other question shows, and it’s very easy to create a new property for the peasant, such as “greeted/ungreeted”. Adjust the “talk to peasant” action to flip that property, and “if the peasant is ungreeted” can be used to decide when to block movement.

The peasant is a person in the Glade. The peasant is either ungreeted or greeted. The peasant is ungreeted. [Talk to it isn't part of the default actions, so I'm using this ask it about] Instead of asking the peasant about "the cave": Say "'Exposition! Explanation!'"; Now the peasant is greeted;

Finally, you need to remember that “Instead of {action}” replaces the normal {action}. Unless you include “continue the action” somewhere, just “instead of going to the cave” will block going to the cave completely. Alternatively, you can use “when” to make an Instead rule that only fires under certain conditions, as in the other question, but you want to add some text so:

Instead of going to the Cave: If the peasant is ungreeted: Say "'Hey! This is my only scene, you're not cutting me out of this adventure!'"; Otherwise: Say "'Have fun storming the castle!'"; Continue the action;

Hope that makes things clearer.

That fixed EVERYTHING. Thank you so, so much. I needed to keep the player from returning to a room as long as there’s a certain object in their inventory and was able to fix that, too.

Inform is getting mad at me again, though. I’m trying to end the story by giving the dragon the aforementioned object, but Inform keeps accusing me of trying to make up a rule.

After giving the dragon the teddy bear: Say "Insert profuse thanks here"; End the story finally saying "You savior, you.".

Inform error: “You wrote ‘After giving the dragon the teddy bear’, which seems to introduce a rule taking effect only if the action is ‘giving the dragon the teddy bear’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.”

The giving action is called “giving it to” so you’ll have to add “to” and switch the nouns around:

After giving the teddy bear to the dragon:

Actions have only one name in the code so you’ll have to use the exact phrasing. You can find them in the Actions page of the Index.

Much thanks. The code stopped giving me the error, but now every time I try to give the dragon the bear it says “the dragon doesn’t seem interested” no matter how many ways I phrase it. The manual says that characters can carry things and I’ve already defined the bear as a portable object, so is there some other definition I need to add?

Giving things to other characters is blocked by default. If the teddy bear is the only thing the player can give to the dragon, the easiest solution is to use an instead rule (“Instead of giving the teddy bear to the dragon: …”) which overrides the block, or if you need something more sophisticated the Recipe Book chapter 7.4. has relevant examples.

Thanks for the tip about the Recipe Book - it had instructions about how to turn off the rule. Thanks everybody for all your help. I just finished making my very first adventure! Now to fix the filler text…

Cool :sunglasses: Will you be posting it?