New extension: Flexible Action Requirements

I think I will be submitting this extension to the inform7 site, so please have a good hard look at it and let me know what you think.

This came out of the discussion on making new actions with more flexible behavior than the original, in this thread:

https://intfiction.org/t/grammar-lines-in-wrong-order/3092/1

Thanks to Trojo and Matt W for their inspiration and encouragement!

You can download the extension here:

eyeballsun.org/i/Flexible%20Acti … ements.i7x

Or unspoiler it here:

[spoiler][code]Version 1 of Flexible Action Requirements by Mike Ciul begins here.

“Overrides carrying requirements for specific actions, and provides more nuanced carrying and touchability requirements when needed.”

Volume - Flexible Kinds of Action

Waiting is flexible about carrying the noun.
Waiting is flexible about carrying the second noun.
Waiting is flexible about touching the noun.
Waiting is flexible about touching the second noun.

Definition: An object is involved if the current action involves it.

Volume - Carrying Requirements

Part - Determining Carrying Requirements

Chapter - Only Available When Carried and Must Be Carried

Definition: an object (called item) is only available when carried:
Follow the custom carrying requirements for the item;
If the outcome of the rulebook is the it must be carried outcome, yes;
no.

To decide whether (item - a thing) must be carried:
If item is not involved, no;
Decide on whether or not item is only available when carried.

Chapter - Custom Carrying Requirements Rules

The custom carrying requirements is an object-based rulebook. The custom carrying requirements rules have outcomes it must be carried (failure) and it may be merely visible (success).

Custom carrying requirements for the noun (this is the basic carrying requirements for the noun rule):
If flexible about carrying the noun, make no decision;
If the action requires a carried noun, it must be carried.

Custom carrying requirements for the second noun (this is the basic carrying requirements for the second noun rule):
If flexible about carrying the second noun, make no decision;
If the action requires a carried second noun, it must be carried.

Part - Enforcing Carrying Requirements

Chapter - The Flexible Carrying Requirements Rule

Section - Definition

An action-processing rule (this is the flexible carrying requirements rule):
Repeat with item running through involved things:
If the item is only available when carried:
Carry out the implicitly taking activity with the item;
If the item is not carried, stop the action.

The flexible carrying requirements rule is listed instead of the carrying requirements rule in the action-processing rules.

Chapter - Implicit Taking

For implicitly taking something (called the item):
Do an implicit take with the item;

To do an implicit take with (O - an object):
(- ImplicitTake({O}); -)

Volume - Touchability Requirements

Part - Determining Touchability

Chapter - Only Available When Touchable and Must Be Touched

Definition: an object (called item) is only available when touchable:
Follow the custom touchability requirements for the item;
If the outcome of the rulebook is the it must be touchable outcome, yes;
no.

To decide whether (item - a thing) must be touched:
If item is not involved, no;
Decide on whether or not item is only available when touchable.

Chapter - Custom Touchability Requirements Rules

The custom touchability requirements is an object-based rulebook. The custom touchability requirements rules have outcomes it must be touchable (failure) and it may be merely visible (success).

Custom touchability requirements for the noun (this is the basic touchability requirements for the noun rule):
If flexible about touching the noun, make no decision;
If the action requires a touchable noun, it must be touchable.

Custom touchability requirements for the second noun (this is the basic touchability requirements for the second noun rule):
If flexible about touching the second noun, make no decision;
If the action requires a touchable second noun, it must be touchable.

Flexible Action Requirements ends here.

---- DOCUMENTATION ----

Section: Altering Action Requirements

Some actions in the Standard Rules are described as acting on “one carried thing.” If we want to waive those requirements, our only option is to create a new action that doesn’t have them. This extension removes that problem by making the carrying requirements more flexible.

In addition, we can now specify touchability requirements in the same level of detail as with carrying requirements. We can also use it to make fine-tuned tests in our own accessibility rules.

Section: Carrying Requirements

To waive the carrying requirements for an action, we can designate it as either of the “flexible about carrying the noun” or “flexible about carrying the second noun” kinds of action.

Eating is flexible about carrying the noun.
Unlocking something with the Force is flexible about carrying the second noun.

If that’s not fine enough detail, we can add rules to the “custom carrying requirements” rulebook, which is an object-based rulebook. The rulebook has two outcomes, “it must be carried,” and “it may be merely visible.” If the rulebook makes no decision, we assume there are no carrying requirements.

Custom carrying requirements for the speck of dust:
	if taking, make no decision;
	If the current action involves the speck of dust, it must be carried.

Custom carrying requirements for the Force:
	it may be merely visible.

To test the carrying requirements, we can use the “only available when carried” adjective.

Before doing something when the noun is only available when carried:
	if the noun is not carried:
		say "Sorry, you can't do that when you're not carrying [the noun].";
		stop the action;
	otherwise:
		say "(Good thing you're carrying [the noun] now)[command clarification break]"

All of the built-in custom carrying requirements rules test if the item is “involved,” i.e. it is the noun or the second noun. If you create custom carrying requirements rules that decide “it must be carried” for any other objects, you might get unexpected results when using the “only available when carried” adjective. If you must be absolutely sure that the item is both involved AND required for its role in the current action, you can use this to-decide-whether phrase:

if the golden plough must be carried:

Section: Touchability Requirements

Two similar kinds of action are defined so we can waive touchability requirements for objects: “flexible about touching the noun” and “flexible about touching the second noun.”

