Trying actions with people [solved]

Hey there,

Having a problem with calling an action with a person.

[code]Booping is an action applying to one thing.
carry out booping:
say “You boop [the noun]”;

if the location of the player is the location of the boopee:
try booping the boopee;[/code]

I get “but this is not an action I recognise, or else is malformed in a way I can’t see how to sort out.” Just a sample function, obviously, but I can’t figure out how to make the call work. I’ve tried “try booping with the boopee” and “try booping (the boopee)”, and just about every variation I can think of.

You’re using an if statement outside of a rule or phrase, which means Inform has no idea when or where to execute the code. You also have no “boopee” defined.

Assuming the if statement was just in order to test some code, you probably want something like this:

Booping is an action applying to one thing.
Report booping: say "You boop [the noun]."

Every turn:
	if the location of the player is the location of the boopee:
		try booping the boopee.
There is a room. The boopee is a thing. The boopee is here.

On a more general note, feedback from a command properly belongs to the “report” or “after” rules. That’s not an error per se but more a matter of style and consistency, since it makes things easier in the long run.

I guess I should have written a better example.

The problem I am having here is that I want to be able to call the function with multiple people.

[code]Booping is an action applying to one thing.
Report booping: say “You boop [the noun].”

Every turn:
if the location of the player is the lobby of booping:
try booping Michael;
try booping John;

The lobby of booping is a room. Michael is a person. Michael is in the lobby of booping. John is a person. John is in the lobby of booping.[/code]

It’s still a bit unclear what the problem is, at least to me. Do you want the game to respond something like “You boop Michael and John”? Could you show a hypothetical transcript of what should happen?

Ayyy Juhana! Your IF recorder is great. Thank you for that.

I’m just using example text to save space. The “say” script is just to simplify the actual output. I’ll try to phrase it better.

I have a function that takes a person as input. When the function is called, it modifies several variables in the person. For example, it changes the color of their shirt. The function is only called automatically: The player never calls it. So I need to figure out how to call the function with a person as input. What I am looking for, specifically, is the syntax of calling the function. Using “booping” as the action and “boopee” as the target, I would assume that:

try booping the boopee;

Would call the booping function and send the boopee as the input person, but Inform throws an exception.

“Function” isn’t well-defined in Inform. Are you talking about an action (like “taking the ball”), a phrase (like “remove the ball from play”), a rulebook (like “every turn”), or a rule (like “every turn: say ‘The clock ticks.’”)? EDIT: Or an activity (like “printing the name of the ball”)?

“Exception” is also not a well-defined term here. Is it a Problem message in the Results pane? A Run-Time Problem error? A stack overflow in the interpreter?

Could you post part of your actual source? It’s hard to figure out what the problem is when your example code doesn’t seem to relate to the actual problem you’re having. :wink:

Ok, not sure if this is it but it sounds like instead of action you need a to-phrase (which is closer to traditional functions.)

To boop (boopee - a person):
    say "You boop [the boopee].";
    now the boopee is bruised;
    [other stuff here]

…and you’d call it with “boop Michael” and “boop John,” and “boopee” would now refer to that person inside the phrase.

That’s what I needed, thanks!

Was it perhaps lack of “Understand ‘Boop [something]’ as booping.” ?