Sleeping

So if you’ve followed my first thread about every turn, you probably know that I’m new to inform and IF writing in general. This is my first project. I’m learning as I go working on an easily expandable project about surviving in a zombie infested world.

I haven’t been able to find anything regarding sleep to help me with this feature. But I have found the basics:

[code]A person is either awake or asleep. A person is usually awake.

Instead of sleeping: now the player is asleep; say “You fall asleep.”
Instead of doing something other than waking up, waiting or sleeping when the player is asleep:
say “Deep within the realms of dreams and terrors, you are unable to do that!”
Instead of sleeping when the player is asleep:
say “Zzzz.”
Instead of waking up when the player is asleep:
now the player is awake;
say “You come to suddenly, wiping drool from your lips.”[/code]

But I want to make this feature a bit more diverse and I have no clue how. I’d be happy to put a credit to your name on the project if someone could come up with the code for this feature. Basically I want the game to have an uncontrollable sleep period. For every 120 minutes awake, 60 minutes of sleep is required before a person wakes up. The player cannot type ‘wake up’. However if a person is attacked I want them to immediately wake up so they can protect themselves. I’d also like the date displayed upon waking up (if possible, only if it is a new day after the day the player went to sleep), but not the time.

I’m probably asking too much but if there’s someone interested in helping me out, that would be amazing.

Thank you,

Wolf

Actually, I have dealt with sleeping and waking up in games I’ve made. Here’s a simple example of it with the player waking up when attacked.

[code]“Test”

Yourself is either awake or asleep. Yourself is awake.

The block sleeping rule is not listed in the check sleeping rulebook.

Carry out sleeping (this is the standard carry out sleeping rule):
if the player is awake begin;
say “You fall asleep.”;
now the player is asleep;
otherwise;
say “Zzzz.”;
end if.

Before doing anything other than sleeping, waking up, waiting or looking when the player is asleep (this is the sleepy rule):
say “Deep within the realms of dreams and terrors, you are unable to do that!” instead;

The sleepy rule is listed first in the before rulebook.

The block waking up rule is not listed in the check waking up rulebook.

Carry out waking up (this is the standard carry out waking up rule):
if the player is asleep begin;
say “You come to suddenly, wiping drool from your lips.”;
now the player is awake;
otherwise;
say “You are already awake.”;
end if.

The block attacking rule is not listed in the check attacking rulebook.

Carry out someone attacking the player when the player is asleep (this is the wake up when attacked rule):
now the player is awake;
say “You wake up to find yourself under attack from [the actor].”.

Carry out someone attacking (this is the standard carry out someone attacking rule):
say “[The actor] attacks [the noun].”.

Carry out attacking (this is the standard carry out player attacking rule):
say “You attack [the noun], completely obliterating them.”;
remove the noun from play.

Every turn when the remainder after dividing turn count by five is zero:
if the evil demon is not off-stage, try the evil demon attacking the player.

The Testing Room is A Room. The Evil Demon is a person in the testing room.

Test me with “sleep / sleep / sleep / sleep / sleep / attack demon / l”.[/code]

Hope this helps.

Are you really contemplating a game where the player has to type Z for 60 turns in a row? I think that is quite going to tax your players’ patience.

An easy way out would be to just set the time of day forward one hour manually in your code for sleeping.

Instead of sleeping: now the time of day is the time of day plus 59 minutes; say "You take a long good nap and wake up refreshed an hour later."

But if it’s important that the turns go by one by one as normal, I would suggest using the technique from “Nine AM Appointment” in the Recipe Book to advance the game one turn at a time without the need of input from the player.
(It would go something like this:)

[code]A person is either awake or asleep. A person is usually awake.
A person can be under attack.

The block sleeping rule is not listed in any rulebook.

Carry out sleeping:
now the player is asleep;
say “You fall to sleep.”;
let the wakeup time be the time of day plus 59 minutes;
while the time of day is not the wakeup time and the player is not under attack:
follow the turn sequence rules;
now the player is awake.

Report sleeping: if the player has not been awake for one turn, say “Zz… You come to suddenly, wiping drool from your lips.”

Every turn while the player is asleep: say “Zzzz”.[/code]

Oh thank you for picking up on that Felix, I totally forgot they would have to press a button every turn whilst sleeping. I know there’s code out there to change the length of time passed with certain actions. I could set sleeping to be a 360 minute turn. Then it could be 1 or 2 turns to finish the sleeping.

That’s definitely better :slight_smile: !
(There are a couple of extensions on the Inform site to help.)