Why does Empty Transfer use Locksmith?

I just added Empty Transfer by Emily Short to my WIP, and it stopped compiling. I tracked it down to my use of the word “keychain,” which is a kind defined in Locksmith. I didn’t really want Locksmith. How important is it to Empty Transfer? Would it be possible to rewrite Empty Transfer with sections for use with/without Locksmith?

I would be happy to do that if so, either as an “editor” for Emily or republishing it under my own name.

Copy-paste Empty Transfer into your code without the invocation of Locksmith, and check where it fails to compile. That will show you where it invokes Locksmith, and you can then determine how to fix it. :slight_smile:

As far as I can tell Empty Transfer only depends on the use option defined in Locksmith—the sequential action option, that, if I remember correctly, makes the game report two actions in sequence rather than the first one as an implicit action in brackets.

Yeah, it is down to an attempt to offer compatible handling of implicit actions, but hasn’t been updated since Inform got the ability to include things conditionally depending on what other extensions are around.

I’ll try to remember to get to this, but I will not be offended if someone else wants to offer an edit: what needs to happen is for the Locksmith inclusion to be replaced with a code section that honors the sequential action option and is compiled only if Locksmith is also included.

Okay, then, here’s my offer:

“Version 5 of Empty Transfer”

[spoiler][code]Version 5 of Empty Transfer by Emily Short begins here.

“Adds actions for emptying containers.”

Volume - General Requirements

Chapter - Holding Requirements (for use without Locksmith by Emily Short)

Section - Autotaking Rules

This is the noun autotaking rule:
if the player is the person asked:
say “(first taking [the noun])”;
silently try taking the noun;
otherwise:
try the person asked trying taking the noun.

This is the second noun autotaking rule:
if the player is the person asked:
say “(first taking [the second noun])”;
silently try taking the second noun;
otherwise:
try the person asked trying taking the second noun.

Section - Must Hold Nouns Rules

This is the must hold the noun rule:
if the person asked does not have the noun, follow the noun autotaking rule;
if the person asked does not have the noun, stop the action;
make no decision.

This is the must hold the second noun rule:
if the person asked does not have the second noun, follow the second noun autotaking rule;
if the person asked does not have the second noun, stop the action;
make no decision.

Chapter - Opening Requirements

Section - Nouns Must Be Open Rules

This is the noun must be open rule:
if the noun is closed:
follow the noun autoopening rule;
if the noun is closed:
stop the action;
make no decision.

This is the second noun must be open rule:
if the second noun is closed:
follow the second noun autoopening rule;
if the second noun is closed:
stop the action;
make no decision.

Section - Autoopening (for use with Locksmith by Emily Short)

This is the noun autoopening rule:
if the sequential action option is active:
if the player is the person asked:
try opening the noun;
otherwise:
try the person asked trying opening the noun;
otherwise:
if the player is the person asked:
say “(first opening [the noun])[command clarification break]”;
silently try opening the noun;
otherwise:
try the person asked trying opening the noun;

This is the second noun autoopening rule:
if the sequential action option is active:
if the player is the person asked:
try opening the second noun;
otherwise:
try the person asked trying opening the second noun;
otherwise:
if the player is the person asked:
say “(first opening [the second noun])[line break]”;
silently try opening the second noun;
otherwise:
try the person asked trying opening the second noun.

Section - Autoopening (for use without Locksmith by Emily Short)

This is the noun autoopening rule:
if the player is the person asked:
say “(first opening [the noun])[command clarification break]”;
silently try opening the noun;
otherwise:
try the person asked trying opening the noun;

This is the second noun autoopening rule:
if the player is the person asked:
say “(first opening [the second noun])[line break]”;
silently try opening the second noun;
otherwise:
try the person asked trying opening the second noun.

Volume - Emptying

Section - Emptying Grammar

Understand “empty [container]” as emptying. Understand “empty [something]” as emptying.

Section - The Emptying Action

Emptying is an action applying to one thing.

Section - Check Emptying

Check an actor emptying something (this is the can’t empty what’s not a container rule):
if the noun is not a container:
if the player is the person asked:
say “You can’t empty [a noun].”;
stop the action.

