Old timey "Use with" Inform7 command syntax

How would you implement a conditional for, say, needing to use tongs to pick up a piece of radioactive material? I’ve looked through the index and there didn’t appear to be a “use with” command so is this an “if/otherwise” situation?

If the tongs are carried by player and they get isotope:
add isotope to inventory;
otherwise:
say “that’s too dangerous.”

What command are you hoping the player will use? “Pick up isotope with tongs”?

Getting it with is an action applying to two things.
Understand "take [things] with [something preferably held]" as getting it with.
Understand "pick up [things] with [something preferably held]" as getting it with.

Then you just need some basic rules for this new action. I’m making it redirect to normal “taking” for simplicity.

Check getting something with something when the second noun is not the tongs: say "[The second noun] isn't very well suited for that purpose." instead.
Carry out getting something with something: try taking the noun.

Now:

Instead of getting the isotope with the tongs:
    say "The tongs let you pick it up safely.";
    move the isotope to the player.

Instead of taking the isotope:
    if the player is holding the tongs:
        try getting the isotope with the tongs instead;
    otherwise:
        say "It's too dangerous to touch with your bare hands!" instead.

Note that all of this is only needed if you want to support the syntax “TAKE [X] WITH [Y]”, since that’s not built-in. You can also use a simple conditional if you don’t care about this syntax.

I like what you’ve done. That’s more the sort of setup I’m used to (but are people today?)

For completeness, what would a simple conditional be in this instance?

Should this be

Instead of taking the isotope:
    if the player is holding the tongs:
       say. "try getting the isotope with the tongs instead";
    otherwise:
        say "It's too dangerous to touch with your bare hands!" instead.

Nope; “try” literally makes Inform carry out that command as though the player had input it. So it “redirects” to the proper action.

A slightly better way might be:

Instead of taking the isotope:
    if the player is holding the tongs:
        say "(with the tongs)[command clarification break]";
        try getting the isotope with the tongs instead;
    otherwise [etc etc]

This makes it clear that the action is getting redirected. ("[command clarification break]" is one of those obscure things you don’t need very often; it’s conventionally used after a parenthetical saying that your command has been reinterpreted or edited in some way.)

If you want a simple conditional, without making a new action, you can use this in place of all that previous code:

Instead of taking the isotope when the player is not carrying the tongs:
    say "It's too dangerous to move with your bare hands." instead.

But this won’t understand TAKE ISOTOPE WITH TONGS (it’ll say “I only understood you as far as wanting to take the isotope”).

Is there a difference between getting and taking?

Maybe my verbiage is creating a problem. Here’s what I have in my game:

Instead of getting the pig carcass with the fresh banana palm leaves:
	say "Sliding the fresh leaves under the carcass is easier than you thought as the rotting flesh has broken down to the point where the fat is oozing out from tears in the skin.
Grasping the fresh, strong leaves you manage to lift the pig carcass off the ground with a minimum of rotten pig juice getting on you.";
	move the pig carcass to the player.

Instead of taking the carcass:
	if the player is holding the fresh banana palm leaves:
		try getting the pig carcass with the fresh banana palm leaves instead;
	otherwise:
		say "It’s too rotted and it disintegrates when you touch it. The old banana leaves are browned and soft and they tear as you try to get a grip on them." instead.


Instead of going north in the palm grove:
	if a random chance of 1 in 4 succeeds:
		say "As if to underscore the menace of the place as you turn to leave, a deafening crack splits the sky and the ground jerks first one way, and then another, accompanied by a huge plume of hot ash spewing from the top of the volcano. A moment later huge chunks of red-hot stone begin to rain down on the scoria field ahead.";
	otherwise:
		now the player is in the scoria field;

That looks reasonable to me; are you getting an error?

I’ve replied too many times with hzdgmg and it was rude to leave you hanging.

Problem. You wrote ‘Instead of getting the pig carcass with the fresh banana palm leaves’ , which seems to introduce a rule taking effect only if the action is ‘getting the pig carcass with the fresh banana palm leaves’. But that did not make sense as a description of an action. I am unable to place this rule into any rulebook.

