Actions taking multiple turns

Hi, I’m looking for some advice please. I’m creating an action which always takes a set number of turns to complete. Each turn while it is happening, I want to print a unique message for that turn, and on the last turn I want to change a property of the thing we’re acting on. The action can be done only once to each thing which allows it, but it can be done multiple times in the same game. The following example code works, but I hate it:

The network is a list of rooms which varies.

A node is a kind of room. A node can be networked.

Connecting is an action applying to nothing.
Understand "connect" as connecting.

Check connecting when the location is not a node (this is the can't connect non-nodes rule):
	say "You cannot connect this place to anything." instead.

Check connecting when the location is a networked node (this is the can't connect what's already networked rule):
	say "This node is fully operational." instead.

Connection in progress is initially false.

Carry out connecting:
	now connection in progress is true.

Building a connection is a recurring scene. Building a connection begins when connection in progress is true.

Every turn during building a connection:
	repeat through the table of connection messages:
		say "[message entry][paragraph break]";
		blank out the whole row;
		rule succeeds.

Building a connection ends when the number of filled rows in the table of connection messages is 0.

When building a connection ends:
	now the location is networked;
	add the location to the network;
	now connection in progress is false.

Check going during building a connection:
	say "You must wait until the sequence is complete." instead.

Table of Connection Messages
message
"message 1"
"message 2"
"message 3"

Junction is a room. Station 3 is west of Junction. Station 4 is east of Junction. Station 3 and Station 4 are nodes.

So my main question is: How can I make these messages available to each building scene? The process of repeating through and blanking out each row of the table means they’ll only ever display the first time.

On the same note: Could I please get some ideas on how I could re-write this kind of delayed action to properly participate in action processing? Right now its success is decided at the end of the scene, which is wrong. The scene is only there because I can’t think of another way to get a sequence of messages like that. It’d be much better if I could do all of this in the carry out and report stages. Thanks.

The task is more complicated than your example code can handle. For instance, for now, if the player stands still for three turns, they’ll get all the messages in place, when what I assume you want is that they get one of the messages each time they extend the node through a new room. So there’s also the issues of tracking whether the player has gone to a new room, and if they have, whether that room is next to the previous bit of node – and if it’s not, what do you want to have happen? Will they just not lay down more node? Or will they undo what they’ve done and start laying it ‘this way’?

Of course some of these options may not be relevant due to other elements of your design, but the fundamental bit is, you’re going to track node progress via the geography, rather than just the passing of time.

-Wade

My understanding is that waiting in place for the connection to be established is what the OP wants.

I don’t think you can do anything like this within Inform’s action processing. Your approach looks basically right.

But there’s no need to blank the table rows. Just set up a counter to keep track of which row to pick, and increment it by 1 each turn. Indeed, you could just use Inform’s own time counter for this purpose.

Every turn during building a connection:
     let N be the minutes part of the time since building a connection began plus one;
     choose row N from the table of connection messages;
     say "[message entry]."

(If you place the period in the say phrase rather than the table entry, you’ll get the paragraph break for free.)

End the scene when the counter gets too big:

Building a connection ends when the minutes part of the time since building a 
connection began is the number of filled rows in the table of connection messages.
3 Likes

Sorry, I wasn’t clear, the player is supposed to stay in the same place. The messages are somewhat atmospheric, but I feel like this is okay because these node connections are important steps in the game. It’s meant to feel like it’s taking a while, or at least waiting for three turns feels like a while to me. I think the inclusion of the list of rooms gave the wrong impression, it wasn’t strictly necessary for the example, that bit is taken care of elsewhere in the code. My question is about having an action print text over a few turns before it finishes.

Thanks, that’s exactly what I needed.

Heh, yeah that’s what made me think you wanted them connected. Looks like jrb understood.

-Wade

1 Like