I am trying to build in a teleporting function into my game in which the player can teleport to any visited room. I have the following code:
porting is an action applying to one thing. understand "port to [thing]" or "port [thing]" as porting
carry out porting:
repeat through the table of porting:
if the topic understood includes input entry:
now player is in equivalent entry;
Table of Porting
Input Equivalent (room)
"Foyer" Room-1
"Entrance Hallway" or "entrance" Room-2
(Note that I donât know if the above code âworksâ because of the parser error. I havenât been able to troubleshoot it)
However, I get the parser error:
You can't see any such thing.
Iâve tried various language to disable the canât see any such thing error in the case of porting but cannot find the correct language.
Can someone tell me how to disable a parser error (if possible)? Or do I need to find another way to code this?
Youâre using [thing] grammar tokens, but there is no âFoyerâ object, for example.
In general, try not to use texts. Try:
Room-1 is room. Understand "Foyer" as Room-1. Room-2 is a room. Understand "Entrance Hallway/--" as Room-2. Room-2 is east of room-1.
porting is an action applying to one thing. understand "port to [any visited room]" or "port [any visited room]" as porting
carry out porting a room:
now player is in the noun;
So the main thing thatâs going on is that the various rooms or objects you want to teleport to are out of scope (teleporting to the room youâre already in isnât very useful!) so the parser isnât finding what the player types in. A way around this is to have the action apply to some text, rather than objects, but youâve defined the action with things, so thatâs why youâre getting behavior different from ASK CHARACTER ABOUT ARBITRARY TEXT.
In this case, I think sticking with objects is actually better since as youâre seeing, the topic approach requires you to manually implement stuff the parser typically handles automatically. The short answer is that you need to change the tokens in your understand statements from [thing] to [any thing]; fortunately, thereâs an example that does most of what you want.
EDIT: sorry, I thought you wanted to let the player teleport to objects as well as rooms, because I am bad at reading. The above is all still right except that you can stick with the âany visited roomâ approach Phil has, which is simpler!
You can use this kind of construction to put just about anything in a parser error, though not everything is going to work due to where it is before action processing. (E) is the âcanât see any such thingâ error.
The parser error internal rule response (E) is "wow".
That includes nothing, you could say ââ for instance, though Iâve noticed that parser errors are going to print a line whether you put something there or not, so the spacing will look off. At least, I donât know how to change that.
You can do weird things with to say definitions, firing off actions, etc.
The parser error internal rule response (E) is "[ridiculous]".
to say ridiculous:
try jumping instead;
This is in no way a recommendation! I wouldnât build anything around this. But the answer to your question is that parser errors, like other texts, can theoretically accommodate substitutions, conditions, nothing, etc
It sounds like you might be asking for a way to say that a particular parser error âisnât an error any moreâ? But that wouldnât make sense in general: if the player types ASDF ZXCVBN and youâve âbypassedâ the rule that says thatâs an error, what on earth is the game supposed to do?
You can bypass certain specific errors by saying that a rule âdoes nothingâ, just as you mentioned. But you need to know what check it is that youâre trying to bypass.