Problem with a Say Phrase

Hi,

I copied a to say phrase from Example 396. It seems correct, and I moved it to the beginning of the source in case it was the order that was the problem, but it still doesn’t work. Inform says it doesn’t know how to say that, even though I’ve told it. What follows is the phrase, and the source in which it’s used. The actions and the other substitutions all work. Let me know if more of the source would be helpful:


To say in-on (item - a thing):
	if the item is a container:
		say "in [the item]";
	else:
		say "on [the item]".

[***]

To say noposture:
	say "[We] can't do that [in-on] [the holder of the actor]".

[***]

[ This code throws the error: ]

Report someone taking position (this is the position report rule):
	say "[The actor] [are] [now] [the posture of the actor][if the holder of the actor is not the location] [in-on] [the holder of the actor][end if]."

What is the exact text of the error message? That might help narrow down the problem.

One thing that’s apparent with this excerpt is that you use the phrase [the posture of the actor], but it’s not defined anywhere in your own code. Is that maybe from an extension you’re using? Are you sure you’ve used an appropriate include line for that extension?

I think what’s happening is that you’re separating the substitutions when you write them like this:

[in-on] [the holder of the actor]

So Inform separately evaluates the substitutions and tries to find one that is just defined as “To say in-on”, without an item following it.

What we want to do is to call the say phrase in one substitution together with the item, enclosed by just one set of brackets (as in example 396):

[in-on the holder of the actor]
1 Like

Sorry for any confusion, Patrick. That is defined in my code, I just didn’t include all of that because it all works. I’m having problems specifically with the “[in-on] [item]” phrase.

That’s a good point. Unfortunately when I write them all in the same substitution like so:


Report someone taking position (this is the position report rule):
	say "[The actor] [are] [now] [the posture of the actor][if the holder of the actor is not the location] [in-on the holder of the actor][end if]."

I get this helpful gem:


Problem. In the sentence 'say "[We] can't do that [in-on the holder of the actor]"'  I was expecting to read an object, but instead found some text that I couldn't understand - 'actor'.
I was trying to match this phrase:
/doc_images/help.png holder of (actor - object) 
But I didn't recognise 'actor'.

I think the position report rule does not contain the problem.

The error message which you quoted refers to:

the sentence 'say "[We] can't do that [in-on the holder of the actor]"'

From your first post, it seems that you use that in the following definition:

To say noposture:
	say "[We] can't do that [in-on] [the holder of the actor]".

The problem is that this is not in the context of a rule concerning actions, unlike the working example “Report someone taking position”. So Inform does not know what “the actor” refers to in this general context.

Depending on the exact effect you want to achieve, you’ll have to restructure your code to either omit mention of the actor, or to place it inside a rule which applies to an action, so that Inform knows who the actor is.

1 Like

The actor is only defined in the context of action processing rules (before, instead, check, etc.). In this case, you are using it in a standalone to say... phrase, which is outside that context.

The same underlying global variable can also be referred to as the person asked in I7, and it has always worked for me in that sort of case. (A tip handed down by zarf years ago. Thanks again, zarf!)

EDIT: To be fair, it was StJohnLimbo who answered your original question about the trouble with your [in-on] phrase, so perhaps his post should be marked as the solution for this thread?

1 Like

@StJohnLimbo @otistdog /me facepalms
My bad, I didn’t read the error properly. Thanks a lot!

EDIT: It all works now.

Don’t worry – it’s not easy to understand that error the first time it’s encountered, and this is definitely a frequently asked question. The underlying cause can be seen in the Standard Rules “Section SR2/7 - The Standard Rulebooks”:

The action-processing rulebook has a person called the actor.

This is what limits the scope. Meanwhile in “Section SR2/2 - Current action”:

The person asked variable translates into I6 as "actor".

That gives global scope to the same I6 variable. Another similar line in the following section also maps the person reaching to the underlying I6 actor variable, so that could be used in the same way.

If it ever doesn’t work, that probably means that you’ve invoked your to say... phrase while the I6 actor global is temporarily set for some subsidiary purpose (like scope checking). If you’re using it in the context of action processing rules, though, it should be set the way that you expect.

2 Likes

I think I just assumed a phrase like that would be able to operate under the scope of the rule that calls upon it in a substitution. But I guess that doesn’t make sense, since it’s legal to say one of those anywhere, and Inform has no way of knowing which variables are allowed when it’s defined so generically? I appreciate that tip about “the person asked”.

You might be interested in Postures by Emily Short and/or Prepositional Correctness by Gavin Lambert, by the way.

2 Likes