Room description variable changing.

Welp, I didn’t want to post again, but the final change has failed… Yay.

I am trying to sort out an issue where I would have a piece of text guiding a player to do something, but I still had that even when they did it (for example the player needs to bandage, but even after bandaging, the room descriptions will still say about the bandage.

I have a variable called Player-bandaged, which I know works because I use it for something non-text related as well. However, for some reason, the descriptions do not change. I am wondering if that is because I have two variables to use? What I mean by this, is that I have a variable named AnimalFeatures, in which displays some hidden text. So I need 4 room descriptions. Pre-bandage without AnimalFeatures, pre-bandage with AnimalFeatures, post-bandage without AnimalFeatures and post-bandage with AnimalFeatures.

This is the code I’ve got.

[code]Forest west edge is a room. Forest west edge is west of Forest North edge.

After going to Forest west edge when Player-bandaged is true and AnimalFeatures is true:
now the description of Forest west edge is "You can see the moon clearly again from over here. You consider stopping to ponder on the night skies beauty. But you need to get home, so no delaying!

However, that is exactly what you do. Delay. Once again, like earlier on, you seem to want to just stare at the moon for a long time. You make this weird growl subconciously, and then suddenly, you look around, breaking out of the trance once more. However, you seem more on edge. More on edge than you already were, anyway.";
continue the action;

After going to Forest west edge when Player-bandaged is true and AnimalFeatures is false:
now the description of Forest west edge is “You can see the moon clearly again from over here. You consider stopping to ponder on the night skies beauty. But you need to get home, so no delaying!”;
continue the action;
After going to Forest west edge when AnimalFeatures is true:
now the description of Forest west edge is "You can see the moon clearly again from over here. If it wasn’t for the fact of you being injured and the threat of more werewolves, you might have just stopped here to ponder on the night skies beauty. Shame. But you need to get home, so no delaying!

However, that is exactly what you do. Delay. Once again, like earlier on, you seem to want to just stare at the moon for a long time. You make this weird growl subconsciously, and then suddenly, you look around, breaking out of the trance once more. However, you seem more on edge. More on edge than you already were, anyway.";
continue the action;

After going to Forest west edge when AnimalFeatures is false:
now the description of Forest west edge is “You can see the moon clearly again from over here. If it wasn’t for the fact of you being injured and the threat of more werewolves, you might have just stopped here to ponder on the night skies beauty. Shame. But you need to get home, so no delaying!”;
continue the action;[/code]

Halp!

EDIT: seems a lot of my room description changes aren’t working. This is odd as earlier on in the game they were. Even basic ones like this isn’t working:

After going to Second Helastrom: now the sound channel of the sound of Hela Growling is the background; internally play the sound of Hela growling on the background repeating 50 time; now the sound channel of the sound of Hi Ho is the midground; internally play the sound of Hi Ho on the midground repeating 50 time; now HelaForest is true; now the description of Grand tree is "The massive old oak tree that underneath houses your packs den. The rings on the fallen bark shows it's incredible age, yet it seems stronger than ever. The smell of blood from below hangs in the air, such a nice smell."; now the description of Helastrom path north is "The grand tree is close to you from here, the bushes being somewhat spread out, but from the south they pick up once more, leading towards the path of Wolf Forest."; now the description of Helastrom path south is "The bushes are massive here, and it is a somewhat struggle to get through them. Some of the plants being spiked at the end, getting into your fur every time. The tree is visible, but not totally so, the bottom half consealed due to the bushes density."; continue the action;

There are a number of comments that could be made here, although I’m not sure any of them will get you closer to solving the problem. I’ll make them anyway, just in case:

  • If you want a paragraph break in printed text, you should use “[paragraph break]” instead of an actual paragraph break. (I wonder if this might not be causing problems.)
  • Ignore this! You do not need “continue the action” when using an “after” rule, because after rules do not affect the flow of actions.
  • Rather than using global variables, you might want to try using adjectives like “bandaged” and “unbandaged”. (A person can be bandaged or unbandaged. A person is usually unbandaged.) This way you can write things like “if the player is bandaged…” I don’t know if this has much effect on the code, but I see this sort of thing more often.

But, at any rate, the above code that you have posted is not a complete example in and of itself (that is, I can’t just throw it in Inform and compile it), so lesser minds like myself can’t help you figure out what is going wrong.

[Edit: OK, just saw your edit. It seems like something else is going wrong somewhere. Remember how Eleas suggested creating a minimum example? Try that and see what happens. Then start adding pieces of your code back until something goes wrong.]

You do indeed need “continue the action” in an After rule, if you want the Report rules to run. (By default After cuts off Report, and any other less-specific Afters.)

Rather than changing the description like this, it’s better to use text substitutions.

The description of the Laboratory is "[if the noisy machine is switched on]You can barely perceive anything but the infernal screeching of [the noisy machine][else]It's blissfully quiet now[end if]."

If you need nested if-statements, you can pull the whole text out into its own substitution.

The description of the Laboratory is "[lab-description]". To say lab-description: [code here].

My bad! I was not aware of this.

This is a good approach, but you do have to wrangle a bit to make the line breaks and paragraph breaks come out right.

It’s worth going into some specific detail about how the after rules actually work.

The after rules are checked after the carry out rules but before the report rules. When an after rule does apply, the result is considered a “success” by default, which immediately stops the action, and no further action rules are run.

The report rules are usually reserved for printing whatever text goes along with an action. A successful after rule pre-empts the report rules entirely. Thus the simplest and most common use for an after rule is to change the text that goes along with an action. For example:

After taking something: say "Got it!"

This lets all of the normal mechanics of the taking action run as normal, and then prints “Got it!”, pre-empting the normal report taking rule (“Taken.”)

The phrase “continue the action” tells the game to not consider the result of this rule a success. The rule runs, but then the game keeps on checking after rules, and then, eventually, the report rules as well. The report going rules are what prints the room description when you arrive at your destination, which is why you usually want to add “continue the action” to any after going rules, because otherwise you won’t see a room description after your rule runs.

However, it’s important to remember that when you continue the action, all of the after rules continue to get checked as well. So here you’ve got 4 after rules, all of which continue the action. Let’s say, for the sake of example, that the player-bandaged and AnimalFeature flags are both true. You go to Forest West Edge, and the game starts checking your after going rules:

  1. It checks the first rule, sees that it applies, and changes the room description accordingly. Then it continues the action.
  2. It checks your second rule, but skips it since the conditions do not apply.
  3. It checks the third rule, sees that it applies, and changes the room description accordingly. Then it continues the action.
  4. It checks the fourth rule, but skips it since the conditions do not apply.

Finally, the game moves on to the report rules, which print the room description, which has been changed to reflect your third after going rule. But based on your code, I suspect that what you really wanted to see was the description from the first rule.

There are a couple of ways to fix this. One way is to rearrange your rules so that the conditions are all mutually exclusive, so that you never have more than one apply in any given situation. You can also nest your conditions, which reduces the number of rules you have to account for. For example:

[code]After going to Forest west edge when Player-bandaged is true:
if AnimalFeatures is true:
now the description of Forest west edge is “You can see the moon clearly again from over here. You consider stopping to ponder on the night skies beauty. But you need to get home, so no delaying![paragraph break]However, that is exactly what you do. Delay. Once again, like earlier on, you seem to want to just stare at the moon for a long time. You make this weird growl subconciously, and then suddenly, you look around, breaking out of the trance once more. However, you seem more on edge. More on edge than you already were, anyway.”;
otherwise:
now the description of Forest west edge is “You can see the moon clearly again from over here. You consider stopping to ponder on the night skies beauty. But you need to get home, so no delaying!”;
continue the action;

After going to Forest west edge when Player-bandaged is false:
if AnimalFeatures is true:
now the description of Forest west edge is “You can see the moon clearly again from over here. If it wasn’t for the fact of you being injured and the threat of more werewolves, you might have just stopped here to ponder on the night skies beauty. Shame. But you need to get home, so no delaying![paragraph break]However, that is exactly what you do. Delay. Once again, like earlier on, you seem to want to just stare at the moon for a long time. You make this weird growl subconsciously, and then suddenly, you look around, breaking out of the trance once more. However, you seem more on edge. More on edge than you already were, anyway.”;
otherwise:
now the description of Forest west edge is “You can see the moon clearly again from over here. If it wasn’t for the fact of you being injured and the threat of more werewolves, you might have just stopped here to ponder on the night skies beauty. Shame. But you need to get home, so no delaying!”;
continue the action;
[/code]

Since Player-bandaged is always going to be either true or false, only one of those rules will ever trigger on a given turn.

As some have suggested, you can use text substitutions to condense this code even further:

The description of Forest West Edge is "You can see the moon clearly again from over here. [if player-bandaged is true]If it wasn’t for the fact of you being injured and the threat of more werewolves, you might have just stopped here[otherwise]You consider stopping[end if] to ponder on the night skies beauty. [if player-bandaged is true]Shame. [end if]But you need to get home, so no delaying![if AnimalFeatures is true][paragraph break]However, that is exactly what you do. Delay. Once again, like earlier on, you seem to want to just stare at the moon for a long time. You make this weird growl subconsciously, and then suddenly, you look around, breaking out of the trance once more. However, you seem more on edge. More on edge than you already were, anyway.[end if]"

This removes the need for any after going rules at all, and instead lets the room description adapt itself to whatever conditions apply whenever it is printed.

Lastly, as some have suggested, you could also create either-or properties instead of global variables to track these states. For example,

A person can be bandaged or unbandaged. A person is usually unbandaged.

This lets you write conditions like “if the player is bandaged” instead of “if player-bandaged is true”. Also, since the property applies to any person, you could track the bandaged state of other people as well (“now Joe is bandaged; now Gordon is bandaged; now Worgah the Midnight Packlord is bandaged”) if that is important in your game. However, although this is handy for writing concise and readable code, it doesn’t really have any bearing on why your after rules were not working.

^Thanks for the explanation of after rules; I know it helped me a lot, as I’m still trying to wrap my head around some aspects of the way Inform works.

This worked! I have no idea why it wasn’t working before, but it works now! I should be able to complete the game now! Thank you!

Yeah, in general it’s better to not change the description text in-game, because when you get a bug, changing descriptions means you have to trace the entire program logic to find where the change occurs.

Mostly, keep state as small and local as possible, and prefer to calculate things rather than store and change.