Ah, that only works if you’ve defined the “getting it with” action (from my first post up above).

So should that be in a special section at the top of the whole document. As in-

[SPECIAL RULES]

Getting it with is an action applying to two things.
Understand "take [things] with [something preferably held]" as getting it with.
Understand "pick up [things] with [something preferably held]" as getting it with.
Check getting something with something when the second noun is not the tongs: say "[The second noun] isn't very well suited for that purpose." instead.
Carry out getting something with something: try taking the noun.

Is this quite a high level idea?

I don’t think it necessarily needs to be a special section at the top! Inform is usually pretty flexible about the order you put your source code in.

Anyway this isn’t a very high level idea, necessarily. What’s going on is that you’re defining a new action. “GET ISOTOPE” and “TAKE ISOTOPE” map to the taking action, which only applies to one thing. If you want “GET ISOTOPE WITH TONGS” you need to define a new action which applies to two things. That’s what you accomplish with the “Getting it with is an action applying to two things” line… then the Understand lines tell the parser what commands can map to your new action, and the Check and Carry out rules tell the game how to perform the action.

One thing that’s important to know is that the commands don’t match up perfectly with action names. An action always has one name you use to refer to it internally–so you always write rules for taking, even though you can use “take” or “get” or “pick up” or a bunch of other things. The Index tab under Actions will give you the internal action names, as well as the commands you can use to invoke the actions. And you can add new commands with new Understand lines.

So you’d suggest I place it near the text it relates to?

Wherever it works best for you to keep track of it! When I have to define an action that has to do with some specific things, I usually put the definition in a section with all the stuff it has to do with. This sounds like what you’re suggesting.

Like, I had something where I had a special action for wiping your shoes on something, so the action definition went in a section with the rules that applied to it and the properties that kept track of whether the shoes had been wiped.

If I had a new action that I was going to use constantly in my game, I would probably define it up near the beginning.

But whatever works for you is best–Inform is flexible here!

I’ve done it all like that and it doesn’t seem to be forcing me to use leaves to get the carcass. I have to have the leaves but just having them in my inventory and saying “get carcass” gets the carcass.

A pig carcass is in the palm grove. The description of a pig carcass is "The carcass is laid out on some large browned banana palm leaves surrounded by dead flowers. It is very rotted and the smell of rot, corruption coupled with clouds of flies creates a cloying miasma.";

Getting it with is an action applying to two things.
Understand "take [things] with [something preferably held]" as getting it with.
Understand "pick up [things] with [something preferably held]" as getting it with.

Check getting something with something when the second noun is not the fresh banana palm leaves: say "[The second noun] isn't very well suited for that purpose." instead.
Carry out getting something with something: try taking the noun.

Instead of getting the pig carcass with the fresh banana palm leaves:
	say "Sliding the fresh leaves under the carcass is easier than you thought as the rotting flesh has broken down to the point where the fat is oozing out from tears in the skin.
Grasping the fresh, strong leaves you manage to lift the pig carcass off the ground with a minimum of rotten pig juice getting on you.";
	move the pig carcass to the player.

Instead of taking the carcass:
	if the player is holding the fresh banana palm leaves:
		try getting the pig carcass with the fresh banana palm leaves instead;
	otherwise:
		say "It’s too rotted and begins to disintegrate when you touch it. The old banana leaves are browned and soft and they tear as you try to get a grip on them." instead.


Instead of going north in the palm grove:
	if a random chance of 1 in 4 succeeds:
		say "As if to underscore the menace of the place as you turn to leave, a deafening crack splits the sky and the ground jerks first one way, and then another, accompanied by a huge plume of hot ash spewing from the top of the volcano. A moment later huge chunks of red-hot stone begin to rain down on the scoria field ahead.";
	otherwise:
		now the player is in the scoria field;

Here’s what I see if I copy your code into a new project.

>get carcass
It’s too rotted and begins to disintegrate when you touch it. The old banana leaves are browned and soft and they tear as you try to get a grip on them.

>get leaves
Taken.

