1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-05 16:44:21 +03:00
inform7/Documentation/Examples/ForDemonstrationPurposes.txt
2019-02-05 00:44:07 +00:00

52 lines
2.2 KiB
Plaintext

*** Relations involving values
(Character who learns new actions by watching the player; For Demonstration Purposes)
A character who learns new actions by watching the player performing them.
Suppose we want to have a character who can dynamically learn new actions by observing the player performing them. We could do this by adding the actions to a list of things the character can do, but using a relation to express the same idea allows for tidier, easier-to-read code.
Thanks to Jesse McGrew for the initial design of this example.
{*}"For Demonstration Purposes"
Section 1 - Procedure
Capability relates various people to various stored actions. The verb to be capable of means the capability relation.
Persuasion rule:
let CA be the current action with no specific actor;
if the person asked is capable of CA:
persuasion succeeds;
otherwise:
say "[The person asked] look[s] confused. Maybe a demonstration would help.";
persuasion fails.
The action requester is an object that varies. The action requester variable translates into I6 as "act_requester".
To decide which action is the current action with no specific actor:
let old actor be the person asked;
let old requester be the action requester;
now the person asked is the player;
now the action requester is nothing;
let CA be the current action;
now the person asked is the old actor;
now the action requester is the old requester;
decide on CA.
The learning by observation rule is listed after the report stage rule in the specific action-processing rules.
Definition: a person is other if he is not the player.
This is the learning by observation rule:
repeat with the viewer running through other people who can see the player:
if the player is the actor and viewer is not capable of the current action:
say "[The viewer] watches your behavior with interest. Seems like [they] [are] learning.";
now the viewer is capable of the current action.
Section 2 - Scenario
The Daily Planet is a room. Clark is here. He is a man.
When play begins:
now Clark is capable of taking inventory.
Test me with "Clark, inventory / Clark, x me / x me / Clark, x me".