GOTO (location) error messages?

I have a command called GOTO that takes a location as a noun. I’d like it to do better than “the noun did not make sense in that context.” So I wrote this error stub.

rule for printing a parser error when the latest parser error is the noun did not make sense in that context error:
	if word number 1 in the player's command is "gt" or word number 1 in the player's command is "goto" or (word number 1 in the player's command is "go" and word number 2 in the player's command is "to"):
		say "That location or thing doesn't exist or isn't known to you yet.";
		the rule succeeds;
	continue the action;

This gets the job done, but I’m always worried about random odd parser problems.

It would be simpler if we could say “[the last action processed]” … but when I try for “the current action,” Inform gives it as waiting.

Is there any way to avoid looking at the command text to print out an appropriate error message? Thanks!

Poke around the forum for “action-to-be”. It’s not normally exposed by the Standard Rules, but you can get at it, and it expresses what you want (the action that was under consideration when the parser error happened).

1 Like

Yep, what you want is the I6 global action_to_be.

You can expose it to I7 either as a phrase:

To decide what action name is the action-to-be: (- action_to_be -).

Or as a variable:

The action-to-be is an action name that varies. The action-to-be variable translates into I6 as "action_to_be".

Either way, as zarf said, this holds the verb that’s currently being parsed. You can check “if the action-to-be is the going to action” or whatever you’ve named your goto action.

1 Like

Haha, I found this and implemented it as you were posting it. It works great!

A simple grep of “word number 1” in my various story.ni files shows a lot of places where I can tune up my code. So I think this information is going in my personal “trivial niceties” extension right away.

There is, however, one thing that might trip up people up. My first guess was “if action-to-be is gotoing”, which was my original guess.

rule for printing a parser error when the latest parser error is the noun did not make sense in that context error:
	if action-to-be is the gotoing action: [ not "if action-to-be is gotoing" ]
		say "That location or thing doesn't exist or isn't known to you yet.";
		the rule succeeds;
	continue the action;
2 Likes

Yep, you’ve run into the distinction between “stored actions” and “action names”.

The short version is that “waiting”, as a description, is technically ambiguous. Is it the equivalent of “taking” (i.e. just the name of the action without any arguments), or the equivalent of “taking the lantern” (the action name plus its arguments and actor)?

Inform handles this ambiguity by interpreting “waiting” as the full action (of kind “stored action”) and “the waiting action” as the name without any arguments (of kind “action name”). Action name literals are much rarer in actual code, while stored action literals appear any time you say “try”, so they decided to make action names more verbose.

3 Likes