Compiling error when I assign an action applying to one thing to an object property

Here’s the original code that compiles and works as expected:

Lab is a room.

A power is a kind of an object.
A power has an action called an invocation.

Foo is a power.

Fooing is an action applying to nothing.

The invocation of foo is fooing.

Understand "foo" as fooing.

Instead of fooing:
	say "Curses! Fooed again!".

Test me with "foo".

But if I change the fooing action to apply to one thing:

Lab is a room.

A power is a kind of an object.
A power has an action called an invocation.

Foo is a power.

Fooing is an action applying to one thing.

The invocation of foo is fooing.

Understand "foo [something]" as fooing.

Instead of fooing:
	say "You foo [the noun]!".

Test me with "foo me".

the code compilation fails with the following error:

Screenshot 2023-04-10 at 9.37.51 AM

I don’t understand what the error means, so I don’t know how to fix it.

I think (may be wrong) that the action needs an actor and an object, and that the actor is implied to be the player. If I replace ‘an action called an invocation’ with ‘an action name called an invocation’, and ‘the invocation of foo is fooing’ with ‘the invocation of foo is the fooing action’, it compiles, but I don’t know if that gives you want you want.

Edit: It also compiles if you specify an object:

Lab is a room. The ball is in Lab.

A power is a kind of an object.
A power has an action called an invocation.

Foo is a power.

Fooing is an action applying to one thing.

The invocation of foo is fooing the ball.

Understand "foo [something]" as fooing.

Instead of fooing:
	say "You foo [the noun]!".

Test me with "foo me".


I tried multiple ways to make the invocation be fooing some variable but it kept giving a horrible crash result from Inform.

2 Likes

I guess the question is how you are going to use this invocation property.

With your original attempt:

A power has an action called an invocation.
The invocation of foo is fooing.

You could do this:

    try the invocation of foo;

Here “fooing” is a complete action, so this makes sense to the compiler. This also works if you specify any other complete action, as Brian said:

[If the action "fooing something"]
The invocation of foo is fooing the ball.

[...or even]

The invocation of foo is inserting the ball into the trophy case.

But if you want to specify a generic action, with nouns to be filled in later, that’s harder. In that case, “try the invocation of foo” isn’t a complete instruction. And there’s no easy way to say “try the invocation of foo on the ball”.

(It’s not impossible, but we should narrow down what you want before we get into code!)

3 Likes

This situation arose from:

The power object contains the action in a property, among other properties related to the action, like info text, active vs. inactive, whether it can it be used indoors or outdoors or both, etc. It allows me to do a bunch of checks of generic power commonalities in a few Action Behavior rules. I get the power object by grabbing the current action, iterating through all power objects and returning the power whose invocation property matches the current action. Then, I have access to all of the simulated action properties via the power object.

The invocation is really never invoked (yet, anyway). It just provides a way to find the corresponding power object that contains all of the simulated action properties I need for my generic power code.

I’m intrigued by your idea of using an action name instead of an action. I’m going to play around with it and see what I can do. I really only need the action name to find the corresponding power object, so maybe that’s enough. Using an entire action is probably overkill. Will let you know either way.

1 Like

An action name will work for that, yeah.

You can make relations with action names or use them as table columns, so there are straightforward ways to associate info with them despite being unable to put properties on them.

Okay, the action name solution is working great for me. Thanks for all the help!

I guess I still don’t understand why the compilation is failing. Maybe something to do with putting actions with different arities into an object’s action property?

At this point, it doesn’t matter much for me, aside from curiosity.

It’s the difference between a specific action (“taking the ball”, something the game could perform) and a description of actions (“taking something”). When you define an action variable, it has to contain a specific action.

(You could write “try taking the ball”, but “try taking something” would be a compilation error. Same deal.)

An action name variable is just the verb part – “taking”, “waiting”, “pushing”, “fooing”. This is a simple value; you can always store that.

4 Likes