Assorted Inform 7 questions

Outside of quotation marks, square bracketed text [like this] is not read or compiled by inform. You can use it to comment your source. The comment can take up multiple lines, and only ends with a close square bracket.

EDIT: It’s covered here in Writing with Inform.

1 Like

Thank you!

I am trying to work out how repeated actions interact with before/stop actions and instead of actions.

As that page notes, “we are counting the number of times the action has been tried, not the number of times it succeeded.” Is there a way to count the number of successes?

Instead of photographing: if the player does not have the camera, say "You can’t take pictures without a camera.

After photographing the map for the first time: if the player has the camera, say “This photo will help you navigate the park with ease. You add it to the load that you are carrying.”

Basically, the goal is to make the latter response happen only on the first successful photographing action by the player. As it is right now, an unsuccessful photographing action will prevent the latter response from appearing on the first success.

I have been playing around with success rules but it seems to make no difference.

Am I using “if” incorrectly? Does the “while” clause apply here?

There can’t be too many topics :slight_smile: This forum is a great place to search for answers, and non-general topic titles are helpful for that. Enjoy Inform 7!

1 Like

You’ve almost got this right - the issues is that you don’t have the conditional in the header if your instead rule, but in the body. So the instead rule always fires, printing the unsuccessful attempt text if the player doesn’t have the camera and doing nothing if they do - but in either case, the instead rule is preempting the action so it never successfully completes.

If you change the rule to:

instead of photographing while the player does not have the camera: 
          say "You can’t take pictures without a camera.”

It should work as intended.

For the second part, I’d be inclined to tie it to the photo object, assuming that you’re implementing that.

The photo is a thing. It is nowhere.     [The second sentence here isn't actually necessary.]
After photographing the map when the photo is off-stage:
        now the player holds the photo;
        say "This photo will help you navigate the park with ease. "

The After rule will only fire once (when the player succeeds in photographing the map), provided you don’t remove the photo from play again later.

If you do find yourself having to track the number of successful attempts at some action, the easiest way is almost certainly to set up your own counter.

I ended up doing something like @jrb 's suggestion with extra steps. In addition to moving photos out of nowhere when they are photographed, the photos are now members of a kind called “keepsakes” that are automatically picked up and can’t be dropped.

The “first time” event is triggered by picking up the photo, which is guaranteed to happen on the first try…I hope.

@DeusIrae I will come back to that later.

Oddly enough I’m seeing that the Inform 7 documentation uses photographs in several examples. I guess this is something that a lot of people including myself want to do in text adventures for some reason.

I remember Robin and Orchid from IFComp a few years back had photography too…wow, that was almost ten years ago.

Thanks to everyone’s help I now have a fully functional parking lot with a car. Off to bed for me…

1 Like

You may want to edit your post to add the missing ‘NOT’ before 'helpful" as in its current form, It makes no sense. shouldn’t it be - non-general topic titles are NOT helpful for that :slightly_smiling_face:

1 Like

I got the intended meaning.

1 Like

I’ve now tried your solution @DeusIrae, that is much more straightforward though I still don’t quite understand the syntax.

I’m now trying to create a sitting and standing system. Following the documentation I successfully overrode the default standing action with:

Understand the command “stand” as something new. Standing up is an action applying to nothing. Understand “stand up” and “stand” as standing up.

However, I also want to add “get up” to that list of synonyms. I can’t override the built-in “getting up” command because understand as something new only accepts single words.

I’ve also tried writing:

Instead of getting up, try standing up.

The actions index shows:

“get out/off/down/up” - Exiting
“get up” - Standing up

I am sorry for being grumpy (and maybe underestimating the search engine) yesterday, and I had planned to edit my post to apologise. But I did mean “non-general topic titles are helpful”: in other words (in order of increasing grumpiness) “specific titles are helpful”, “non-specific titles are unhelpful”, and “general titles are unhelpful”. I like Ask Ryan, though, and can’t work out whether it’s an exception, or specific in its own way!

Oh, I see what you mean now…yes this will not be the best-keyworded topic.

Still, I feel like I would be spamming the board if I start a new topic for each question. Hopefully this is a short and sweet project on my part.

1 Like

I’ve managed to solve this with

After reading a command: if the player’s command matches “get up”,
replace the player’s command with “stand.”

1 Like

But if you do, you can be in my club! I have a general rule: “no more than one coding question on the forum per day.” I tell myself that this makes me less annoying. But actually that rule is useful, because it forces me to solve things that I’d otherwise have asked a question about.

1 Like

This is true, but I feel like a longer explanation is needed.

You can do this:

Understand "get up" as standing.

This compiles, but it doesn’t work. Unfortunately the new definition of “get up” winds up with a lower precedence than the Standard Rules definition of “get up”, so it never triggers.

Replacing pieces of the player’s command is often a clunky and/or buggy approach. In this case, though, it’s simple and I don’t see anything that’s likely to go wrong.

It is possible to solve this without doing that. You have to start with

Understand the command "get" as something new.

…and then re-create every grammar line that involves “get” except “get up”.

Understand the command "get" as something new.

Understand "get up" as standing.
Understand "get in/on" as entering.
Understand "get out/off/down" as exiting.
Understand "get [things]" as taking.
Understand "get in/into/on/onto [something]" as entering.
Understand "get off/down [something]" as getting off.
Understand "get [things inside] from [something]" as removing it from.

This is a lot of Understand lines, but it does what you want.


Thank you for the heads up @zarf. I’ve taken that into consideration and now realize that I only actually need to override the default meaning of “get up” when the player is lying down. Hopefully this does not cause further conflicts, we will see.

After reading a command: if the player’s command matches “get up” and the player is prone, replace the player’s command with “stand.”

Two extensions you might find of interest are Emily Short’s Modified Exit and Postures.


Thank you! I need to tightly control player options because of the way scoring works in my game, but those look otherwise useful.