Problems with run-time error P10 and timed events

Hi all,

I am new to Inform 7, so my apologies since I expect the solution to my issues is fairly simple.

I have an example code block to simulate lighting objects fire- the following code (I assume) is not causing any issues:

When play begins: 
	now the right hand status line is "[time of day]"; 

This Place is a room. 

A flammable object is a kind of thing.
A flame-state is a kind of value. Flame-states are initial, alight, and ashes. A flammable object has a flame-state.
A flammable object has a time called the flame-life. 
The flame-life of a flammable object is usually 1 minute.

A thing can be sparkable or inert. A thing is usually inert.

There is a flint in This Place. The flint is sparkable.

There is a knife in This Place. It is sparkable.

There is some dried grass in This Place. It is a flammable object. The flame-state of the dried grass is initial. The indefinite article of dried grass is "some".

The description of a thing is "[if sparkable]It looks like it could make a spark, if you struck it on something.[else if the noun is a flammable object and the flame-state of the noun is initial]It looks like it could tempt a spark.[else if the noun is a flammable object and the flame-state of the noun is alight]It's on fire.[else if the noun is a flammable object and the flame-state of the noun is ashes]It is now just ash.[end if]".

After printing the name of a flammable object (called object) (this is the flame state identification rule):
	if the flame-state of the object is not initial,
		say " ([flame-state of the object])".

The sparks are a thing. The indefinite article of sparks is "some". The sparks are initially nowhere. 

Understand the command "spark" as something new.
Understand "spark [thing] with/on/against [thing]" as sparking it with.
Understand "hit [thing] with/on/against [thing]" as sparking it with.
Understand "strike [thing] with/on/against [thing]" as sparking it with.
Understand "scrape [thing] with/on/against [thing]" as sparking it with.
Sparking it with is an action applying to two things.

Check sparking it with:
	if the noun is not sparkable,
		say "The [the noun] is not sparkable." instead;
	if the second noun is not sparkable,
		say "The [the second noun] is not sparkable." instead;
	if the noun is the second noun,
		say "That doesn't seem possible." instead;
	otherwise:
		say "You strike [the noun] on [the second noun].".

Carry out sparking it with:
	say "Sparks scatter around.";
	now the player is carrying sparks;
	fizzling out occurs in 1 turn from now.
	
Report sparking it with:
	say "Better decide what to burn before you do.";

At the time when fizzling out occurs: 
    try dropping the sparks.
Instead of dropping the sparks:
	say "The remaining sparks die out.";
	now the sparks are nowhere.

The next code is the actual ‘burning’ action, which I’ve had various errors with and haven’t been able to understand the cause really:

Understand the command "kindle" as something new.
Understand the commands "light" and "burn" as something new.
Understand "kindle [something]" as kindling it.
Understand "set fire to [something]" as kindling it.
Understand "set [something] on fire" as kindling it.
Kindling it is an action applying to one thing.
Understand the commands "light" and "burn" as "kindle".

Check kindling it:
	if the noun is not a flammable object,
		say "You don't want to burn [the noun]." instead;
	if the player is not carrying sparks,
		say "You need to make some sparks (if there were any, they've gone out by now)." instead;
	if the noun is the second noun,
		say "That doesn't seem possible." instead;
	otherwise:
		say "You blow some sparks toward [the noun].".
	
Carry out kindling it:
	if the flame-state of the noun is alight,
		say "[The noun] is already burning." instead;
	if the flame-state of the noun is initial,
		now the flame-state of the noun is alight;
		becoming ash occurs in the flame-life of the noun from now.
		
Report kindling it:
	if the flame-state of the noun is alight,
		say "[The noun] burns.";
	otherwise:
		if the flame-state of the noun is ashes,
			say "There's no use in burning ashes.".	

At the time when becoming ash occurs:
	if the noun is a flammable object,
		now the flame-state of the noun is ashes.


test me with "actions / burn fire / set fire to grass / strike flint on knife / set grass on fire / light knife / i / l "

This code was throwing the runtime error (p10) about non-existent properties, of non-flammable things I assume, when trying to “light the knife”, but also after simply ‘looking’ after the grass object was alight. I got rid of this error by adding the line if the noun is a flammable object, to the last timed event (becoming ash). I am not exactly sure why this disappeared however.

My second issue is with the timed event (becoming ash). No matter how long I wait in-game, no flammable object in the alight condition becomes ashes. This has confused me greatly- I’ve looked through and tried example code from the documentation and other manuals, but haven’t been able to solve it despite having similarly formatted code. My only guess is that the issue might have to do with how Inform is measuring time; for example when I use ‘showme [a flammable object]’ the flame-life is always whatever specified time after 12:00 am, how is this a way to measure the time in-game, rather than counting back from the specified time?

Thanks in advance to anyone who may answer.

1 Like

Try adding

say "becoming ash: [the noun]"; 

to your becoming ash rule.

You’ll notice it thinks “noun” means the knife. This is because “noun” is set when processing an action. It doesn’t get set when the dried grass trips the becoming ash rule.

One solution is to track the “ash countdown” of each thing on the thing itself instead of using scheduled events, and handle the countdown in an every turn rule.

3 Likes