Check an actor emptying (this is the can’t empty what’s closed rule):
abide by the noun must be open rule.

Check an actor emptying (this is the can’t empty what’s empty rule):
if the noun does not contain something:
if the player is the person asked:
say “There is nothing in [the noun].”;
stop the action;

Section - Carry Out Emptying

Carry out an actor emptying (this is the move emptied items rule):
now every thing is unmarked for listing;
repeat with item running through things in the noun:
if the person asked is the player:
silently try taking the item;
otherwise:
silently try the person asked trying taking the item;
if the person asked carries the item:
if the person asked is the player:
silently try dropping the item;
otherwise:
silently try the person asked trying dropping the item;
if the person asked does not carry the item:
now the item is marked for listing;

Section - Report Emptying

Report an actor emptying (this is the standard empty report rule):
if the number of marked for listing things is 0:
say “Nothing comes out of [the noun].” instead;
if the player is the person asked:
say "You empty ";
otherwise:
say "[The person asked] empties ";
say “[the list of marked for listing things] from [the noun].”;
now every thing is unmarked for listing.

Volume - Transferring it Into

Section - Transferring Grammar

Understand “empty [container] into/in [container]” as transferring it into. Understand “empty [something] into/in [something]” as transferring it into. Understand the command “dump” as “empty”.

Section - The Transferring it Into Action

Transferring it into is an action applying to two things.

Section - Check Transferring Something Into Something

Check an actor transferring something into something (this is the can’t transfer what’s not a container rule):
abide by the can’t empty what’s not a container rule.

Check an actor transferring something into something (this is the can’t transfer from closed containers rule):
abide by the noun must be open rule.

Check an actor transferring something into something (this is the can’t transfer from empty containers rule):
abide by the can’t empty what’s empty rule.

Check an actor transferring something into something (this is the can’t transfer into what’s not a container rule):
if the second noun is not a container:
if the player is the person asked:
say “[The second noun] cannot contain things.”;
stop the action.

Check an actor transferring something into something (this is the can’t transfer to closed containers rule):
abide by the second noun must be open rule.

Check an actor transferring something into something (this is the can’t transfer something within itself rule):
if the noun encloses the second noun:
abide by the must hold the second noun rule.

Section - Carry Out Transferring Something Into Something

Carry out an actor transferring something into something (this is the move transferred items rule):
now every thing is unmarked for listing;
repeat with item running through things in the noun:
if the player is the person asked:
silently try taking the item;
otherwise:
silently try the person asked trying taking the item;
if the person asked carries the item:
if the person asked is the player:
try silently inserting the item into the second noun;
otherwise:
silently try the person asked trying inserting the item into the second noun;
if the item is in the second noun:
now the item is marked for listing.

Section - Report Transferring Something Into Something

Report an actor transferring something into something (this is the standard transfer report rule):
if the number of marked for listing things is 0:
say “Nothing comes out of [the noun].” instead;
if the player is the person asked:
say "You empty ";
otherwise:
say "[The person asked] empties ";
say "[the list of marked for listing things] from [the noun] “;
if the second noun is a container:
say “into”;
otherwise:
say “onto”;
say " [the second noun][if something is in the noun]. [The list of things in the noun] remain[s] in [the noun][end if].”;
now every thing is unmarked for listing.

Volume - Dumping it Onto

Section - Dumping Grammar

Understand “empty [container] on/onto [supporter]” as dumping it onto. Understand “empty [something] on/onto [something]” as dumping it onto.

Section - The Dumping it Onto Action

Dumping it onto is an action applying to two things.

Section - Check Dumping Something Onto Something

Check an actor dumping something onto something (this is the can’t dump from unheld containers rule):
abide by the must hold the noun rule.

Check an actor dumping something onto something (this is the can’t dump from non containers rule):
abide by the can’t empty what’s not a container rule.

Check an actor dumping something onto something (this is the can’t dump from closed containers rule):
abide by the noun must be open rule.

Check an actor dumping something onto something (this is the can’t dump empty containers rule):
abide by the can’t empty what’s empty rule.

