Hi everyone.
I have come up with some code that seems to do what I want, but I want to see if anybody can foresee any issues that I cannot.
I modified the ‘exit’ command so that if there is exactly one room connected to the location, typing “exit” or “out” will try going the direction toward that room.
I wish for “exit” to work as it normally does in all other circumstances.
Also, rooms in my game are either “findable” or “not findable.” Almost every room is “findable.” The status line at the top of the game displays directions to “findable” rooms. This is so I can hide the directions to “unfindable” rooms in the status bar if I want to.
My thinking with my code below was that I only wanted to interrupt the normal flow of running the exit command if both of the following are true:
- There is exactly one findable room a direction away from the location.
- That findable room is not “outside” from the location.
The below might not be the most elegant way to do it, but it seems to work. I just want to see if anyone can see any major issues with it.
Wayout is a kind of value.
1wyo specifies a wayout.
The player has a wayout.
The wayout of the player is 0wyo.
Exitout is a kind of value.
1exo specifies an exitout.
The player has an exitout.
The exitout of the player is 0exo.
Before exiting:
now the wayout of the player is 0wyo;
now the exitout of the player is 0exo;
let place be location;
repeat with way running through directions:
let place be the room way from the location;
if place is a findable room:
increase the wayout of the player by 1wyo;
if place is outside from the location:
increase the exitout of the player by 1exo;
if the wayout of the player is 1wyo:
if the exitout of the player is 0exo:
repeat with way running through directions:
let place be the room way from the location;
if place is a findable room:
try going the way;
stop the action;
The only other thing I wish to change is the “exit” fail response from “But you aren’t in anything at the moment” to “You must be more specific” as the latter now makes more contextual sense. I’ve done that kind of thing before, but I can’t remember how to do it and I’m not sure how to word what I’m trying to do so I can find the answer in the Inform documentation.
Thanks in advance!