>get carcass
Sliding the fresh leaves under the carcass is easier than you thought as the rotting flesh has broken down to the point where the fat is oozing out from tears in the skin. Grasping the fresh, strong leaves you manage to lift the pig carcass off the ground with a minimum of rotten pig juice getting on you.

Is this not what you wanted?

No. The leaves are in a different location (maybe a problem there) but I wanted people to have to solve the puzzle like “use fresh banana palm leaves with pig carcass” or “use FBPL to get carcass”.

"Escape from Paradise" by Daniel

When play begins:
say "Intro text goes here";
	


[Variables]



[BEACH]
The Beach is a room. Beach is north of The Shallows. beach is west of Headland View. beach is east of The Smell of Death. "You are standing on a beach. The waves crash along the shoreline and the sand is warm between your toes.";

A small red crab is in The Beach. The description of A small red crab is "This is a tiny red crab. It eyes you uncertainly but doesn't try to escape.";

A small blue crab is in the beach. The description of a small blue crab is "This is a tiny blue crab. It scuttles away";

After examining small blue crab:
	move blue crab to the shallows;
	stop the action;
	
After going south from beach when the red crab is not carried by the player:
	 move the red crab to shallows;
	continue the action;


[SHALLOWS]
The Shallows is a room. "The water laps at your ankles as you gaze out at the remains of the GOSUB jet, and beyond, to the open ocean.  The water’s cool but not cold. This would be the perfect spot to go for a swim if only it weren’t for all those circling grey fins. It's a miracle you made it to shore.";

After examining small blue crab:
	move small blue crab to beach;
	stop the action;

After going north from beach when the red crab is not carried by the player:
	move the red crab to beach;
	continue the action;


[HEADLANDS]
Headland View is a room. headland view is north of Jump death. "After recovering from the climb you move to the edge of the headlands and gaze to the south taking in the beautiful view that spills out over the Atlantic Ocean. If it weren't for the mangled GOSUB jet rolling in the surf of the reef and the many gray fins circling hungrily at the base of the overhanging headlands you could imagine you were the only inhabitant of a primordial Earth.";

after dropping the pig carcass:
	say "Dripping with rotten pig juice you manage to wrestle the carcass over to the edge of the headlands and drop it into the water below. You see first one shark, and then another, and then the whole school swim over to it and begin tearing it apart.";
	stop the action;

Instead of going south in the headland for the first time:
	say "It's a long way down and there are sharks waiting at the bottom. It doesn't seem very safe.";
	stop the action;


[JUMP DEATH]
Jump death is a room. "Leaping from the headlands, you enjoy a couple of seconds of joyous freefall, followed by about 30 seconds of pain from the unexpected firmness of the water below which you soon forget as hundreds of razor sharp shark’s teeth bite into your flesh.";



[FRUIT GROVE]
The Fruit Grove is a room.  the fruit grove is north of the headland view. "The air here is thick with the hum of bees and the smell of flowers. Tiny monkeys swing through the branches of a multitude of different fruit trees before resting on branches to chatter at you."

Fruit trees are in the fruit grove. The description of fruit trees is "There are banana palms, mangoes, papayas and several other species that are completely foreign to you.";

After examining the fruit trees:
	move the fresh banana palm leaves to the fruit grove;
	move the mangoes to the fruit grove;
	move the papayas to the fruit grove;
	continue the action;



[THE SMELL OF DEATH]
The Smell of Death is a room. The Smell of Death is south of The Palm Grove. "Generally the island is picture postcard perfect, but not in this place. Standing in the long damp shadows of the looming volcano with sharks circling just off shore would be unsettling in itself. Combined with the heavy smell of death that hangs in the air here, the island feels malevolent, your presence a violation.";


[THE PALM GROVE]
The Palm Grove is a room. The Palm Grove is south of The Scoria Field. "The smell of rotting flesh is almost overwhelming here and the source of the noisome stench is immediately obvious. Lying at the centre of a ring of tall palms is a rotting pig carcass laid out on banana palm leaves surrounded by hundreds, perhaps thousands, of flies. There’s something vaguely ritualistic about the whole tableau. 

