I want something like this -
player in room
after 2 turns NPC enters and makes threat to player
next turn NPC repeats threat
next turn NPC carries out threat and games ends
But this NPC threat can be stopped by the player performing a simple action such as pushing a button
You could use scenes if you wanted to, but its fairly simple to do without them.
This is how I would do it:
[code]The Living Room is a room.
The Kitchen is north of the Living Room.
The Cook is in the Kitchen. “The cook glares at you.”
ThreatCount is a number that varies. ThreatCount is 0.
Every turn when the location of the player is the kitchen:
now ThreatCount is ThreatCount plus 1;
if ThreatCount is 3:
say “The cook glares menacingly at you. ‘Get out of my kitchen,’ he growls.”;
otherwise if ThreatCount is 4:
say “The cook grabs a knife from the counter. 'I’m not going to tell you again.”;
otherwise if ThreatCount is 5:
say “The cook runs towards you, stabbing you in the heart with the carving knife. ‘Nobody enters my kitchen!’ he says, over your weakening body.”;
end the game in death.
Although I am by no means an expert. There might be an easier way.
I plugged you code into Inform 7, ran it and got this error message:
[i]Problem. The phrase or rule definition ‘Every turn when the location of the player is the kitchen’ is written using the ‘colon and indentation’ syntax for its 'if’s, 'repeat’s and 'while’s, where blocks of phrases grouped together are indented one tab step inward from the ‘if …:’ or similar phrase to which they belong. But the tabs here seem to be misaligned, and I can’t determine the structure. The first phrase going awry in the definition seems to be ‘now ThreatCount is ThreatCount plus 1’ , in case that helps.
This sometimes happens even when the code looks about right, to the eye, if rows of spaces have been used to indent phrases instead of tabs.
I’m not experienced enough with Inform yet to see what must be an obvious error. But this looks like something I could use if I can fix it.
It sounds like your tabs didn’t copy correctly – if you copy directly from the post the tabs will convert into spaces, which gives you that error.
Here’s how to avoid having to convert the spaces back into tabs by hand:
- Hit “reply” to the post with the code in it.
- Copy the code from inside the quoted part of the original post. If the original poster pasted it in with tabs, you’ll be able to copy it with tabs.
- Hit “cancel” so you aren’t actually replying to the post.
Hope this helps!
That fixed it. Now I can adapt the routine to my game.