How to add an object to the scope in Inform 7

I have no idea if I am using correct words here. I am a programmer but as I recently became very intrigued by Interactive Fiction, I decided to attempt to learn how to use Inform 7.

I am working on a very small game, mostly to be a test to make me learn more about how Inform 7 works.
What I want to do right now, is to have certain objects, that the player can only carry one of at a time.

(In the game, you are an ant; You can only carry one large object at a time).

Right now I have the following code:

a haulable object is a kind of thing.
instead of taking a haulable object, say "That is far too big to take with you. You might be able to haul it on your back, however.".


The players back is a supporter.
understand "haul [something]" or "carry [something] on back" or  "haul [something] on back" or "carry [something] on my back" or  "haul [something] on my back" or "put [something] on back" or "put [something] on my back" as hauling.
Hauling is an action applying to one thing.
instead of hauling the noun:
	if the noun is not a haulable object:
		say "[the noun] is big nor heavy, and does not need to be carried on your back.";
	else:
		if the players back encloses something:
			say "Your back is full.";
		else:
			say "Channeling all your strength, you put [the noun] on your back.";
			now the noun is on the players back;


to say the hauled item: say "[list of the things on the players back with definite articles]".
		
understand "stop hauling" as stop-hauling.
Stop-hauling is an action applying to nothing.
instead of stop-hauling:
	if the players back encloses nothing:
		say "You did not drop anything, as you were not hauling anything on your back.";
	else:
		say "You stop hauling [the hauled item] and drop it to the ground.";
		repeat with the item running through things on the players back:
			if the location is a tree-room:
				say "[the noun] starts plunging downward by the pull of gravity.";
				say "with a large *THUD*, it lands right next to the Northern Exit.";
				now the item is in the northern exit;
			else:
				now the item is in the location;

Now, I want to be able to do the following things:
-Add ‘stop hauling X’ to the possibilities of the stop-hauling action (where X is whatever you are currently carrying).
-Add ‘drop X’ as alias to stop-hauling as well. As ‘drop X’ usually scans through your inventory, how can I change its behaviour to check the players back as well?
-Change ‘put X in Y’ and ‘put X on Y’ to use whatever the player has on their back as possible candidates as well.

How can I make Inform understand these things?

Thank you for your help,

~Qqwy

The first two are pretty straightfoward. The third is more fiddly.

To add “stop hauling X” as a possibility, you need to define an action applying to one thing, and an understand line for “stop hauling [something]” that goes to that action. Then you just need to write a rule for it that mimics the stop-hauling action.

Once that’s done, making “drop X” an alias is easy–just use an Instead of dropping rule that redirects the action to the new stop-hauling action.

So we get this:

[code]a haulable object is a kind of thing.
instead of taking a haulable object, say “That is far too big to take with you. You might be able to haul it on your back, however.”.

The player’s back is a supporter. The player’s back is part of the player.
understand “haul [something]” or “carry [something] on back” or “haul [something] on back” or “carry [something] on my back” or “haul [something] on my back” or “put [something] on back” or “put [something] on my back” as hauling.
Hauling is an action applying to one thing.
instead of hauling the noun:
if the noun is not a haulable object:
say “[the noun] is big nor heavy, and does not need to be carried on your back.”;
else:
if the player’s back encloses something:
say “Your back is full.”;
else:
say “Channeling all your strength, you put [the noun] on your back.”;
now the noun is on the player’s back;

to say the hauled item: say “[list of the things on the player’s back with definite articles]”.

understand “stop hauling” as stop-hauling.
Stop-hauling is an action applying to nothing.
instead of stop-hauling:
if the player’s back encloses nothing:
say “You did not drop anything, as you were not hauling anything on your back.”;
else:
say “You stop hauling [the hauled item] and drop it to the ground.”;
repeat with the item running through things on the player’s back:
if the location is a tree-room:
say “[the noun] starts plunging downward by the pull of gravity.”;
say “with a large THUD, it lands right next to the Northern Exit.”;
now the item is in the northern exit;
else:
now the item is in the location;

Anthill is a room. The northern exit is north of anthill.

A tree-room is a kind of room.

The rock is a haulable object in anthill. The dung ball is in anthill. The nest is a container in the anthill.

Specific stop-hauling is an action applying to one thing.
Understand “stop hauling [something]” as specific stop-hauling.
instead of specific stop-hauling something (called the item):
if the player’s back does not enclose the item:
say “You aren’t hauling that.”;
else:
say “You stop hauling [the item] and drop it to the ground.”;
if the location is a tree-room:
say “[the item] starts plunging downward by the pull of gravity.”;
say “with a large THUD, it lands right next to the Northern Exit.”;
now the item is in the northern exit;
else:
now the item is in the location;

Instead of dropping something when the noun is on the player’s back: try specific stop-hauling the noun.[/code]

(I changed the spelling of the player’s back, and also made it part of the player, so it’ll move along with the player. As you have the players back defined, it starts out of play, so the stuff you haul actually disappears from sight!)

The second part is more fiddly… you have to tell Inform to ignore carrying requirements when the noun is on the player’s back, so it doesn’t try and fail “take rock” when the rock is on the player’s back–and you also have to tell the rules that prevent the player from putting stuff in/on other stuff that they shouldn’t interfere when the noun is on the player’s back. This looks like:

[code]The carrying requirements rule does nothing when the noun is not nothing and the noun is on the player’s back.

The can’t insert what’s not held rule does nothing when the noun is on the player’s back.

The can’t put what’s not held rule does nothing when the noun is on the player’s back.[/code]

(The first one includes “the noun is not nothing” because the carrying requirements rule runs for every action, including nounless actions like “looking,” and if there’s no noun then Inform will throw an error when it tries to evaluate “the noun is on the player’s back.” Checking “the noun is not nothing” first will prevent it from trying to evaluate “the noun is on the player’s back” when there’s no noun.)

Also as a courtesy to let “put rock on my back” be understood as hauling the rock, you might try this:

Instead of putting something on the player's back: try hauling the noun.

…Inform will automatically understand “back” as the player’s back because that’s part of its name, and it basically ignores “my,” so now “put rock on my back” will work.

Thank you very much for your reply! (sorry that I posted a snippet that was not fully complete, by the way).

Those three statements that modify the rules: is there a place in the documentation somewhere where a list of rules that affect a certain action (and what they do!) can be found? The Index tab does list actions and also the rules from which they are defined, but the inner workings of a rule are not shown there.

How to know what to rules overwrite, and in what way?

~Qqwy

A good way to do this in general is to start your game, type “rules,” and then try to perform your action. This will give a list of the rules that are running. Sometimes typing “actions” as well will help. The rules you haven’t written will generally be found in the Standard Rules–go to the Open Extension menu and find them under “Graham Nelson.”

The carrying requirements rules are a bit more complex, though… I just adapted some code from the Lollipop Guild example there (look at the list of examples in the documentation.)

There is also an extension - Bulky Items (I think) that does exactly what you want.