Slouching
Example 396
★★Suppose we want to let the player explicitly sit, stand, or lie down on different enterable objects. (Normally Inform treats all these actions as entering, but there may be cases where we want to distinguish between the player sitting on a chair and the player standing on it.)
Our implementation gives each kind of enterable a range of allowed postures, and one preferred posture. If the player enters the supporter or container without specifying a posture (as in ENTER CHAIR), he will be put in the preferred posture. If he explicitly says, e.g., STAND ON CHAIR, he will be put in the standing position as long as standing is a posture that suits the chair.
"Slouching"
Section 1 - Posture Rules
A posture is a kind of value. The postures are seated, standing, and reclining.
A person has a posture. The posture of a person is usually standing.
A supporter has a posture. A container has a posture.
Posture-permission relates various things to various postures. The verb to allow means the posture-permission relation.
Understand the commands "stand" and "sit" and "lie" as something new.
Understand "sit on/in [something]" as sitting on.
Understand "lie on/in [something]" as lying on.
Understand "stand on/in [something]" as standing up on.
Sitting on is an action applying to one thing.
Lying on is an action applying to one thing.
Standing up on is an action applying to one thing.
Carry out an actor sitting on:
if the holder of the actor is not the noun, silently try the actor entering the noun;
if the holder of the actor is the noun:
if the actor is not seated, try the actor taking position seated;
otherwise follow the report taking position rules.
Carry out an actor lying on:
if the holder of the actor is not the noun, silently try the actor entering the noun;
if the holder of the actor is the noun:
if the actor is not reclining, try the actor taking position reclining;
otherwise follow the report taking position rules.
Carry out an actor standing up on:
if the holder of the actor is not the noun, silently try the actor entering the noun;
if the holder of the actor is the noun:
if the actor is not standing, try the actor taking position standing;
otherwise follow the report taking position rules.
Understand "lie down" as lying down.
Understand "sit down" or "sit" or "sit up" as sitting down.
Understand "stand" or "stand up" as standing up.
Lying down is an action applying to nothing.
Sitting down is an action applying to nothing.
Standing up is an action applying to nothing.
Taking position is an action applying to one posture.
Instead of an actor lying down:
try the actor taking position reclining; rule succeeds.
Instead of an actor sitting down:
try the actor taking position seated; rule succeeds.
Instead of an actor standing up:
try the actor taking position standing; rule succeeds.
Check an actor taking position:
if the holder of the actor is not a room and the holder of the actor does not allow the posture understood:
if the actor is the player:
say "You can't take that position [in-on the holder of the actor].";
otherwise if the actor is visible:
say "[The actor] can't take that position.";
stop the action.
Check an actor taking position:
if the posture understood is the posture of the actor:
if the actor is the player:
say "You are already [the posture understood].";
otherwise:
if the actor is visible, say "[The actor] is already [the posture understood].";
stop the action.
Carry out an actor taking position:
now the posture of the actor is the posture understood.
Report someone taking position (this is the position-report rule):
say "[The actor] is now [the posture of the actor][if the holder of the actor is not the location of the actor] [in-on the holder of the actor][end if]."
Report taking position:
say "You are now [the posture of the player][if the holder of the player is not the location] [in-on the holder of the player][end if]."
To say in-on (item - a thing):
if the item is a container, say "in [the item]";
otherwise say "on [the item]".
Carry out an actor exiting (this is the departure-posture rule):
let N be the holder of the actor;
if N is a container or N is a supporter,
now the posture of the actor is the posture of N;
otherwise now the posture of the actor is standing.
The departure-posture rule is listed after the standard exiting rule in the carry out exiting rulebook.
The departure-posture rule is listed after the standard getting off rule in the carry out getting off rulebook.
Carry out an actor entering something (this is the arrival-posture rule):
if the noun is a container or the noun is a supporter,
now the posture of the actor is the posture of the noun.
The arrival-posture rule is listed after the standard entering rule in the carry out entering rulebook.
Check an actor going somewhere:
if the actor is in a room and the actor is not standing:
say "([if the actor is not the player][the actor] [end if]first standing up)[command clarification break]";
silently try the actor taking position standing;
if the actor is not standing, stop the action.
Section 2 - Some Generic Kinds
A chair is a kind of supporter. A chair is always enterable. Every chair allows seated and standing. A chair is usually seated.
A sofa is a kind of supporter. A sofa is always enterable. Every sofa allows seated, standing and reclining. A sofa is usually seated.
A hammock is a kind of container. A hammock is always enterable. Every hammock allows seated and reclining. A hammock is usually reclining.
Section 3 - The Scenario
The Resort is a room.
The banana hammock is a hammock in the Resort. The stone bench is a sofa in the resort.
Clark is a man in the Resort. A persuasion rule: persuasion succeeds.
Rule for writing a paragraph about someone (called target):
say "[The target] is [posture] [if the holder of the target is the location]nearby[otherwise][in-on the holder of the target][end if]."
Rule for writing a paragraph about something which encloses an unmentioned person (called target):
carry out the writing a paragraph about activity with the target instead.
Test me with "sit on bench / stand on bench / get up / lie on hammock / sit up / g / clark, sit on bench / look / clark, lie down / g / look / clark, get up / look / clark, lie down / look / enter bench".
Test me with "sit on bench / stand on bench / get up / lie on hammock / sit up / g / clark, sit on bench / look / clark, lie down / g / look / clark, get up / look / clark, lie down / look / enter bench".
Resort
Clark is standing nearby.
You can also see a banana hammock (empty) and a stone bench here.
>(Testing.)
>[1] sit on bench
You are now seated on the stone bench.
>[2] stand on bench
You are now standing on the stone bench.
>[3] get up
You get off the stone bench.
Resort
Clark is standing nearby.
You can also see a banana hammock (empty) and a stone bench here.
>[4] lie on hammock
You are now reclining in the banana hammock.
>[5] sit up
You are now seated in the banana hammock.
>[6] g
You are already seated.
>[7] clark, sit on bench
Clark is now seated on the stone bench.
>[8] look
Resort (in the banana hammock)
Clark is seated on the stone bench.
>[9] clark, lie down
Clark is now reclining on the stone bench.
>[10] g
Clark is already reclining.
>[11] look
Resort (in the banana hammock)
Clark is reclining on the stone bench.
>[12] clark, get up
Clark gets off the stone bench.
>[13] look
Resort (in the banana hammock)
Clark is standing nearby.
You can also see a stone bench here.
>[14] clark, lie down
Clark is now reclining.
>[15] look
Resort (in the banana hammock)
Clark is reclining nearby.
You can also see a stone bench here.
>[16] enter bench
(getting out of the banana hammock)
You get onto the stone bench.
Clark is standing nearby.
You can also see a banana hammock (empty) and a stone bench here.
>(Testing.)
>[1] sit on bench
You are now seated on the stone bench.
>[2] stand on bench
You are now standing on the stone bench.
>[3] get up
You get off the stone bench.
Resort
Clark is standing nearby.
You can also see a banana hammock (empty) and a stone bench here.
>[4] lie on hammock
You are now reclining in the banana hammock.
>[5] sit up
You are now seated in the banana hammock.
>[6] g
You are already seated.
>[7] clark, sit on bench
Clark is now seated on the stone bench.
>[8] look
Resort (in the banana hammock)
Clark is seated on the stone bench.
>[9] clark, lie down
Clark is now reclining on the stone bench.
>[10] g
Clark is already reclining.
>[11] look
Resort (in the banana hammock)
Clark is reclining on the stone bench.
>[12] clark, get up
Clark gets off the stone bench.
>[13] look
Resort (in the banana hammock)
Clark is standing nearby.
You can also see a stone bench here.
>[14] clark, lie down
Clark is now reclining.
>[15] look
Resort (in the banana hammock)
Clark is reclining nearby.
You can also see a stone bench here.
>[16] enter bench
(getting out of the banana hammock)
You get onto the stone bench.