The adjective “only available when touchable” will tell us if an object is subject to touchability requirements of the current action. And we can make sure it is also involved in the current action using the to-decide-whether phrase “must be touched.”

To meddle with touchability requirements further, we may create “custom touchability requirements” rules. The outcomes are called “it must be touchable,” and again, “it may be merely visible.”

Unlike the carrying requirements modifications, though, there are no built-in changes to accessibility rules. Declaring that

listening is flexible about touching the noun

will not allow us to listen to things that are out of reach. We’d have to define our own rules, perhaps like this:

Reaching outside (this is the can always reach available when merely visible objects rule):
	unless an involved thing is only available when touchable, allow access;

The can always reach available when merely visible objects rule is listed before the can't reach outside closed containers rule in the reaching outside rules.

Even then, we would still need additional grammar lines or “try” statements to enable the player to perform actions on things that are not in scope.

The main value of the touchability requirements, then, is so we can designate some objects in scope as “too far away” or “too high up:”

Accessibility rule when the fans must be touched:
	say "The fans are too far away.";
	stop the action;

Section: Notes

Thanks to Trojo and Matt W for inspiring this extension. You may contact Mike Ciul at captainmikee@yahoo.com with bug reports and feedback.

Example: * “Mange Tout” - A blancmange that can’t be taken but can be eaten, and tennis fans who can’t be touched but can be heard.

*: "Mange Tout"

Include Flexible Action Requirements by Mike Ciul.

Wimbledon Stadium is a room. A giant blancmange is a fixed in place edible thing in Wimbledon Stadium.

The fans are a plural-named person in Wimbledon.

Accessibility rule when the fans must be touched:
	say "The fans are too far away.";
	stop the action;

Instead of listening to the fans when the blancmange is off-stage:
	say "A tremendous roar of jubilation washes over you.";
	end the story finally saying "You have won the match."

Instead of listening to the fans:
	say "The crowd is hushed with terror and anticipation.";

Eating is flexible about carrying the noun;
Listening is flexible about touching the noun;

Test me with "listen to fans/eat fans/take blancmange/eat blancmange/listen to fans"

[/code][/spoiler]

“Australia?”

“No, try again.”

“Australia!”

Python aside, this sounds very useful.

I’ve already found a problem. My example doesn’t involve anything that IS takeable, so I neglected to test for that in my new carrying requirements rule. And when I did test for that, I realized that the carrying requirements allow wearing as well as carrying. I think…

[code]There is a kilt in Wimbledon. The kilt is wearable.

Test me with “take kilt/wear kilt/drop kilt/wear kilt/remove kilt”[/code]

Here’s the update to the flexible carrying requirements rule:

An action-processing rule (this is the flexible carrying requirements rule): Repeat with item running through involved things that are not held by the person asked: If the item is only available when carried: Carry out the implicitly taking activity with the item; If the item is not carried, stop the action.
Does that look right now?

I’m not sure whether this answers your question (or causes more problems), but if you eat something that you’re wearing, the implicit action that it triggers is “taking it off” rather than “taking.” I think this means that you have to make some more changes to your implicitly taking activity, because as written the implicit take will yield “you already have that.” I think.

(Another point is that taking things off can break the player’s carrying capacity; that’s not really your problem but you might want to be aware of the coming bugfix.)

It seems there’s no problem there - confirming my impression that carrying requirements allow wearing, it’s handled by a check rule called “can’t eat clothing without removing it first.” Of course.

Err… that’s good to know. It has pretty serious effects on my WIP, which has carrying capacity issues.

You probably just have to write a “check taking off” rule that’s analogous to the can’t exceed carrying capacity rule (and one more for holdalls, if you have holdalls). There’s a similar issue with giving, which may or may not come up.

(Did you catch the subtle plug for my new game? Official rollout, such as it is, when I finish my comp reviews, probably.)

Yeah, it wasn’t too hard once I knew about it.

I think I’ve got giving taken care of - Giving is rolled into my Speech Motivations extension, and it’s translated into something more like “offering,” with the accepting part handled by an actual take.

Oh yes, I tried it out. Although with the spoilers, it didn’t take more that 5 minutes or so to get through! :smiley:

Did you find the Secret Implemented Action?

HONK HORN (or SQUEEZE HORN)

Yes, I did! I liked it.

It turns out there was a subtle problem with that loop, which has prompted me to unroll it:

An action-processing rule (this is the flexible carrying requirements rule): If the noun is not held by the person asked and the noun is only available when carried: Carry out the implicitly taking activity with the noun; If the noun is not carried, stop the action. If the second noun is not held by the person asked and the second noun is only available when carried: Carry out the implicitly taking activity with the second noun; If the second noun is not carried, stop the action.

The issue came up when I was trying to redirect a regular take - if the redirected take succeeds (silently), the original take does not result in the original object being held, so the implicit take stops the action with no further messages. I created a special “for implicitly taking” rule, but because the loop doesn’t check if the noun or second noun has changed, it still failed. But the unrolled version works correctly with something like this:

[code]A stand-in is a kind of thing. A stand-in has a thing called the real item.

For implicitly taking a stand-in (called the fake) when the real item of the fake is visible:
If the noun is the fake, now the noun is the real item of the fake;
If the second noun is the fake, now the second noun is the real item of the fake;
Carry out the implicitly taking activity with the real item of the fake;[/code]