Greetings from a newbie

Just wanted to hop by and say hello. I’ve been spending most of my free time reading on how to use IF, and I must say, I’m positively surprised by it’s capabilities. :open_mouth: I’ve been having loads of fun just messing around trying to create various objects and rooms.

I have, however come across a slight difficulty, and even after 2 hours of haggling I’ve been unable to solve this one.

My code is as follows:

The lighter is a portable device. The description of the lighter is “A silver lighter which can ignite things. Its light is currently [brightness of the lighter].” The lighter has a brightness. The lighter is radiant. The lighter is in the upper drawer.
Instead of burning paper:
if the player has a lighter,
now the leaflet is nowhere;
say “The paper quickly turns to ashes.”;
else say “You have nothing to set the paper on fire. Dumbass.”

I’ve tried moving it all around, but it keeps telling me ‘but this is a phrase which I don’t recognise’, referring to the last phrase. I’ve tried adding colons in front of ‘if’ and ‘else’, or just ‘else’, but that doesn’t seem to really help either…
Any help would be greatly appreciated. I’m sorry if this is on the wrong subforums, I haven’t been able to find the ‘help’ section just yet as I am in quite a hurry.

Welcome! Inform 7 questions go in the “Inform 6 and 7 development” forum here–I moved it for you.

Anyway, the issue is that you need a colon after “else” (not before it). And then proper formatting will be important; you need to make sure everything’s indented properly. See §11.7 of the documentation. So this will work:

Instead of burning paper: if the player has a lighter: now the paper is nowhere; say "The paper quickly turns to ashes."; else: say "You have nothing to set the paper on fire. Dumbass."

Note that the two things under “if the player has a lighter” both have to be indented so they both are governed by it, the “else” is at the same level as the “if,” and the line under the “else” is indented. Sometimes you can use a comma on the same line, but that only works when you have only one line that goes with the “if” clause.

Also, it’s a very good idea to use “code” tags when you’re posting code–press the “code” button above the box where you type your comment, and paste your code in between. That will preserve your indentation, which as you can see can be critical.

Oh also also, it looked like you were calling the same thing the paper in one place and a leaflet in another.

Again, welcome!

Thank you so much Matt. As you’ve easily been able to decipher I am indeed a newbie when it comes to this stuff.

I’ll make sure to post in the right sub-forums and use the ‘code’ tag next time.

About the paper… after reading the chapter about kinds I wrote:

Paper is a kind of thing. The orientation leaflet is in the D-Class Cell. The leaflet is a paper.

(without indentations, it seems to work fine. I assume indentations are only necessary for ‘if’ statements and such)

Essentially my idea was to create a kind known as ‘paper’, then tag all objects such as ‘newspaper’ and ‘orientation leaflet’ as being paper. That’s how I understood ‘kinds’ anyway :question: I might just be using it wrong, which, really, wouldn’t surprise me at all.

Thanks again for your help. I am truly grateful. :smiley:

Problem is, your instruction “now the leaflet is nowhere” will make the leaflet disappear, even if it was the newspaper that was being burned. You can use the phrase “the noun” to refer to whatever is being burned in the rule.

Paper is a kind of thing. The orientation leaflet is in the D-Class Cell. The leaflet is a paper.

Instead of burning paper:
	if the player has a lighter:
		now the noun is nowhere;
		say "[The noun] quickly turns to ashes.";
		say "You have nothing to set [the noun] on fire. Dumbass."

Thank you jrb. I think I may have run across a similar problem in the past regarding another item… I’ll need to get used to using things like [The noun] when writing rules. I’m sure I’ll be a few steps ahead after having read both books.

This is probably the kindest, most helpful community I’ve come across so far. I think I’m going to have a great time here, and hopefully I’ll be the one helping out others in the future. :wink:

Another way to handle the issue that jrb pointed out is to use a temporary variable that you set in the beginning of the rule:

[code]Paper is a kind of thing. The orientation leaflet is in the D-Class Cell. The leaflet is a paper.

Instead of burning a paper (called the kindling):
if the player has a lighter:
now the kindling is nowhere;
say “[The kindling] quickly turns to ashes.”;
say “You have nothing to set [the kindling] on fire. Dumbass.”[/code]

Here “the kindling” gets set to the thing that you’re burning at the beginning of the rule, and you can use “the kindling” to refer to it for the rest of the rule. There are many different contexts in which you can do a thing like this (for instance, you could define a kind called match, and write something like “if the player holds a match (called the igniter),” which would set “igniter” to a match the player holds).

On the other hand, “the noun” always refers to the thing that you’re performing the current action on; you don’t even have to have referred to it already. So it’s OK to say:

Instead of burning: say "[The noun] can't be burned."

and “the noun” will refer to what the player is trying to burn.

(And one of the neat tricks is that, if you have both these rules, Inform will try the more specific “Instead of burning a paper” rule before the general “Instead of burning” rule, so you don’t actually get both messages… but that’s another story.)

Your kind words are appreciated!

[rant]Eventually it’s best to not use “Instead” for everything, since it bypasses the parser.

[code]“Disco Inferno”

A thing can be burnable.

paper is a kind of thing. paper is usually burnable.

a thing can be an igniter.

The block burning rule is not listed in any rulebook.

Check burning (this is the not flammable rule):
if the noun is not burnable:
say “[The noun] isn’t something you can easily set ablaze.” instead.

Check burning (this is the need a source of ignition rule):
if the player does not carry an igniter:
say “You don’t have any way to set that ablaze.” instead.

Carry out burning:
say “You try to set [the noun] ablaze with [the random igniter carried by the player].”

Carry out burning:
now the noun is off-stage.

Report burning:
say “There is a brief ball of fire, and [the noun] turns to ash instantly.”

Disco is a room. “You are totally burning up the dance floor!”

A torch is in Disco. It is lit. It is an igniter.

some flimsy paper decorations are in disco. “Some paper decorations hang overhead, providing a festive atmosphere.” It is paper.

a newspaper is in disco. It is paper. The description is “The headline reads DISCO DEAD, SOURCES SAY.”

a bomb is in disco. The description is “It looks dangerous. The fuse is not lit.”

A fuse is part of bomb. It is burnable. The description is “It looks really long.”

After burning fuse:
say “It sputters and sparks thrillingly, but before it burns half and inch toward the bomb, a security guard dressed like a construction worker runs over and extinguishes it with a blast from a fire extinguisher. ‘You can’t burn this mother down,’ he asserts, boogie-ing back into the shadows.”;
now fuse is part of bomb.

A pile of wet rags is in disco.

The player carries a cigarette lighter. Lighter is an igniter. The description is “It’s a common disposable cigarette lighter.”

The player carries a lit cigarette. It is an igniter. [/code][/rant]

Wow. Impressive. I thought basic statements like ‘A thing can be burnable’ were already a part of the ‘rulebook’ as you might call it. Inform does a great job at guessing properties and such. Thank you for the detailed example Hanon, I’ll be sure to use some of it for my own little project. Cheers!