Parser errors

Hello, all:

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?

1 Like

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;
3 Likes

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!

2 Likes

Thank you for taking the time not only to correct but to explain why. The why helps me learn.

1 Like

Thanks again for explaining why, the why is what helps me learn.

1 Like

Just for snicks, is there a way to bypass a parser error by saying it does nothing? What would syntax be?

If you made a parser error do nothing, then the player would get no feedback. What is it you want to do?

I’m just wondering if there is a way. I would not use it in this case, I’m just wondering what the coding would look like for future reference.

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

2 Likes

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.