I’ve tried to search the forum about this, but it’s difficult when the search blocks words like “text” and “going.” I also thought I read about an extension that might handle this but I couldn’t find it.
I’m trying to write a framework for displaying custom text when you move to/from a room, such as “You follow a long twisting passage that eventually leads to…”. I realize that I could simply make before/after rules every time this is necessary, but I thought this might be better if I wanted to use it often.
This is horrible, but it appears to work:
[code]“New Test” by Test
A custom travel text room is a kind of room.
A custom travel text room has some text called traveling-from-north text.
A custom travel text room has some text called traveling-to-north text.
[etc. for every direction]
Place 1 is a room.
Place 2 is a custom travel text room.
Place 3 is a custom travel text room.
Place 2 is south of Place 1. Place 3 is south of Place 2.
The traveling-from-north text of Place 2 is “You travel south through a long, rusty pipe to…”.
The traveling-to-north text of Place 2 is “You scramble north along the rusty pipe again to…”.
After going south to a custom travel text room (this is the say traveling-from-north text rule):
If the traveling-from-north text of the location is not “”,
Say the traveling-from-north text of the location;
Otherwise say “Debug - there is no special south traveling text!”;
Continue the action.
[etc. for every direction]
Before going north from a custom travel text room (this is the say traveling-to-north text rule):
If the traveling-to-north text of the location is not “”,
Say the traveling-to-north text of the location;
Otherwise say “Debug - there is no special north traveling text!”;
Continue the action.
[etc. for every direction]
Test me with “s / s / n / n”.[/code]
I set up a kind of room because I figured it would be quite wasteful to assume that every room needs a set of strings that will be empty most of the time. Even so, the sheer number of strings needed for this will still end up being wasteful. Is there a more efficient way to do it?
Do you see any obvious problems this could cause, ways that it could print text erroneously? Probably the “before” parts, since we don’t know yet whether the action will succeed?
What if I want to block the text when a player uses Emily Short’s go to command?