Check an actor dumping something onto something (this is the can’t dump onto what’s not a supporter rule):
if the second noun is not a supporter:
if the player is the person asked, say “[The second noun] cannot support things.”;
stop the action;

Check an actor dumping something onto something (this is the can’t dump onto itself rule):
abide by the can’t transfer something within itself rule.

Section - Carry Out Dumping Something Onto Something

Carry out an actor dumping something onto something (this is the move dumped items rule):
now every thing is unmarked for listing;
repeat with item running through things in the noun:
if the player is the person asked:
silently try taking the item;
otherwise:
silently try the person asked trying taking the item;
if the person asked carries the item:
if the person asked is the player:
try silently putting the item on the second noun;
otherwise:
silently try the person asked trying putting the item on the second noun;
if the item is on the second noun:
now the item is marked for listing.

Section - Report Dumping Something Onto Something

Report an actor dumping something onto something (this is the standard report dumping rule):
follow the standard transfer report rule.

Empty Transfer ends here.

---- Documentation ----

This extension adds three actions: emptying something (for emptying a container onto the floor); transferring something into something (for moving the contents of a container into another container); and dumping something onto something (for moving the contents of a container onto a table). All three actions are implemented for non-player characters as well as for the player.

If an object in a container should not be movable, it is enough to supply an “instead of taking” rule (and another “instead of someone trying taking…” rule, if other characters than the player are going to interact with the object). These insteads will be honored in the process of emptying. (A note of warning: because of the way messages are printed, the results may be infelicitous if we rely on making the contained object “fixed in place” rather than writing an instead of taking rule. In that case, Inform may print “That’s fixed in place.” at a point in the action where it is unclear what “That” refers to.)

Example: * Sorting - A test case with boxes and enclosed items.

*: "Sorting"

Include Empty Transfer by Emily Short.	

 Start Room is a room. 

The grey box, the silver box, the blue box, and the white box are openable open containers in the Start Room. The grey box contains an apple, an orange, a chocolate, and a mint. The white box contains a napkin. The blue box contains an anchovy and a key. The silver box contains a sense of wonder.

The pedestal is a supporter in the Start Room.

Clark is a man in the Start room. A persuasion rule: persuasion succeeds.

Instead of taking the mint: say "The mint has melted in place." Instead of someone trying taking the mint: say "[The person asked] tries to pry the mint from place, but it is melted there."

Instead of taking something which is in the silver box: say "You can't reach into the silver box." Instead of someone trying taking something which is in the silver box: say "[The person asked] cannot fit a hand into the silver box."

Test empty with "empty grey / put all in grey / close grey / empty grey / empty apple / empty silver box".

Test transfer with "empty grey into white / dump white into grey / put white in grey / empty grey into white / get all / put all in white / get grey / empty white into grey / dump grey into blue / dump blue onto pedestal".

Test Clark1 with "get grey / drop grey / put all but grey in grey / close grey / clark, empty grey / clark, get orange and apple / clark, put orange and apple in grey / clark, empty silver box/ clark, drop grey / get grey / put all in grey / clark, empty grey".

Test Clark2 with "clark, empty grey into white / clark, get white / clark, put orange into white / clark, empty white onto pedestal / clark, empty silver box".[/code][/spoiler]

I’d be happy to send it as a file if that’s preferred.

It turns out that in addition to the sequential actions option, Empty Transfer also makes use of Locksmith’s autotaking rules, which I duplicated for use without Locksmith.

Now this is the sort of situation where my mind wanders. First of all, I imagine lots of tiny little extensions that work well together. An “autotake” extension could combine all the shared functionality of both extensions and they could both include it.

As my mind wanders further, I think, why not make all shared check rules truly shared? Most of the time the only thing that differs is the failure message. So maybe an “unsuccessful attempt by the player” extension that regroups all the check rules in the Standard Library to avoid duplication, printing out the appropriate message for each combination of actor, action, and reason the action failed. Now here is where I get really happy. Ron Newcomb already wrote an extension that does most of that, in an amazingly brief amount of code! Now all I’d have to do is rewrite all the check rules and library messages!

So, does this look useful?

