Duplicates: Lighting Matches

It’s funny how something you think is going to be very simple in Inform ends up taking about 5 hours and about 260 error messages!

This little problem came up when I started playing with the ‘duplicates’ feature as outlined in Chapter 4.13.

The idea seems to be to create a type (a shape is a kind of thing) and then something within that class (a square is a kind of shape). This then allows you to tell Inform “three squares are in the lab” which will create three objects which the player can then take any number of - “take one square”, “take two squares”, “take all squares”

This was all going fine until I wanted to make a box of matches and then destroy/move/remove from play individual matches which have been burned.

my current set up is;

this creates; Problem. You wrote ‘now the match is in room 0’ : but this is not explicit enough, and should set out definite relationships between specific things, like ‘now the cat is in the bag’, not something more elusive like ‘now the cat is carried by a woman.’ (Which woman? That’s the trouble.)

I’ve tried 'move the noun to room 0 (which moves the lamp), or move the second noun (which causes a runtime error crash).

there’s several ways I’ve tried getting rid of the used match, room 0 is the location I normally used for storing objects which are out-of-play, even though I know there’s a command for out-of-play. Ideally once the match is struck I’d like it to burn for 1 turn then disappear from the inventory or become used and have its description change to ‘match (used)’ or something, but having a 6 unused matches and six used is going to get messy.

all a bit of a muddle, sorry - I’m sure there’s a much simpler way of doing all this!

just figured it out!

this works by moving everything flagged as used!

Now I just have to figure out how to make the match burn for only 1 turn then disappear

What you wanted in your original code was something like:

instead of burning the lamp when a lit match (called M) is carried by the player:

That distinguishes a particular match, and you can then move M around or whatever.

Ah, that’s very useful to know. Right now I’ve been using ‘the match’ and then in instances when this creates an error replacing it with ‘the noun’ which fixes the problem, but then creates problems when I want to do things like ‘now the noun is used’ because it doesn’t know which noun.

so now can i say ‘now the match (called M) is used’ or can I just say ‘now M is used’ or whatever? Will give it a try, thanks.

(Now spent about 7 hours trying to make this work!)

Here’s what I’ve got now and it seems to work, with all used matches being removed from the inventory;

The only problem now is that the player can repeatedly strike an already lit match BEFORE it ‘clucks’ and keep it alight indefinitely.

all attempts to make the match ‘used’ at the point of being lit have been met with severe resistance by Inform. I have a headache now and I’m going to sleep!

First, it’s helpful to post your full code, in case another part of the code is interfering. It’s easy enough to figure out in this case, though.

You don’t need to define the “lit” property for any thing; the standard Rules already contain the line “A thing can be lit or unlit. A thing is usually unlit.”

A lot of your logic isn’t careful about selecting a certain match. That can cause problems for you later.

I’ve reorganized your code into mostly check, carry out, and report rules. When you’re writing or rewriting an action, this generally makes the behavior much easier to follow.

I believe this accomplishes all of the behavior you want to see.

[code]There is room.

A burner is a kind of thing.
A match is a kind of burner. A match can be used.

A lamp is a burner, here.
A matchbox is closed, openable, here. The matchbox contains twelve matches.

The block burning rule is not listed in the check burning rules.

Before opening the not held matchbox:
say “(first taking the matchbox)”;
silently try taking the matchbox.

Check burning the lamp when the player does not carry a lit match:
say “Try lighting it with something.” instead.

Check burning when the noun is not a burner:
say “This dangerous act would achieve little.” instead.

Check burning a match when the noun is not held:
say “You’ll only be able to do that if you take a match out of the matchbox first.” instead.

Check burning a lit match:
say “You can’t light a match if it’s been used.” instead.

Carry out burning:
now the noun is lit.

Every turn when a match is lit:
repeat with M running through lit matches:
if M is used:
if M is visible, say “The flame reaches the end of the match and it burns out.”;
remove M from play;
now M is used.
[A match dies out after being lit for 1 turn, and multiple matches can be lit
in succession without interfering with each other.]

Report burning the lamp:
say “The lamp is lit.”

Report burning a match:
say “You strike the match and it quickly starts to burn.”

Does the player mean burning a lit thing: it is unlikely.[/code]

You may also want to check out “Example 407 - The Cow Exonerated” in the Inform Documentation.

Just wondering, but because you use the ‘lit’ characteristic I presume the items (like a match or the lamp) automatically become light sources? Or does that need to be set separately? If the later I would recommend using another name for the ‘lit’ characteristic, if not, wow, i7 is bloody amazing, carry on, and ignore. :slight_smile:

The lit/unlit property is already defined in the standard rules and a lit thing is indeed automatically a light source. So yes, “i7 is bloody amazing” (strictly speaking it’s i6 not i7). :laughing:

@ChrisC wow thankyou for all that. You just condensed it all down into something that made everything a lot easier. I like the fact that the matches now burn for 1 turn without there needing to be a timer because once a match is lit, next turn it gets picked up as lit and removed from play. Excellent work.

@Tanga yes when the match is ‘lit’ it will provide light in a dark room, but only for one turn, so maybe I could construct a puzzle where the lamp goes out and the only way to solve the puzzle is to repeatedly light the remaining matches. or maybe a monster which appears when the lamp runs out of fuel and then the match is struck, only to go out 1 turn later…


Whenever you write “the match”, the compiler always thinks you mean “a match”. (Because there are ten matches, so there’s no such thing as the match.)

If you always write “a match”, this whole exercise will be much less confusing.

Yeah, this is what I meant by my matches comment before. It doesn’t affect the actual behavior of the code, but it does make it much easier to understand what’s going on.