[I7] Giving orders to a device (Format is NAME, ORDER)

So, some time ago, I was writing a game. In the game, the player carried a handheld device (Called Omega), and the first task for the player: give an order to the computer.

For example:

omega, mail

Would open the New Mail folder (Of course, a fake).

omega, calendar

Would print the schedule.

I tried many things, and it didn’t work. The rules only applied to animals, men or women, and i tried to set omega as an animal, but there would be side effects (Mostly the interpreter prompting the reply you usually get when you try to operate an animal but find an error condition.).

Is there any way to do this?

I know it has been done before, in The Orion Agenda (dispenser, coffee//dispenser, water).


Several ways to accomplish what you’re looking for come to mind–for example, you could simulate a conversation with Omega by having several different commands that all redirect to a menu with options like 1. Ask Omega to check mail, 2. Ask Omega to check calender, etc.

Perhaps those more knowledgeable than myself can give you some much better help, but given the specifications for functionality that you discussed it seems that the easiest way to work out interacting with Omega involves nothing more than some selective punctuation removal. The following shows one way to implement what you described:

The Test Area is a room.  The description of the Test Area is "A featureless room, with walls made of bare concrete block, serves as your workshop.".

A supporter called the work bench is in the Test Area.  The description of the work bench is "A sturdy table made of thick planks of unvarnished wood serves as your makeshift desk.".

A container called the tool box is on the work bench.  The description of the tool box is "A large metal tool box, painted fire-engine red.  The tool box is [if open]open[otherwise]closed[end if].".  The tool box is closed and openable.

A device called Omega is on the work bench. Understand "pda" as omega.  The description of omega is "Your trusty handeheld pda.  The chrome-plated device is voice-activated, and no batteries are necessary since it has a built-in microfusion reactor.".  Omega has a number called mailbox.  Mailbox is usually 0.

After reading a command:
	let currentcommand be indexed text;
	let currentcommand be the player's command;
	replace the regular expression "omega," in currentcommand with "omega";
	replace the regular expression "pda," in currentcommand with "omega";
	change the text of the player's command to currentcommand.

Omegamailing is an action applying to one visible thing.  Understand "[something] mail" as omegamailing.

Check omegamailing:
	if omega is switched off:
		try switching on omega;
		if omega is not switched on:
			say "Your omega seems to be broken." instead.

To say currentmail for (reader - a thing):
	if reader is the player:
		if the mailbox of omega is 1:
			say "From: sally52@allies.com[line break]I got your message, and I'll meet you by the wharf tonight at ten.";
		if the mailbox of omega is 2:
			say "From george@intrigue.com[line break]I have some information you may find interesting.  Meet me at the Westside Cafe at noon tomorrow.";
			say "From fast-eddie@viagra.com[line break]We have special offer just 4 you!!  Please be responding at soon as possable to advantage on special offer!!!".

Report omegamailing:
	say "[currentmail for the player][line break]".

[Takes care of an odd response if omega is not visible, for example inside the closed tool box]

Rule for printing a parser error when parser error is not a verb I recognise:
	if the player's command includes "omega" or the player's command includes "pda":
		unless the player can see omega:
			say "You seem to have misplaced your omega device.".	

[If we ask an inamimate object other than omega for our mail, the default response seems appropriate: "You can't talk to the (whatever)."]

We can now pretend the player is talking to Omega, unless talking would be inappropriate–for example if we put Omega in the tool box and close the tool box. Of course you’d need to write some conditions to determine the current “mailbox” of the Omega. One small problem with the above code is that if the player types a long command such as “Put pencil, shotgun, omega, and necklace on work bench” they’ll receive a parser error since the comma after “omega” will be automatically removed; I myself don’t use commands of that type when playing a game, but there are probably many folks who do that would be frustrated at having to re-type such a long command for no apparent reason.

Hopefully the above will be helpful to you.

Well, instead of making Omega an animal, you could give it the “talkable” attribute, like so:
Include (- has talkable, -) when defining Omega.
That way you can give it orders, but it will be treated as a thing in all other respects, so no “That would be less than corteous” or “I don’t think Omega would care for that” messages.

Here’s an implementation:

[code]Include Default Messages by David Fisher.

A computer is a kind of device.
Include (- has talkable, -) when defining a computer.

Checking for mail is an action applying to nothing.
Understand “mail” as checking for mail.

Check an actor checking for mail:
unless the actor is a computer, stop the action.

Carry out a computer checking for mail:
say “‘You have no messages.’”

Displaying the calendar is an action applying to nothing.
Understand “calendar” as displaying the calendar.

Check an actor displaying the calendar:
unless the actor is a computer, stop the action.

Carry out a computer displaying the calendar:
say “‘No appointments today.’”;

Checking for mail is doing computer stuff. Displaying the calendar is doing computer stuff.
Persuasion rule for asking a computer to try doing computer stuff: persuasion succeeds.

Instead of doing computer stuff, say “That command is for computers only.”

Instead of a switched off computer (called comp) doing something:
say error message for the comp;
rule succeeds.

Asking a computer about something is computer conversation.
Telling a computer about something is computer conversation.
Asking a computer for something is computer conversation.
Instead of computer conversation, say “You can only do that to something animate.”
Instead of answering a computer that something, say error message for the noun.

To say error message for (comp - a computer):
if comp is switched on, say “‘Does not compute!’”;
otherwise say “[The comp] is currently switched off.”

Table of custom library messages (continued)
Message Id Message Text
LibMsg “[if the main object is a computer][error message for the main object][otherwise][The main object] has better things to do.[/p][end if]”

The Lab is a room. Omega is a computer in the Lab.

Test me with “take omega / omega, mail / turn on omega / omega, mail / omega, calendar / omega, sing / mail”.[/code]

Way cool example, SJ_43. I’ve grabbed it (with proper credit to you, of course, and to Eudoxia for posing the question) to include in the next version of the Inform 7 Handbook.

I’ve become quite shameless about scouting out tips and examples that I think people may find useful – I figure, having the material gathered together in one place is easier than having to scout through forums and the newsgroup for it.

–Jim Aikin

Thanks Jim!

I’ll just clarify something that may not be obvious to beginners: when an order to someone is not understood as a correct command, it’s turned into an “answering it that” action instead, which is why “answering a computer that something” is handled differently from “asking a computer about something” (and the other talking actions).

Edit: To make “say hello to omega” produce the correct response:

Understand "answer [text] to [computer]" as a mistake ("You can only do that to something animate.").

Oh, and the “check” rules may seem superfluous, but they are there to stop any NPCs from carrying out the computer commands.