Low Light
Example 359
★Suppose we want a different treatment of lighting than the usual: the room isn't totally dark, but there's something we can't see unless we turn on a bright light.
"Low Light"
First we make our environment and its light:
The Workroom is a room. The desk is in the Workroom. The brilliant lamp is a device on the desk.
To decide whether the light level is high:
if the brilliant lamp is switched off, no;
if the player cannot see the brilliant lamp, no;
yes.
To decide whether the light level is low:
if the light level is high, no;
yes.
Now we make a shadow so that the player can only refer to it if the shadow is in inventory or the light is on:
The shadow is a privately-named thing on the desk.
Understand "barely-visible" or "barely visible" or "shadow" as the shadow when the light level is high. Understand "invisible" or "shadow" as the shadow when the player encloses the shadow.
And finally a couple of extra touches to make it clear why we're able to interact with the shadow when it's in inventory, even if the light is low:
Before printing the name of the shadow:
if the light level is high:
say "barely-visible ";
otherwise if the player encloses the shadow:
say "invisible (but tangible) "
After dropping the shadow when the light level is low:
say "You let it go and it fades into the ambient gloom."
To handle the appearance of the object, we want to set its locale priority to 0: that will prevent it being named in room descriptions.
After choosing notable locale objects:
unless the light level is high:
set locale priority of the shadow to 0.
Test me with "look / get shadow / turn on lamp / look / get shadow / i / turn off lamp / i / drop shadow / look / get shadow / turn on lamp / look".
Test me with "look / get shadow / turn on lamp / look / get shadow / i / turn off lamp / i / drop shadow / look / get shadow / turn on lamp / look".
Workroom
You can see a desk (on which is a brilliant lamp) here.
>(Testing.)
>[1] look
Workroom
You can see a desk (on which is a brilliant lamp) here.
>[2] get shadow
You can't see any such thing.
>[3] turn on lamp
You switch the brilliant lamp on.
>[4] look
Workroom
You can see a desk (on which are a brilliant lamp and a barely-visible shadow) here.
>[5] get shadow
Taken.
>[6] i
You are carrying:
a barely-visible shadow
>[7] turn off lamp
You switch the brilliant lamp off.
>[8] i
You are carrying:
an invisible (but tangible) shadow
>[9] drop shadow
You let it go and it fades into the ambient gloom.
>[10] look
Workroom
You can see a desk (on which is a brilliant lamp) here.
>[11] get shadow
You can't see any such thing.
>[12] turn on lamp
You switch the brilliant lamp on.
>[13] look
Workroom
You can see a barely-visible shadow and a desk (on which is a brilliant lamp) here.
You can see a desk (on which is a brilliant lamp) here.
>(Testing.)
>[1] look
Workroom
You can see a desk (on which is a brilliant lamp) here.
>[2] get shadow
You can't see any such thing.
>[3] turn on lamp
You switch the brilliant lamp on.
>[4] look
Workroom
You can see a desk (on which are a brilliant lamp and a barely-visible shadow) here.
>[5] get shadow
Taken.
>[6] i
You are carrying:
a barely-visible shadow
>[7] turn off lamp
You switch the brilliant lamp off.
>[8] i
You are carrying:
an invisible (but tangible) shadow
>[9] drop shadow
You let it go and it fades into the ambient gloom.
>[10] look
Workroom
You can see a desk (on which is a brilliant lamp) here.
>[11] get shadow
You can't see any such thing.
>[12] turn on lamp
You switch the brilliant lamp on.
>[13] look
Workroom
You can see a barely-visible shadow and a desk (on which is a brilliant lamp) here.