A Question about Action Variables

This code is probably missing something obvious, but I have been banging my head against the wall trying to see it. Everything works great until I try to reference last state in the Report rule. The code compiles, but when I try to stuff fluff in the puffer, I get run-time error.

The error is:
*** Run-time problem P10: Since the fluff ball is not allowed the property “last state”, it is against the rules to try to use it.

I don’t understand why it things I’m trying to reference a last state property on the fluff ball. The examples I have looked at don’t clarify action variables. They just reference them.

Please help.

[code]“Puffer” by Esadurate

The Barn is a room.

Fullness is a kind of value. The fullnesses are saggy, floppy, lumpy, fluffy, stuffy, stuffed, puffy and puffed.

A puff-thing is a kind of a thing. A puff-thing has a fullness. Understand the fullness property as describing a puff-thing.
A fluff ball is a kind of thing.

A puff-thing called a puffer is in the Barn. The puffer is saggy.

Puff-stuffing it in is an action applying to one carried thing and one touchable thing. Puff-stuffing it in has a fullness called the last state.

Understand “stuff [something] in/into [something]” as puff-stuffing it in. Understand “stuff [something] with [something]” as puff-stuffing it in (with nouns reversed).

Understand “stuff [something]” as puff-stuffing it in.

Rule for supplying a missing second noun while puff-stuffing:
if the player does not enclose a fluff ball:
let F be a random fluff ball that is off-stage;
move F to the player;
if a fluff ball is carried:
now the second noun is the noun;
now the noun is a random fluff ball that is carried by the player;
say “(with fluff)[command clarification break]”;
continue the action;
otherwise:
say “Blah!”.

Setting action variables for puff-stuffing it in:
now the last state is the fullness of the second noun.

Check puff-stuffing something in something:
if the noun is not a fluff ball or the second noun is not the puffer, say “I’m not sure how to do that.” instead;
if the puffer is puffed, say “It’s completely full.” instead.

Carry out puff-stuffing something in something:
remove the noun from play;
now the fullness of the second noun is the fullness after the fullness of the second noun.

Report puff-stuffing something in something:
say “[The last state] [second noun] is now [fullness of the second noun].”

The player carries 10 fluff balls.[/code]

Here’s the story as it plays out:

[code]Barn
You can see a puffer here.

stuff the puffer with fluff

*** Run-time problem P10: Since the fluff ball is not allowed the property “last state”, it is against the rules to try to use it.

puffer is now floppy.

stuff the fluff ball in the puffer

*** Run-time problem P10: Since the fluff ball is not allowed the property “last state”, it is against the rules to try to use it.

puffer is now lumpy.

[/code]

My immediate thought is: you’ve never declared “last state” anywhere. It’s not a global variable, or an action variable, or a property. So Inform guesses that you mean a property of the noun, since it can’t always check those at compile-time so as far as it’s concerned your code might be entirely valid. Then it discovers at run-time that it’s not a property of the noun, and gives the error.

Solution: declare the “last state” somehow. (Global variable or action variable are probably what you want.)

From a quick test run, I think that you need the two following changes:

“Puff-stuffing it in has a fullness called the last state.” needs to be “The Puff-stuffing it in action has a fullness called the last state.”

and

“Setting action variables for puff-stuffing it in:” needs to be “Setting action variables for puff-stuffing something in:”

With those two changes, the source runs for me.

It is declared as an action variable immediately after the action itself is declared. Apparently, however, I declared it incorrectly.

They worked for me as well. I guess the starting point was that I was missing the word “action” in the variable declaration. Once that was in place, I got a message during compile about the setting rule.

I wonder what the compiler thought I was trying to do with my original declaration.

Anyway, thank you!

It thought that you were (implicitly) declaring an object called “Puff-stuffing it in”, and saying that it had a fullness. If you check the World Index you’ll find it there, in the list of objects not initially in any room. (That is often a good place to look when Inform is behaving mysteriously.)

Okay cool. Thank you. I will look there next time I get in a pinch.