Actions: Noun vs Second Noun confusion

Hi friends, new here, been messing with Inform 7 for a few days and am about 3000 words into a basic story I’m doing to learn the ropes.

Unfortunately something seems to have broken with one of my puzzles. At one point, you need to use a knife on a tree’s bark to break it away. Here’s basically what I’ve got it doing:

After hitting the bark: 
	if the noun is the knife:
		say "That worked!";
		now the bark is nowhere;
	else:
		say "That won't work.";
		stop the action. 

I’ve defined hitting as applying to two touchable things, understanding “hit [something] with [something]” as hitting, I’ve got it understanding a few other appropriate verbs as “hitting” for the purposes of this, and obviously the flavour text in the game is a little more interesting.

Let’s say I then run it. Something like this happens:

Oh look, some bark.
> hit bark with knife
That won't work. 

I’m confused. I’m pretty sure at one point I had this exact code producing the desired result - like, if you hit it with the knife, you can break through, but if you hit it with anything else, you get a failure. But I’m getting a result every time that it just ignores the first “if” and leaps to “That won’t work” and stopping the action.

Can anyone help me understand what’s going on? I’ve tried a handful of different permutations of this (“Instead” and “before” instead of “after,” for example; also with continuing and stopping the action) and have a laundry list of other successful conditional things happening elsewhere in the story, so I’m confused as to why I can’t seem to get this (seemingly very simple thing) working as intended.

Thanks in advance!

The trick is, “the noun” is always the first noun used in the command. When you HIT BARK WITH KNIFE, “the noun” is the bark, not the knife.

You want “the second noun”. (Yes, the naming is weird. It’s a relic from very old versions of Inform that’s too ingrained to change now.)

1 Like

The second noun! That did it, thank you so much.

I’m thrilled that I don’t really need to learn code for this, per se, to write these but wow is Inform ever idiosyncratic.

1 Like

A minor note, but it’s best to define two-noun action names as verb phrases using the pronoun “it”. This keeps your rule definitions and code more readable, often allowing you to avoid needing to refer to “the noun” or “the second noun” entirely.

Hitting it with is an action applying to two things.

You can then use this name in rule definitions in the future, with “it” replaced with the noun, and the second noun at the end.

A thing can be sharp. A thing is usually not sharp. 

The player carries a knife. The knife is sharp.

Check hitting something with something:
	say "Pointless." instead.

Instead of hitting the bark with something not sharp:
	say "That won't work[one of][or]. You'll need to find something sharp[stopping]."

Instead of hitting the bark with something sharp:
	say "That worked!";
	now the bark is nowhere;
	rule succeeds.
4 Likes

Thanks for the tip - that does seem to simplify things a lot!

I must point that bark has usefulness. some species of trees’s bark contain resin, meaning that they are also a flame/heat (and light…) source if ignited. so, better put them in the location of the tree, even as red herring :wink:

Best regards from Italy,
dott. Piergiorgio.

1 Like

That’s a very clever idea! This is perhaps not that type of game, though. I’m very much trying to write something that’s quite accessible to people with no prior experience with IF, so I’m trying to avoid red herrings as much as possible. But I will be putting that idea in my back pocket for use in the future. :grin:

1 Like