Empire: Train -how to list inside/outside as an exit when in the station?

I am setting up a train in my game. I have used the ‘Empire’ script. It all works fine, except that ‘inside’ is not listed as an exit when player is in the station and the train is there (nor is outside listed as exit when player is in train at a station).

To control general listing of exits in my game I have the following:

To say exit list:
let place be location;
repeat with way running through directions:
let place be the room way from the location;
if place is a room, say “[way][line break]”.

After looking:
say “Exits are: [line break][exit list][paragraph break]”.

From a quick gander, it looks like the issue is that in the Empire example, there are never directional connections established between the train and the stations – the going inside and going outside actions are intercepted with Before or Instead rules that manually move the player to or from the train. So to get this to work, you’d need to rejigger the code so that when the scheduled times hit, you’d set new/updated inside from and outside from relations for the train and relevant station, rather than just updating the “station” property.

So like start out the train in Seattle, then go through your timetable like this (BTW, you can use the preformatted text option – the </> icon in the toolbar – to preserve Inform’s formatting):

At 4:45 PM:
	if the player is in the train or the player is in the station of the train, say "The train pulls out of [the station of the Train]!";
	now the station of the Train is the Train;
	change outside exit of the Train to nothing;
	change inside exit of Seattle to nothing.

Hope this helps!

1 Like

Perfect! Thanks for that, the empire example is difficult to decode, I wouldn’t have worked that out. Thank you.

Unfortunately it’s still not listing inside/outside as exits when in station or in train.

My code looks like this:

Market street is a room.

Market street is northwest of town square.

The empire builder train is a room. The Train has a room called the station. The station of the Train is Market Street.

The description of the Empire Builder is “One of the (relatively) plush long-distance Amtrak trains. You’re in a two-story car with toilets and a cafe at one end, not having sprung for a sleeper.
[if the station of the Train is the train]Outside the window there is rapidly-passing countryside.[otherwise]Through the windows you can see the [station of the Train] train station.[end if]”

Instead of exiting when the player is in the Train:
if the station of the Train is the Train:
say “The train is not stopped at a station.” instead;
otherwise:
move the player to the station of the train instead.

Before going outside when the player is in the Train:
try exiting instead.
Before going inside when the player is in the station of the Train: move the player to the Train instead.
Market Street, Edmonds, Everett, Wenatchee, and Spokane are rooms.

The description of a room is usually “The scenic train station of [the location][if the location is the station of the train].
The pompously-titled Empire Builder train is pulled up here, soon to continue its journey towards Chicago[end if].”

At 9:07 AM:
if the player is in the train or the player is in the station of the train,
say “The train pulls out of [the station of the Train]!”;
now the station of the Train is the Train;
change outside exit of the Train to nothing;
change inside exit of Market Street to nothing.

At 9:10 AM:
now the station of the Train is Edmonds;
if the player is in the train or the player is in the station of the train, say “The train pulls into Edmonds and comes to a stop.”;
change outside exit of the Train to nothing;
change inside exit of Edmonds to nothing.

At 9:15 AM:
if the player is in the train or the player is in the station of the train, say “The train pulls out of [the station of the Train], running north along the shore towards Everett.”;
now the station of the Train is the Train;

At 9:20 AM:
now the station of the Train is Everett;
if the player is in the train or the player is in the station of the train, say “The train arrives in scenic Everett, WA: the last stop before it turns east and heads over the mountains.”;
change outside exit of the Train to nothing;
change inside exit of Everett to nothing.

At 9:25 AM:
if the player is in the train or the player is in the station of the train, say “The train pulls out of [the station of the Train] and turns east.”;
now the station of the Train is the Train.

At 9:30 AM:
if the player is in the train or the player is in the station of the train, say “In darkness the train rolls into Wenatchee; which is just fine, considering that there is nothing to see here at all.”;
now the station of the Train is Wenatchee;
change outside exit of the Train to nothing;
change inside exit of Wenatchee to nothing.

At 9:35 AM:
if the player is in the train or the player is in the station of the train, say “The train pulls out of [the station of the Train] and continues east through the darkness towards Spokane.”;
now the station of the Train is the Train.

Oh, sorry, should have spelled it out a little better: first, you should start the train out in Market Street:

The train is inside of Market Street.

And then you need to swap the “nothings” to the relevant station when arriving – so your 9:07 is right, but your 9:10 should be:

At 9:10 AM:
     now the station of the Train is Edmonds;
     if the player is in the train or the player is in the station of the train, say “The train pulls into Edmonds and comes to a stop.”;
     change outside exit of the Train to Edmonds;
     change inside exit of Edmonds to the Train.

And your 9:15:

At 9:15 AM:
     if the player is in the train or the player is in the station of the train, say “The train pulls out of [the station of the Train], running north along the shore towards Everett.";
     now the station of the Train is the Train;
     change outside exit of the Train to nothing;
     change inside exit of Edmonds to nothing.

And so on from there

Ah! Apologies, my bad. Many thanks again.

Works perfectly now!

This is a great deal of exit-fiddling, and it will be easy to forget a case. I’d say the better course is to tweak the “exit list” routine by adding a couple of lines:

if the location is the train, say "outside[line break]";
if the location is the station of the train, say "inside[line break]";
3 Likes

Oh yeah, that’s much smarter! Though since the code changes the station of the train back to train when it’s in transit, I think you’d get both “inside” and “outside” listed as a possible exit while you’re riding the train. So ultimately I think the code would look like:

To say exit list:
	let place be location;
	repeat with way running through directions:
		let place be the room way from the location;
		if place is a room, say “[way][line break]”;
	if the location is the station of the train and the location is not the train, say "inside[line break]";
	if the location is the train and train is not station of the train, say "outside[line break]".

Thanks Andrew. I’m only having a few stations in total - its’ actually going to be a Manchester metrolink tram when its done.

Rather than stating time of day is there a way to just make the train stay at each station for 5 mins then move to the next one, then when it reaches the final station is leaves in 5 mins and does the return journey?

Actualy I think I can just do this with :
“Every turn when the minutes part of the time of day is X”

1 Like

This doesn’t help with the exit-fiddling, but if you’re interested in scheduled transport then you might want to give Transit System by Emily Short a look.

Thanks for this, probably overkill for my needs, but very useful to know it exists.