I was too optimistic about finishing Frankenstein’s Ghost. Still got a problem.
My intention was to create a ghost who shows up randomly (1 in 4 chance), but not until a certain room is visited. However, the ghost in the source code I have written isn’t waiting for that.
Here’s the code:
The ghost is a person. The ghost is in Hallway.
The ghost counter is initially zero.
if the ghost counter is one:
end the story saying “It touced you. You have died.”;
otherwise if the ghost is in the location:
increment the ghost counter;
now the ghost counter is zero.
if a random chance of 1 in 4 succeeds:
now the ghost is in the location;
now the ghost counter is zero;
say “Holy haunt, Batman! There’s a presence here – an apparition! Jeepers, it’s the monster’s ghost! You’d better leave – if that thing touches you, you’re dead!”
I am a newbie and neophyte of every kind, but reading the code you have provided, I don’t see anything that makes the encounter dependent on visiting Hallway. There is probably a better way to do this, but perhaps you could make a condition that tracks whether Hallway has been visited and add that as the first requirement of the every-turn rule (before the random-chance success requirement)?
Non-neophytes, please regard this post as an attempt to practice/exercise.
Lux is right. You want to change the preamble of your “Every turn:” rule to “Every turn when the Hallway is visited:”.
I get the feeling “visited” is implemented by default – is that the case?
Edit: Okay, it is. Well, that’s nice. I’m going to see if there is an equivalent for examining things, because that would be very nice.
…the trick there being that the adjective “visited” for rooms is actually built-in to Inform, so you don’t need to do any bookkeeping yourself.
EDIT: Whoops, I was trying to get in right after Draconis. lux: Yes! I think it’s actually introduced in Example 4 rather than in the main text of Writing with Inform.
Bumping rather than editing: Lux, I’m pretty sure there’s no built-in equivalent for examined things, but examples 90 and 111 of the documentation (Morning After and Y ask Y?) show you how to set up an “examined/unexamined” adjective.
Draconis: That works.
All: Thanks for the replies.