Draconis posted first, but here’s one where I implement the sidewalk as an enterable supporter instead of a room and use a table. Also, maybe the examples in this thread would be helpful.
(The tabs in this code look weird, but they should copy and paste correctly–each column of the table is separated by a tab stop.)
[code]North Poddington is a room. Poddington Central is a room. West Umbunch is a room. South Poddington is a room. Crampton Return is a room. Crampton Return North is a room.
Umbunch Central is east of West Umbunch and north of Crampton Return. “If you want to return to the moving sidewalk, you can go east to West Umbunch or south to Crampton Return.”
Table of Moving Sidewalk Places
start message destination
North Poddington “The sidewalk carries you south to Poddington Central.” Poddington Central
Poddington Central “The sidewalk moves on to West Umbunch.” West Umbunch
West Umbunch “With a groan the sidewalk moves on to South Poddington.” South Poddington
South Poddington “The sidewalk veers east to Crampton Return.” Crampton Return
Crampton Return “The sidewalk carries you north to Crampton Return, er, North.” Crampton Return North
Crampton Return North “The sidewalk swings back round to North Poddington and turns south again.” North Poddington
The moving sidewalk is an enterable supporter in North Poddington.
Definition: a room is sidewalky if it is a start listed in the Table of Moving Sidewalk Places.
Every turn when the player is on the moving sidewalk and the location is sidewalky (this is the move the sidewalk rule): [“location”=room where the player is]
choose a row with a start of the location in the Table of Moving Sidewalk Places; [this is guaranteed to work because the location is sidewalky]
say the message entry;
move the moving sidewalk to the destination entry; [and the player will move with it, as will anything on the sidewalk]
Carry out going to a sidewalky room (called new place) when the moving sidewalk is not in new place (this is the update sidewalk location on going rule):
now the moving sidewalk is in new place.
Every turn when the location is sidewalky and the moving sidewalk is not in the location (this is the update sidewalk location in an emergency rule):
now the moving sidewalk is in the location.
Instead of waving hands:
say “A cheery crowd that you hadn’t seen before hoists you onto its shoulders and deposits you in Poddington South.”;
move the player to Poddington South.[/code]
There’s a couple of issues. One is that the last “every turn” rule is a bit wonky–as you can see if you try “wave” and then “get on sidewalk,” the sidewalk gets moved to Poddington South before the end of the turn (it’s there) but after the room description for the new location is printed. One way to avoid this would be to write a phrase like “move the player and maybe the sidewalk to (new place - a room)” which checks whether it needs to move the sidewalk first, and then use that instead of “move the player to Poddington South.” (I can write this up more coherently if you want to see.)
Another issue is the behavior of stuff you drop on the sidewalk. Right now there isn’t anything to drop on the sidewalk, but if you did have something to drop in this code, it would just sit on the sidewalk until you got back on or left, and if you went to another sidewalky room it would magically reappear there. You’d probably want to take care of that somehow (simplest solution: Don’t let the player drop anything on the sidewalk).
Hope this is helpful!