There are a few things I’ve been having trouble with for a long time, and as I am currently working on something that involves both of these issues it seemed like a good time to ask for some help on the problems.
I was working on some code for containers or supporters intended to simulate an “empty space” underneath these objects if such is desired. There is a fine extension on the Inform website, “Underside” by Eric Eve, that does this already; however since for various reasons I’m not interested in using that extension, I decided to make my own. I’m mostly finished and happy with the way the code below works:
Chapter 1 - Support Code
[not directly relevant to the matter at hand, but needed for the sample code to work as intended]
Include Plurality by Emily Short.
Rule for deciding whether all includes scenery: it does not.
Rule for deciding whether all includes something fixed in place: it does not.
Use full-length room descriptions.
Rule for printing room description details: stop.
Bulk is a kind of value. The bulks are microsize, smallsize, cupsize, gallonsize, bagsize, suitcasesize, bathtubsize, bedsize, closetsize, shedsize, roomsize, and megasize.
A thing has a bulk. A thing is usually smallsize. A person is usually bathtubsize.
Before an actor inserting something into something (this is the sizecheck for inserting rule):
if the actor is the player:
if the bulk of the noun is greater than the bulk of the second noun:
say "[The noun] [is-are] too big to fit into [the second noun]." instead;
otherwise:
if the player can see the actor:
if the bulk of the noun is greater than the bulk of the second noun:
say "[The actor] looks at [the noun], looks at [the second noun], and shakes [if the actor is male]his[otherwise if the actor is female]her[otherwise]its[end if] head." instead;
otherwise:
if the bulk of the noun is greater than the bulk of the second noun:
stop the action.
Before an actor entering a container (this is the sizecheck for entering rule):
if the actor is the player:
if the bulk of the player is greater than the bulk of the noun:
say "You can't fit into [the noun]." instead;
otherwise:
if the player can see the actor:
if the bulk of the actor is greater than the bulk of the noun:
say "[The actor] looks at [the noun] and shakes [if the actor is male]his[otherwise if the actor is female]her[otherwise]its[end if] head." instead;
otherwise:
if the bulk of the actor is greater than the bulk of the noun:
stop the action.
A container is usually openable. A container is usually closed.
Rule for printing room description details of a container (called UE) (this is the intermediate casual container looking rule):
if UE is open or UE is transparent:
unless UE contains a person:
omit contents in listing;
otherwise:
let heldones be a list of things;
repeat with sittas running through things in UE:
if sittas is a person:
add sittas to heldones;
say " (in which [is-are] [heldones])";
omit contents in listing;
otherwise:
continue the activity.
Report examining a container which contains something (this is the after xing a container rule):
if the noun is open or the noun is transparent:
say "In [the noun] [is-are] [list of things in the noun with indefinite articles].".
Rule for printing room description details of a supporter (called UQ) (this is the better supporter looking rule):
if UQ does not support a person:
omit contents in listing;
otherwise:
let loungers be a list of things;
repeat with T running through things on UQ:
if T is a person and the player can see T:
add T to loungers;
say " (on which [is-are] [loungers])";
omit contents in listing.
Chapter 2 - Undersides
[This code is what was intended to be discussed in this thread]
Section 1 - What they are
An underside is a kind of container. An underside is usually open and not openable. The printed name of an underside is usually "[the holder of the item described]". The bulk of an underside is usually bathtubsize. An underside is usually scenery. An underside is usually privately-named. An underside is usually enterable.
The specification of an underside is "A conceptual representation of the spatial area underneath a thing.".
Section 2 - Miscellaneous Rules for Undersides
Report examining a supporter (called xedsup) which supports something (this is the after xing a supporter rule):
unless the player is in an underside incorporated by xedsup:
say "On [the noun] [is-are] [list of things on the noun with indefinite articles].".
Check looking under something:
unless the noun incorporates an underside:
say "You don't find anything of interest under [the noun]." instead;
otherwise:
let redir be a random underside incorporated by the noun;
try searching redir instead.
Rule for deciding whether all includes something in an underside: it does not.
Instead of an actor examining an underside:
try the actor searching the noun.
Procedural rule for an actor searching an underside: ignore the standard search containers rule.
Report searching an underside (this is the after xing an underside rule):
if the noun is open:
if the noun contains anything:
say "Under [the holder of the noun] [is-are] [list of things in the noun with indefinite articles].";
otherwise:
say "You don't find anything unusual under [the holder of the noun].";
otherwise:
say "You don't find anything unusual under [the holder of the noun]."..
Check an actor taking an underside:
if the actor is the player:
say "You can't take a 'space.'" instead;
otherwise:
if the player can see the actor:
say "[The actor] ignores your nonsensical request." instead;
otherwise:
stop the action.
Report an actor searching something that incorporates an underside (this is the thorough search of things with undersides rule):
try the actor searching a random underside that is incorporated by the noun.
Carry out taking something that incorporates an underside (called curunder) (this is the addon taking something with an underside rule):
if curunder is open and curunder contains anything:
let undalist be a list of things;
repeat with revealedstuff running through things in curunder:
add revealedstuff to undalist;
move revealedstuff to the holder of the noun;
say "As you take [the noun], you reveal [undalist with indefinite articles] that [if the number of entries in undalist is 1]was[otherwise]were[end if] underneath it.".
After looking while the holder of the player is an underside (called curunder) (this is the thorough looking from an underside rule):
try searching curunder;
continue the action.
Section 3 - Putting into and Taking from Undersides
Putting it under is an action applying to two things and requiring light. Understand "put [something] under/underneath/beneath [something]" as putting it under. Understand "drop [something] under/beneath/underneath [something]" as putting it under. Understand "place [something] under/underneath/beneath [something]" as putting it under. Understand "move [something] under/underneath/beneath [something]" as putting it under. Understand "hide [something] under/underneath/beneath [something]" as putting it under.
The specification of the putting it under action is "A courtesy redirect action for putting things into an 'underside' container.".
Instead of an actor putting something under something (this is the simulate putting under rule):
if the second noun incorporates an underside:
let curunder be a random underside incorporated by the second noun;
if the noun is curunder or the second noun is curunder:
if the player can see the actor:
say "That's irrational.";
otherwise:
stop the action;
otherwise:
unless the noun is in curunder:
if the bulk of the noun is greater than the bulk of curunder:
if the player can see the actor:
say "[The noun] is too big to fit under [the holder of curunder].";
otherwise:
stop the action;
silently try the actor inserting the noun into curunder;
if the noun is in curunder:
if the player can see the actor:
say "[if the actor is the player]You place[otherwise][The actor] places[end if] [the noun] under [the second noun].";
rule succeeds;
otherwise:
rule fails;
otherwise:
if the player can see the actor:
say "[The noun] is already under [the second noun].";
otherwise:
stop the action;
otherwise:
unless the noun is the second noun:
if the player can see the actor:
say "That's impractical in this case." instead;
otherwise:
stop the action;
otherwise:
say "That's irrational.".
Removing it from under is an action applying to two things and requiring light. Understand "get [something] from under/underneath/beneath [something]" as removing it from under. Understand "take [something] from under/underneath/beneath [something]" as removing it from under. Understand "pull [something] from under/underneath/beneath [something]" as removing it from under. Understand "remove [something] from under/underneath/beneath [something]" as removing it from under.
The specification of the removing it from under action is "A courtesy redirect action for retrieving things from an 'underside' container.".
Before an actor removing something from under something (this is the simulate removing from under rule):
if the second noun incorporates an underside:
let curund be a random underside incorporated by the second noun;
unless the noun is in curund:
if the player can see the actor:
say "[The noun] isn't under [the second noun]." instead;
otherwise:
stop the action;
otherwise:
try the actor taking the noun instead;
otherwise:
if the player can see the actor:
say "There isn't anything under [the second noun]." instead;
otherwise:
stop the action.
Section 4 - Entering and Exiting Undersides
Crawling under is an action applying to one thing. Understand "get under/underneath/beneath [something]" or "crawl under/underneath/beneath [something]" or "hide under/underneath/beneath [something]" or "move under/underneath/beneath [something]" as crawling under.
The specification of the crawling under action is "A simulation for entering 'underside' containers.".
Check an actor crawling under something (this is the check and redirect crawling under rule):
if the noun incorporates an underside (called curunder):
if the bulk of the actor is greater than the bulk of curunder:
if the player can see the actor:
say "[if the actor is the player]You[otherwise][The actor][end if] can't fit under [the noun]." instead;
otherwise:
stop the action;
if curunder is closed:
silently try the actor opening curunder;
unless curunder is open:
if the player can see the actor:
say "[if the actor is the player]You[otherwise][The actor][end if] aren't able to get under [the noun]." instead;
otherwise:
stop the action;
if the holder of curunder is the holder of the actor and the actor is the player:
say "You'll need to get [if the noun is a container]out of[otherwise]off[end if] [the noun] before you can get under it." instead;
try the actor entering curunder instead;
otherwise:
if the player can see the actor:
say "[The noun] isn't something [if the actor is the player]you[otherwise][the actor][end if] can get underneath in any practical sense." instead.
After an actor entering an underside (this is the reporting-redirect-for entering an underside rule):
if the player can see the actor:
say "[if the actor is the player]You get underneath[otherwise][The actor] gets underneath[end if] [the holder of the noun].".
Crawling out from is an action applying to one thing. Understand "get out from under/underneath/beneath [something]" or "crawl out from under/underneath/beneath [something]" or "move from under/underneath/beneath [something]" as crawling out from.
The specification of the crawling out from action is "A courtesy redirect action for exiting from an 'underside' container.".
Instead of an actor crawling out from something (this is the redirect crawling out from to exiting rule):
try the actor exiting.
After an actor exiting (this is the reporting redirect for exiting an underside rule):
if the container exited from is an underside:
if the player can see the actor:
say "[if the actor is the player]You get[otherwise][The actor] gets[end if] out from under [the holder of the container exited from].";
if the actor is the player:
try looking;
otherwise:
continue the action.
Chapter 3 - Example Room
Persuasion rule: persuasion succeeds
The Bedroom is a room. The description of the bedroom is "Your cozy bedroom.".
A bed is an enterable supporter in the bedroom. The bed is bedsize. The description of the bed is "Your comfy bed.".
An underside called bedspace is part of the bed.
A sock is in the bedspace. The description of the sock is "A dusty sock.".
A blanket is on the bed. The blanket is bathtubsize. The description of the blanket is "A faded wool blanket.".
A marble is in the bedroom. The description of the marble is "A shiny azure marble.".
Zeke is a man. The player is Zeke.
Zelda is a woman. The description of Zelda is "Your lovely wife, Zelda.".
Zeke and Zelda are on the bed.
Test me with "x bed / stand / look under bed / get sock / put sock under bed / search bed / get marble / get under bed / l / showme bed / drop marble / get out from under bed / zelda, get under bed / x bed / search bed / get on bed / l /zelda, stand / l.".
There are two remaining features I want to add, but both of them involve processes I’ve been unable to fully understand for quite some time now.
- Modifying the visibility ceiling
In this particular case, when the player is under the bed I’d like the room description to appear as:
Bedroom (under the bed)
Your cozy bedroom.
More generally, I’ve looked at the section in the Standard Rules dealing with the looking action and determining visibility levels several times; although I can mostly follow how the process works, I don’t understand how to intervene in or modify the process. I’ve had other situations before where, for example, the player is in container A which is inside container B. In that case I always wanted the room description while looking to say:
Room (in container B)
A room.
rather than
Room (in container B) (in container A)
A room.
If anyone can suggest a direct solution for the matter at hand involving undersides I’d be interested to hear it, but I would also be interested in hearing any discussion about how to generally affect the visibility levels processing.
- Removing things from scope
I’d like to set things up so that when the player (or all actors if possible) is in an underside of object XYZ, the player/actors cannot see other items on (for supporters) or in (for containers) object XYZ, except of course for items that are in the underside of XYZ along with the player; I’d also like to prevent the player (or other actors if possible) from interacting with any items on/in object XYZ unless such objects are in the underside of XYZ. For example, if I am hiding under a bed it’s not possible for me to read a magazine that’s on top of the bed; furthermore if Jane enters the room while I’m under the bed and drops a scarf on the bed, I shouldn’t know at all that a scarf is now on the bed until I stand up and look.
This is something I’ve had trouble with for some time now. While the Inform documentation is full of examples regarding how to add things to the scope of the player, it has little to say about deciding the scope of other actors and as far as I can determine it has not a single word about how to remove things from anyone’s scope (player or other actors).
So far I tried two things to address the issue in particular regard to undersides; both of them compiled fine, but neither worked:
[(a)]
After deciding the scope of the player while the player is in an underside (called the smallerbox) (this is the can't see other side of holder while in underside rule):
let the greaterbox be the holder of the smallerbox;
unless the greaterbox is transparent:
place the greaterbox in scope, but not its contents;
repeat with adjustment running through things in the smallerbox:
place adjustment in scope.
The above seemed to have absolutely no effect on anything.
[(b)]
Rule for deciding the concealed possessions of a supporter (called cursup):
unless cursup incorporates an underside:
make no decision;
otherwise:
let curund be a random underside incorporated by cursup;
if the player is in curund:
if the particular possession is in curund:
no;
otherwise:
yes;
otherwise:
make no decision.
(b) had the odd effect of hiding the player after entering the underside, as well as blocking the “After entering an underside” rule (both of which are undesirable effects), but otherwise had no effect on anything.
Despite the claim
I find that this is something I want to do on a fairly regular basis, for both the player and for other actors; sadly I don’t really know how to even start writing such rules.
Does anyone have any suggestions for dealing with these issues?