I am trying to write some code for when the time is visible in the status bar. Currently, this is my code:
To say visibletime:
if a timepiece is in the presence of the player:
say "[time of day]";
else if the sky is in the presence of the player:
say "[approxtime]";
else:
say "??:??"
When play begins:
now the right hand status line is "[visibletime]"
However, inform does not like the two “in the presence of the player” conditions. These are the errors I get:
[spoiler][code]Problem. In the sentence ‘if a timepiece is in the presence of the player’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘a timepiece is in the presence of the player’.
I was trying to match this phrase:
if (a timepiece is in the presence of the player - a condition):
But I didn’t recognise ‘a timepiece is in the presence of the player’.
Problem. In the sentence ‘if the sky is in the presence of the player’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘sky is in the presence of the player’.
I was trying to match this phrase:
if (sky is in the presence of the player - a condition):
But I didn’t recognise ‘sky is in the presence of the player’.
[/code][/spoiler]
The sky is a backdrop, and a timepiece is a kind of thing.
EDIT: Well, looks like you came up with another solution while I was typing!
I’m not sure that “in the presence of” works outside of rule headings. So you can say “Carry out jumping in the presence of the sky,” but I don’t know if “in the presence of the sky” works outside that. Also I don’t think you can do “when X is in the presence of Y”; I think it always has to be “in the presence of X,” which means that the player is in the presence of X.
One thing you might try is “if a timepiece is visible” and “if the sky is visible.” These will do more complicated visibility checks (so they shouldn’t hold if the timepiece is in the location but in a closed opaque container, for instance), but that’s probably fine.
Also note that you have to end your code blocks with periods, or put extra space around them.
This is something I have that seems to work:
[code]To say visibletime:
if a timepiece is visible:
say “[time of day]”;
else if the sky is visible:
say “[approxtime]”;
else:
say “??:??”.
When play begins:
now the right hand status line is “[visibletime]”.
Front walk is a room. The Hall is inside from front walk. The living room is inside from Hall.
A timepiece is a kind of thing. The clock is a fixed in place timepiece in the living room. The watch is a timepiece in the living room.
The sky is a backdrop. The sky is in the Front walk.
To say approxtime: say “Day or maybe Night”.[/code]
You did figure it out, “When foo is in the location” is a much better phrase to use because “the location” is always the room the player is in, no matter what else the player is contained by. (a chair, a locked trunk).
I know there’s a good page or so in the manual about “in the presence of” but I’m not sure what the difference is between that and “when X is in the location.” Perhaps it’s meant only to apply to NPCs and also take into account if Harry Houdini is locked in the trunk along with you? - instead of literally “in the location”.
“In the presence of X” does a full scope check. This is slower, but correctly handles cases like an object added to scope (answers yes) or an object in a closed opaque container (answers no).