As you approach the carcass you realize the vegetation has been cleared to the North offering a perfectly framed view of the volcano which is smoking menacingly.";

A pig carcass is in the palm grove. The description of a pig carcass is "The carcass is laid out on some large browned banana palm leaves surrounded by dead flowers. It is very rotted and the smell of rot, corruption coupled with clouds of flies creates a cloying miasma.";

Getting it with is an action applying to two things.
Understand "take [things] with [something preferably held]" as getting it with.
Understand "pick up [things] with [something preferably held]" as getting it with.

Check getting something with something when the second noun is not the fresh banana palm leaves: say "[The second noun] isn't very well suited for that purpose." instead.
Carry out getting something with something: try taking the noun.

Instead of getting the pig carcass with the fresh banana palm leaves:
	say "Sliding the fresh leaves under the carcass is easier than you thought as the rotting flesh has broken down to the point where the fat is oozing out from tears in the skin.
Grasping the fresh, strong leaves you manage to lift the pig carcass off the ground with a minimum of rotten pig juice getting on you.";
	move the pig carcass to the player.

Instead of taking the carcass:
	if the player is holding the fresh banana palm leaves:
		try getting the pig carcass with the fresh banana palm leaves instead;
	otherwise:
		say "It’s too rotted and begins to disintegrate when you touch it. The old banana leaves are browned and soft and they tear as you try to get a grip on them." instead.


Instead of going north in the palm grove:
	if a random chance of 1 in 4 succeeds:
		say "As if to underscore the menace of the place as you turn to leave, a deafening crack splits the sky and the ground jerks first one way, and then another, accompanied by a huge plume of hot ash spewing from the top of the volcano. A moment later huge chunks of red-hot stone begin to rain down on the scoria field ahead.";
	otherwise:
		now the player is in the scoria field;
		

[THE SCORIA FIELD]
The Scoria Field is a room. "This is a scoria field."

[OFF STAGE ITEMS]
there are fresh banana palm leaves. The description of fresh banana palm leaves is "These massive banana palm leaves are thick, and sturdy.".
there are mangoes. The description of mangoes is "they are tasty.".
there are papayas. The description of papayas is "they are tasty.".

Totally unrelated to your question, but I’d never heard “banana palm” before now. Google turns up some hits, though. Is the name “banana palm” a regional thing?

The plants that bananas grow on are definitely not palms (I have both bananas and palms growing outside). If you’re talking about the same plant, you might want to get rid of “palm” there, unless “banana palm” is more familiar to your readers?

Oh, that’s an easy fix. Replace your “instead of taking…” rule with this:

Instead of taking the carcass:
    say "You can't take it with your bare hands, for whatever reason. You'll need to use something else."

Then maybe add some more syntaxes to help the players out:

Understand "use [something preferably held] to take [things]" as getting it with (with nouns reversed).
Understand "use [something preferably held] on [the carcass]" as getting it with (with nouns reversed).

I’ve made the second line specific to this object, so that it won’t catch all attempts to USE something. Alternately, remove that second line, and use this instead:

Using it on is an action applying to two things.
Understand "use [something preferably held] on [something]" as using it on.

Check using something on something: say "Please be more specific." instead.
Instead of using something on the carcass:
    say "(using [the noun] to lift [the carcass])[command clarification break]";
    try getting the carcass with the noun instead.

This creates a generic “use X on Y” verb that does nothing by default, but can be overridden with Instead rules that redirect to more useful actions.

So, like this…

Instead of taking the carcass:
	say "You can't take it with your bare hands, for whatever reason. You'll need to use something else."
	otherwise:
		say "It’s too rotted and begins to disintegrate when you touch it. The old banana leaves are browned and soft and they tear as you try to get a grip on them." instead.

Understand "use [something preferably held] to take [things]" as getting it with (with nouns reversed).
Understand "use [something preferably held] on [the carcass]" as getting it with (with nouns reversed).

Oh boy. It’s talking about it maybe being right but there being a tab problem. I’m fiddling at the moment.