Setting action count to display messages and move player

Hi,

I need to implement action count to display some random narrative every few turns and then move the player after X turns. I’ve used this code from another thread which sets things up:

A room has a number called turn count. Every turn: increment the turn count of the location.

Every turn when the location is a room:
increment the turn count of the location;
say “[one of]Here's a random message[or]here's another random message[at random]”

I’d like to amend this so that after every fifth turn, displays a new, random message.

And then, after 20 turns, move the player to a new room in a new region. When in the new region, this function stops.

Any help appreciated, thanks.

Would something like this work?

Every turn:
	If the player has been in Lobby for exactly 5 turns or the player has been in lobby for exactly 10 turns or the player has been in lobby for exactly 15 turns:
		Say "[one of]Bark one[or]Bark two[or]Bark three[stopping].";
	If the player has been in Lobby for 20 turns:
		Say "poof!";
		Now the player is in atrium.
1 Like

Hi Mike, thanks for that. That’s 99% there! It moves the player and prints the correct description. The only thing missing is that it does not print the name of the room. Any way I can force that, something like:

Now the player is in atrium, print room name and description

Huh, that’s weird, I thought that should happen automatically (and it’s working in my minimal example) – maybe add a “try looking” after moving the player? If that’s still not working, I’d use RULES to see if there’s something pre-empting the usual behavior.

Interesting. This may have something to do with it, although when implemented this still prints the room name elsewhere in my game:

A room has some text called the unvisited_description.
instead of looking in a room:
	say  the unvisited_description of the location;

Example of this in action:

Damp Hallway is a room in Sub1. The unvisited_description of Damp Hallway is "[damp_long]".
to say damp_long: say "Long Damp hallway description".
The description of Damp Hallway is "[if unvisited][damp_long][otherwise]Short damp hallway description".

Normally, when moving around the game, this honours the room title before printing either the short or long description. However, after moving the player, it does not. I will have a play.

Thank you.

Ah, yeah, that’s probably what’s causing the issue. Is the idea just to have a longer initial description of a location that the player gets only the first time they visit, and then a more streamlined one that displays on subsequent visits? If so, it’s way easier just to use the [one of]…[stopping] syntax I used above (docs on that here).

1 Like

Yes, exactly that. I can’t remember why I went for the solution I did in the end, but the [one of] idea makes more sense and is a lot easier to implement. I will try this now. Thanks once again, Mike.

1 Like

Ah, I’ve just remembered why I did this. I need to insert [if] statements inside my descriptions. I found I wasn’t able to nest them in descriptive text. For example, if I player says ‘look’, I need to call the long description but also include

Here begins the room description. There is a chair. [if player has key]On the chair is a key[end if][if player does not have key]no key here[end if]continue the description of the room"

Ah, yeah, I’ve run into that challenge sometimes. I’d still avoid an instead rule – a to-say phrase will give you more control in those circumstances than the simple one of… stopping approach will, but likewise won’t bork the rules machinery.

(Avoiding instead rules unless you’re really sure you need one is generally an Inform best practice – I’ve definitely got painful experience in overusing them myself!)

Yes, I’m trying to avoid them by putting necessary ifs at the end of the description. But I have just tried this:

The Harbour is a room. The description is "[one of]This is the harbour[if the player has the rusty key] there is no key here[end if] [if the player does not have the rusty key] here is the key[end if]here continues the description[or]Here is another description[stopping]".

The rusty key is a thing. The rusty key is in the harbour.

The boat is a room. The boat is south of the harbour. "description".

What is happening is that you only ever see the long description ([one of]) once. If you leave the room and go back in you see the short description, which is fine, but if you type ‘look’, it serves up the short description.

I haven’t followed all of this thread, but you may find this useful:

After printing the locale description:
    <print long description >

If the idea is to have separate descriptions for all visited and unvisited rooms, and you don’t mind giving up the ability to set a room’s description by just throwing in a quoted text as a standalone sentence, then I think this should work:

A room has some text called the visited description.
A room has some text called the unvisited description.
The description of a room is usually "[if visited][visited description][else][unvisited description][end if]".

Damp Hallway is a room.
The unvisited description of Damp Hallway is "[damp_long]". [Though it probably makes sense to manually expand that substitution now.]
The visited description of Damp Hallway is "Short damp hallway description."

(You can add the underscores to the names too, if you prefer that.)

1 Like