I don’t have time to dig into the second issue right now – I suspect you’re right and that you’ll have to do something like have the flame-life just be a number, and then say the event occurs in flame-life minutes from now, or something like that? But problem one is I’m pretty sure happening because naming the action “kindling it” rather than just “kindling” is confusing the computer; this isn’t really documented, but the “it” in action names is reserved for actions applying to two things, and acts as a placeholder showing where the nouns should go. So if you just change the action name to “kindling” you should be good!

1 Like

Ah, good eyes! I think you could also catch this by having the event repeat over all flammable objects (probably a good idea in case multiple things are burning).

This I think does what you want:

When play begins: 
	now the right hand status line is "[time of day]"; 

This Place is a room. 

A flammable object is a kind of thing.
A flame-state is a kind of value. Flame-states are initial, alight, and ashes. A flammable object has a flame-state.
A flammable object has a number called the flame-life. 
The flame-life of a flammable object is usually 1.
A flammable object has a number called a ash countdown. The ash countdown is usually -1.

A thing can be sparkable or inert. A thing is usually inert.

There is a flint in This Place. The flint is sparkable.

There is a knife in This Place. It is sparkable.

There is some dried grass in This Place. It is a flammable object. The flame-state of the dried grass is initial. The indefinite article of dried grass is "some".

The description of a thing is "[if sparkable]It looks like it could make a spark, if you struck it on something.[else if the noun is a flammable object and the flame-state of the noun is initial]It looks like it could tempt a spark.[else if the noun is a flammable object and the flame-state of the noun is alight]It's on fire.[else if the noun is a flammable object and the flame-state of the noun is ashes]It is now just ash.[end if]".

After printing the name of a flammable object (called object) (this is the flame state identification rule):
	if the flame-state of the object is not initial,
		say " ([flame-state of the object])".

The sparks are a thing. The indefinite article of sparks is "some". The sparks are initially nowhere. 
sparks have a number called the fizzle countdown. The fizzle countdown is usually -1.

Understand the command "spark" as something new.
Understand "spark [thing] with/on/against [thing]" as sparking it with.
Understand "hit [thing] with/on/against [thing]" as sparking it with.
Understand "strike [thing] with/on/against [thing]" as sparking it with.
Understand "scrape [thing] with/on/against [thing]" as sparking it with.
Sparking it with is an action applying to two things.

Check sparking it with:
	if the noun is not sparkable,
		say "The [the noun] is not sparkable." instead;
	if the second noun is not sparkable,
		say "The [the second noun] is not sparkable." instead;
	if the noun is the second noun,
		say "That doesn't seem possible." instead;
	otherwise:
		say "You strike [the noun] on [the second noun].".

Carry out sparking it with:
	say "Sparks scatter around.";
	now the player is carrying sparks;
	now the fizzle countdown of the sparks is 1;
	
Report sparking it with:
	say "Better decide what to burn before you do.";

Every turn when the player encloses the sparks:
	if the fizzle countdown of the sparks <= 0:
		now the sparks are nowhere;
		now the fizzle countdown of the sparks is -1;
	otherwise:
		decrement the fizzle countdown of the sparks;
	
Understand the command "kindle" as something new.
Understand the commands "light" and "burn" as something new.
Understand "kindle [something]" as kindling it.
Understand "set fire to [something]" as kindling it.
Understand "set [something] on fire" as kindling it.
Kindling it is an action applying to one thing.
Understand the commands "light" and "burn" as "kindle".

Check kindling it:
	if the noun is not a flammable object,
		say "You don't want to burn [the noun]." instead;
	if the player is not carrying sparks,
		say "You need to make some sparks (if there were any, they've gone out by now)." instead;
	if the noun is the second noun,
		say "That doesn't seem possible." instead;
	otherwise:
		say "You blow some sparks toward [the noun].".
	
Carry out kindling it:
	if the flame-state of the noun is alight,
		say "[The noun] is already burning." instead;
	if the flame-state of the noun is initial,
		now the flame-state of the noun is alight;
		now the ash countdown of the noun is the flame-life of the noun;
		
Report kindling it:
	if the flame-state of the noun is alight,
		say "[The noun] burns.";
	otherwise:
		if the flame-state of the noun is ashes,
			say "There's no use in burning ashes.".	

Every turn (this is the ash countdown rule):
	repeat with FO running through flammable objects:
		if the ash countdown of FO is 0:
			say "[The FO] burns to ash.";
			now the ash countdown of FO is -1;
			now the flame-state of FO is ashes;
		otherwise if the ash countdown of FO > 0:
			decrement ash countdown of FO;


test me with "actions / burn fire / set fire to grass / strike flint on knife / set grass on fire / light knife / i / l "
1 Like

Thanks very much to both Phil and Mike, I really appreciate the help.

The suggested fix works perfectly! The relationship between time and turns is something I’ll have to look into more to understand Inform; it seems using turns to measure the passage of time is much more reliable than minutes, and does kind of the same thing anyway as each ‘turn’ is an in-game minute anyway :woman_shrugging:t2:.

Also regarding Mike’s note about action [it] in the documentation is interesting, I had not idea that was the case. I knew writing ‘it with’ usually applies to two things, so I thought removing ‘with’ would work for a one-thing action. Thanks for this clarification.

1 Like