I7 randomly understanding then not understanding code.

I am trying to achieve the following situation: if the player cuts a rope, and they are carrying a certain item, another item is removed from play, and a statement is printed.

I have written the code like this:

Instead of cutting rope, if the player is carrying the glass shard, remove oil lamp from play.

This works.

This also works:

Instead of cutting rope, if the player is carrying the glass shard, Say "Strand by strand, you sever the fibres of the rope until it finally snaps. The lamp falls rapidly to the ground, and splits open as it collides with the trapdoor below. Oil flies in every direction, with the lion's share soaking into the wooden planks of the trapdoor, which immediately catch fire."

However, if I try to include the ‘remove’ function AND the ‘say’ function, I7 suddenly starts playing dumb, and either says that it doesn’t understand what “say” is, as an action, or says that it doesn’t understand what “play” or “remove from play” is, despite that fact that it understands that command perfectly in isolation. Which command it refuses to understand depends on how I arrange them in the code.

This is bullshit! I get the feeling that I can make it understand both commands in the same list by altering some minor thing like a comma or semi colon, or indentation, but none of the variations I’ve tried have made a difference.

Or is it because the “instead” command can only replace something (in this case cutting the rope) with one other action? What would be a better construction to achieve what I want (basically the player cutting the rope, but only with the glass shard item)?

If somebody can provide a solution, and maybe even explain why I7 is doing this, it would be amazing.

You’re not showing the code that doesn’t work, but the most likely explanation is wrong punctuation. If you have more than one expression in a code block (the if conditional), you need to use a colon instead of a comma. Expressions must be separated with a semicolon and indented correctly. The last statement can have either a semicolon or a full stop.

Also, I didn’t even know you can use a comma for rules (Instead of X, do Y). I suggest you start using colon there as well. It’s certainly needed if there’s more than one expression in the rule.

Instead of cutting rope: [<-- colon] if the player is carrying the glass shard: [<-- colon, one tab] say "Whatever."; [<-- semicolon, two tabs] remove oil lamp from play. [<-- full stop or semicolon, two tabs]

That said, you probably want this instead:

Instead of cutting rope when the player is carrying the glass shard: say "Whatever."; remove oil lamp from play.

Otherwise you’ll get a blank response when the player is not carrying the glass shard.

Thanks so much. It’s working with your final suggestion.

Just before you replied, I had managed to get it to remove the lamp and display the message, but it always follwed that with “cutting that would achieve nothing”!

This is academic though, because it’s avoiding the real (more complicated issue). As far as I7 is concerned, the rope has not been cut. To achieve this properly, I think I would need to redefine cutting, or what cutting is capable of, or something like that. Too complicated!

Thanks again :slight_smile:

There are three kinds of object that are notoriously troublesome to implement in IF: fire, rope and liquids. (They’re all non-rigid, divisible substances with a wide variety of applications and manipulations). If you’re still getting used to the I7 syntax, rope may be a particularly challenging thing to tackle.

You probably don’t need to redefine the cutting action entirely, though: chances are, cutting things isn’t really a very big part of your story, and you don’t need any big general rules for how cutting things works. You can do it with specific rules that just pertain to that one rope - that’s what’s happening in the examples above. Figure out what it means, in game terms, for that particular rope to be cut.

Most simply, you can define a new value to describe the rope’s state:

The rope can be cut or uncut. The rope is uncut.

and change it at the appropriate time with

now the rope is cut;

That doesn’t do anything on its own, of course: you have to use that value in relevant ways, like descriptions:

The description of the rope is "[if uncut]About ten feet of sturdy rope[otherwise]The rope has been cut into two sections, each about five feet long[end if]."

Maybe you want your rope to behave differently - maybe you want one object to turn into two separate objects, or maybe you just want to destroy the rope entirely. But you have to know that before you can tell Inform what to do.