version 3/080503 by Nate Cull
Example: ** Alchemy - A demo game showing use of these basic actions.
"Alchemy" by Nate Cull
[This is a demo game for Planner.]
The release number is 2.
The story creation year is 2006.
The story headline is "An Interactive Demonstration"
Include Planner by Nate Cull.
Include Basic Plans by Nate Cull.
The Laboratory is a room. The description of the Laboratory is "A chaos of glassware, dark sigils, spellcasting apparatus sprawled in disgusting confusion -- in other words, a perfectly normal research lab. A stone archway leads east and another south."
The Library is east of the Laboratory. The description of the Library is "The stony walls are racked with square miles of parchment volumes."
A curiously carved table is a supporter in the Library.
A rosewood bench is a supporter in the laboratory. "A rosewood bench, scarred and burned by years of incantations, fills half of the room."
An iron crucible is an open container on the rosewood bench. "Bob's crucible bubbles merrily on the bench."
A cupboard is a closed openable container in the laboratory. "A cupboard of great antiquity quietly blends into the corner shadows."
A plastic bag is a closed transparent portable openable container on the carved table.
A Chinese puzzle box is a locked lockable closed openable portable container in the plastic bag.
A pinch of ginger is a portable thing in the puzzle box.
A wicker basket is an open container in the cupboard.
An onion, a tomato, a stick of celery, a lemon and a banana are in the wicker basket.
Broth is a thing.
Procedural rule when the desired relation is being-in and the desired param1 is broth and the desired param2 is the crucible:
ignore the basic putting things in containers rule;
Planning when the desired relation is being-in and the desired param1 is broth and the desired param2 is the crucible:
suggest being-in with the onion and the crucible;
suggest being-in with the celery and the crucible;
suggest being-in with the banana and the crucible;
suggest being-in with the ginger and the crucible;
To decide whether soup is brewing:
if the onion is not in the crucible, decide no;
if the celery is not in the crucible, decide no;
if the banana is not in the crucible, decide no;
if the ginger is not in the crucible, decide no;
Every turn when soup is brewing:
if the crucible is visible, say "The crucible simmers; the contents meld into a rich pungent vegetable broth.";
repeat with item running through things in the crucible begin;
remove item from play;
now broth is in the crucible;
The Alcove is a room.
The Alcove is south of the Laboratory. The description of the Alcove is "A tiny niche carved out of the stone, which opens out to the north."
A brass hook is a supporter in the Alcove. "Screwed into the stonework with grim determination is a shiny brass hook." The brass hook has carrying capacity 1.
A silver key is on the brass hook. The matching key of the Chinese puzzle box is the silver key.
Bob is a person in the laboratory. "The mighty wizard Bob potters around his domain."
The description of Bob is "Bob is carrying [if bob carries anything][list of things carried by bob][otherwise]nothing[end if]."
Procedural rule when the desired relation is being-in and the desired param1 is a person:
ignore the basic dropping objects in rooms rule;
have Bob plan an action for being-in with broth and the crucible;
Rule for deciding the concealed possessions of Bob:
Section - Custom Actions
[Asking a person for an object is an alternative plan for getting hold of an object. It's the sort of strategy that would only be appropriate in some genres, so it's not in Basic Plans.]
Doing-asking-for is a planning-action.
Planning-acting when the planned action is doing-asking-for:
try the planning actor trying asking the planned param1 for the planned param2;
Planning rule when the desired relation is being-touchable-by and the desired param2 is the planning actor and a person (called the owner) encloses the desired param1:
suggest being-touchable-by with the owner and the planning actor;
suggest doing-asking-for with the owner and the desired param1;
Procedural rule when the second noun is Bob:
ignore the block giving rule;
Section - Custom Messages
[The 'action success flag' trick we use is a bit of a nasty hack. There is probably a better way to find out if an action succeeds, but I don't know it yet. For the moment we use this, but it only gets set if an 'after' rule runs, which means if we use 'instead' to block the action, we need to set it manually. We should probably have a phrase for this, but it's so ugly there's likely to be a more permanent solution anyway.]
Instead of Bob trying asking the player for something:
say "'I say, old chap,' mutters Bob. 'Do be a sport and give me [the second noun].'";
change the action success flag to 1;
say "Bob scratches his beard and looks perplexed.";
end the game saying "You have witnessed the Making of Soup";
say "'Arr, that didn't work,' says Bob. 'Reality be getting a mite thin.'";
Report Bob trying opening the cupboard for the first time:
say "'Aslan sesameslan!' says Bob, flinging the cupboard doors wide open to reveal [list of things in the cupboard].";
stop the action;
[Another nasty hack just to get a nice message when Bob takes something from a container rather than from the room. Must be a better way to do this.]
The previous take holder is an object that varies.
Before Bob trying taking something:
change the previous take holder to the holder of the noun;
Report Bob trying taking something:
if the previous take holder is not a room begin;
say "Bob takes [the noun] from [the previous take holder].";
stop the action;