“Autotaking”

[spoiler][code]Autotaking by Mike Ciul begins here.

“Implicit taking of noun or second noun that may be invoked by (or used as) a check rule.”

Section - Sequential Action Option

Use sequential action translates as (- Constant SEQUENTIAL_ACTION; -).

Section - Autotaking Nouns Rules

This is the noun autotaking rule:
if sequential action option is active:
if the player is the person asked:
try taking the noun;
otherwise:
try the person asked trying taking the noun;
otherwise:
if the player is the person asked:
say “(first taking [the noun])”;
silently try taking the noun;
otherwise:
try the person asked trying taking the noun.

This is the second noun autotaking rule:
if sequential action option is active:
if the player is the person asked:
try taking the second noun;
otherwise:
try the person asked trying taking the second noun;
otherwise:
if the player is the person asked:
say “(first taking [the second noun])”;
silently try taking the second noun;
otherwise:
try the person asked trying taking the second noun.

Section - Must Hold Nouns Rules

This is the must hold the noun rule:
if the person asked does not have the noun, follow the noun autotaking rule;
if the person asked does not have the noun, stop the action;
make no decision.

This is the must hold the second noun rule:
if the person asked does not have the second noun, follow the second noun autotaking rule;
if the person asked does not have the second noun, stop the action;
make no decision.

Autotaking ends here.

---- DOCUMENTATION ----

Derived from (and largely copied and pasted from) Emily Short’s extension “Locksmith,” Autotaking provides a convenient way for any action to ensure that the noun or the second noun is held before being carried out. It also provides for the “sequential action” output style to be used instead of the default “(first taking the noun)” message.

Whenever we create an action that involves a noun or second noun that must be held, we can invoke the “must hold the noun” rule or the “must hold the second noun” rule:

Attacking it with is an action applying to two things.

The must hold the second noun rule is listed first in the check attacking it with rulebook.

This will generate an automatic take if the actor doesn’t have the second noun, and the action will be stopped if the autotake fails.

We can also invoke the “noun autotaking” and “second noun autotaking” rules explicitly:

Check an actor attacking something with something (this is the weapons must be held rule):
	if the actor does not hold the second noun, follow the second noun autotaking rule;
	if the actor does not hold the second noun, stop the action.

By default, automatic taking actions are described as other automatic actions usually are in Inform: the player sees something like “(first taking…)” before he takes an object used in an action. The “Use sequential action” mode is provided for the case where we would prefer to see “Taken.” instead.

Example: * Butterfingers - Making sure the “attacking it with” action always uses a held weapon.

*: "Butterfingers"

Include Autotaking by Mike Ciul.

Attacking it with is an action applying to two things.

Understand "attack [something] with [something]" as attacking it with.

The must hold the second noun rule is listed first in the check attacking it with rulebook.

Check attacking something with something:
	If the noun is not a person:
		say "You do very little damage to [the noun].";
		stop the action.

Check attacking the player with something:
	say "You wound yourself slightly, but the pain causes you to stop.";
	stop the action.

Carry out attacking something with something:
	Now the second noun is in the location.

Report attacking something with something:
	say "With a mighty yell, you swing [the second noun] at [the noun]. Unfortunately, it slips from your sweaty fingers and falls to the ground."

Arena is a room.

The gladiator is a man in Arena.

There is a sword in Arena. There is a big rock in Arena.

Instead of taking the big rock, say "You strain to lift the rock, but it's too heavy for you."

test me with "i/attack rock with sword/i/attack me with sword/attack gladiator with sword/g/attack gladiator with rock"[/code][/spoiler]

I haven’t had a chance to test it yet… but yes, looks very useful.

I look forward to seeing it in the extension catalog.

My guess is the player gets his butt kicked by the gladiator in the example. :wink:

What about the commands that already result in implicit takings by default? I think it would be nice if this extension made the sequential action options work for them, too, without the author having to add the must hold rules to their check rulebooks.

Perhaps some less naïve version of

Rule for implicitly taking the noun: follow the must hold the noun rule. Rule for implicitly taking the second noun: follow the must hold the second noun rule.
might be made to work.