Is it possible to make an object a device and supporter?

I would like to make an electronic chair both a device and a supporter so the player can enter the chair to sit on it and push buttons on arm of the chair. From memory an object can’t be both a device and a supporter so is there anyway to make this possible?

Create a supporter, then make a device. Declare that the device is ‘part of’ the suporter. This in effect sticks them together.

Yes and no.
In Inform 7 a thing cannot formally be of two distinct kinds (e.g. both a supporter and a device).
But you can easily make a supporter behave just like a device.

[code]The Workshop is a room.
The gadget is a supporter in the Workshop.

The gadget can be switched on or switched off.
The gadget is switched off.
Include (- has switchable, -) when defining the gadget.
[/code]The last three lines in the above code is all the functionality there is in a device.

The only thing that distinguishes the gadget above from a proper device, is that it isn’t called a device. So if you write rules or phrases that test for devices, the gadget won’t be recognized as one.
I.e. a rule like: Before doing something to a device: say "ding dong!" will fire for things that are declared to be devices, but it won’t fire for the device-like gadget.

I keep thinking about writing an extension that handles redirection to component parts of an object. But I’m not sure it’s possible to generalize. Has anyone else thought about this?

The problem is that while it’s easy to redirect an action on a particular noun to a different action, it’s difficult to redirect to a different noun for any arbitrary action. Most of the time I end up handling it with Before rules, but that’s kind of fragile, especially when there’s the possibility of multiple redirects. If you just change the noun or second noun without “trying” the new action over again, you can miss things because of rule order. But I’ve never quite gotten a handle on the syntax of “trying” a stored action or manipulating the “action-name part of the current action” variable in order to try it over again.

If rule order is a big problem, that seems like something you might be able to take care of with a new rulebook that runs before the Before rules:

[code]Command Center is a room.

The Pre-Before rules are an action based rulebook.
An action-processing rule (this is the run the pre-before rules rule): consider the Pre-Before rules.
The run the pre-before rules rule is listed before the before stage rule in the action-processing rulebook.

Pre-before switching on something when the noun is not a device and the noun incorporates a device:
if the noun incorporates two devices, continue the action;
change the noun to a random device incorporated by the noun.

Report examining something when the noun incorporates a device:
say “[The noun] comprises [a list of devices incorporated by the noun].”

A command chair is in Command Center. A yellow switch is a device. The yellow switch is part of the command chair. A blue switch is a device. The blue switch is part of the command chair.

The unnecessarily complicated machine is a device in Command Center. The submachine is a device. The submachine is part of the unnecessarily complicated machine.
After switching on the yellow switch: say “Vroom!”
After switching on the blue switch: say “Vreem!”
After switching on the unnecessarily complicated machine: say “Vraam!”
After switching on the submachine: say “Wakawakawaka!”

The nuclear football is in Command Center. The panic button is a device. The panic button is part of the nuclear football.

Before switching on the panic button:
say “Are you absolutely sure?”;
unless the player consents:
stop the action.

Carry out switching on the panic button: end the story saying “Boom”.

Test me with “switch on chair/switch on yellow/switch on machine/switch on submachine/switch on football”. [and then type yes][/code]

This should be easy enough to change to redirect any arbitrary action with “Pre-before doing something when the noun is the nuclear football” or summat, depending on how you want to do it. It might not handle multiple redirects gracefully, though.

Or if you just want to be able to change the stored action, it looks like Ron Newcomb’s Editable Stored Actions is the way to go. And so cool! I’d forgotten about it!

You should be able to use the existing setting action variables rules, just don’t tell anyone because they’re a secret!

Seems to me we’re just unrolling something that should be a loop. Isn’t that what the “try” phrase is for?

Probably. What troubles were you having with the try syntax?

I don’t remember. This actually works:

[code]Indirect incorporation relates a thing (called the part) to a thing (called the whole) when the component parts core of the part is the whole. The verb to be sub-part of implies the indirect incorporation relation.

Definition: A thing is supercomponent rather than subcomponent if it is the component parts core of it.

To decide whether (the function - an action-name) is processed by (the receiver - a thing):
no.

To decide whether (the function - the switching on action) is processed by (the receiver - a device): yes.

To decide whether (the function - the switching off action) is processed by (the receiver - a device): yes.

Before doing anything with a subcomponent thing:
if the action name part of the current action is processed by the noun, continue the action;
Now the noun is the component parts core of the noun;
instead try the current action;

Before doing anything with a supercomponent thing:
if the action name part of the current action is processed by the noun, continue the action;
Repeat with the part running through things that are sub-part of the noun:
if the action name part of the current action is processed by the part:
now the noun is the part;
instead try the current action;

Test is a room.

There is a container called an electrostatic washer in Test. The description is “To clean anything, put it inside and turn on the power switch.” A device called an power switch is part of the electrostatic washer. The description is “If you can read this, the machine is broken.”

Test me with “x washer/x switch/turn on switch/turn on washer”[/code]

But I don’t know if there would be issues farther down the line.

For an extension, I don’t think I would want to use this “is processed by” phrase. I considered this:

To decide which object is the handler for (the function - an action-name) of (the dispatcher - an object): decide on the dispatcher.

but better yet would be a rulebook. Not sure exactly whether it would be an action-based or object-based rulebook, and whether it would produce an object or a stored action, or just change the current action and set a flag, or…

Ooh, this is much more elegant! I think this is enough to write the whole extension now:

[code]Redirecting the nouns for is a rulebook. The redirecting the nouns for rules have outcomes don’t retry the action (failure) and retry the action (success).

Before doing something:
Follow the redirecting the nouns for rulebook;
If the rule succeeded:
instead try the current action;

Last redirecting the nouns for doing anything with a subcomponent thing:
Now the noun is the component parts core of the noun;
retry the action;

Redirecting the nouns for switching on or switching off:
if the noun is a device, don’t retry the action;
if exactly one device (called the part) is sub-part of the noun:
Now the noun is the part;
retry the action.[/code]