Every turn rule help

Hello,

I’d been messing with Inform for awhile, and then took quite a break. I’m trying to get back into it, and have been learning faster than before, as some of the operations I didn’t understand sunk in more quickly, but I’m having a bit of an issue still. Is there any way someone could help me with this Every turn rule (is that the right term?), as I’m having a bit of trouble creating a time system for my game…

[code]Metro is a region. [This is the main characters city]
Village is a region. [This is Marcus’s village]
In-Metro is a truth state that varies. In-Metro is true.

Use American dialect, full-length room descriptions, and the serial comma.
Rule for printing the banner text: say “Release 1/ Version 1.0/ Inform 7 build.”

Time-Keeper is a number variable. Time-Keeper is 0.

Day-Hours is a truth state that varies. Day-Hours is true. [This will test the game starting in daylight]
Time-Started is a truth state that varies. Time-Started is true.[Testing with time on at start of game]

Every turn:
if Time-Started is true: [If time has started in the game]
increase Time-Keeper by 1; [increase the timer by 1 each turn]
if Time-Keeper is 5 and Day-Hours is true: [if its daylight and it’s half over]
say “The sun is getting ready to set”; [Warn player that the sun will be setting]
if Time-Keeper is 10 and Day-Hours is true and In-Metro is true: [in city timer maxed]
now Time-Keeper is 0; [Reset the timer]
now the moon is in Metro; [Now the moon is up]
now sun is in limbo; [place sun in hidden limbo room]
now Day-Hours is false; [It’s nighttime now]
say “The moon has risen.”; [Let the player know it’s night]
if Time-Keeper is 10 and Day-Hours is false and In-Metro is true: [Tmaxed N]
now Time-Keeper is 0; [Reset timer]
now the moon is in limbo; [place moon in hidden limbo room]
now the sun is in Metro; [Place sun in city region]
now Day-Hours is true; [Now it’s Daytime]
say “The sun has risen.” [Warn player that the sun has risen]

A thing can be distant or near. A thing is usually near.

[Game Engine End][/code]

The numbers will change there, but I’ve shortened them for testing purposes…

Thanks in advance :slight_smile:

What is the problem you’re having, exactly? Is there a reason why you’re not using the built-in timekeeping?

You’ve got the indentations of your if-blocks all messed up. You probably want something like:

Every turn: if Time-Started is true: [If time has started in the game] increase Time-Keeper by 1; [increase the timer by 1 each turn] if Time-Keeper is 5 and Day-Hours is true: [if its daylight and it's half over] say "The sun is getting ready to set"; [Warn player that the sun will be setting] if Time-Keeper is 10 and Day-Hours is true and In-Metro is true: [in city timer maxed] now Time-Keeper is 0; [Reset the timer] now the moon is in Metro; [Now the moon is up] now sun is in limbo; [place sun in hidden limbo room] now Day-Hours is false; [It's nighttime now] say "The moon has risen."; [Let the player know it's night] if Time-Keeper is 10 and Day-Hours is false and In-Metro is true: [Tmaxed N] now Time-Keeper is 0; [Reset timer] now the moon is in limbo; [place moon in hidden limbo room] now the sun is in Metro; [Place sun in city region] now Day-Hours is true; [Now it's Daytime] say "The sun has risen." [Warn player that the sun has risen] or (equivalently) Every turn while Time-Started is true: [If time has started in the game] increase Time-Keeper by 1; [increase the timer by 1 each turn] if Time-Keeper is 5 and Day-Hours is true: [if its daylight and it's half over] say "The sun is getting ready to set"; [Warn player that the sun will be setting] if Time-Keeper is 10 and Day-Hours is true and In-Metro is true: [in city timer maxed] now Time-Keeper is 0; [Reset the timer] now the moon is in Metro; [Now the moon is up] now sun is in limbo; [place sun in hidden limbo room] now Day-Hours is false; [It's nighttime now] say "The moon has risen."; [Let the player know it's night] if Time-Keeper is 10 and Day-Hours is false and In-Metro is true: [Tmaxed N] now Time-Keeper is 0; [Reset timer] now the moon is in limbo; [place moon in hidden limbo room] now the sun is in Metro; [Place sun in city region] now Day-Hours is true; [Now it's Daytime] say "The sun has risen." [Warn player that the sun has risen]

(Also, you need to make the limbo a region rather than a room in order to put backdrops like the sun and the moon in it. But in order to store things in a limbo out of play, you don’t really have to create either a room or a region of your own; you can use the built-in ability to move things ”off-stage” instead: »Now the sun/moon is off-stage.» Things and backdrops by default both start out off-stage unless you declare them to be somewhere; so »The moon is a backdrop.» by itself will create a backdrop that starts the game off-stage.)

Awesome thanks for the information guys, I’m going to give it a test run here soon. I didn’t know that about moving things off stage, lol.

I’m not familiar with the built in time keeping.

I should probably take a look at the documentation again, it’s been awhile. I was just trying to get into it and building games from scratch. I have been spending a lot of time with Jim Akin, and Ron Newcombs books though :slight_smile:

hmm, I’ve tried the edits that you gave me, but something else seems to be wrong. I’m not getting the warning messages for the sun setting, or any text displayed. It seems as though the variable isn’t increasing, or something in the source isn’t responding, lol…

[code]Metro is a region. [This is the main characters city]
Village is a region. [This is Marcus’s village]
In-Metro is a truth state that varies. In-Metro is true.

Use American dialect, full-length room descriptions, and the serial comma.
Rule for printing the banner text: say “Release 1/ Version 1.0/ Inform 7 build.”

Time-Keeper is a number variable. Time-Keeper is 0.

Day-Hours is a truth state that varies. Day-Hours is true. [This will test the game starting in daylight]
Time-Started is a truth state that varies. Time-Started is true.[Testing with time on at start of game]

Every turn:
if Time-Started is true: [If time has started in the game]
increase Time-Keeper by 1; [increase the timer by 1 each turn]
if Time-Keeper is 5 and Day-Hours is true: [if its daylight and it’s half over]
say “The sun is getting ready to set”; [Warn player that the sun will be setting]
if Time-Keeper is 10 and Day-Hours is true and In-Metro is true: [in city timer maxed]
now Time-Keeper is 0; [Reset the timer]
now the moon is in Metro; [Now the moon is up]
now sun is off-stage; [place sun in hidden limbo room]
now Day-Hours is false; [It’s nighttime now]
say “The moon has risen.”; [Let the player know it’s night]
if Time-Keeper is 10 and Day-Hours is false and In-Metro is true: [Tmaxed N]
now Time-Keeper is 0; [Reset timer]
now the moon is off-stage; [place moon in hiden limbo room]
now the sun is in Metro; [Place sun in city region]
now Day-Hours is true; [Now it’s Daytime]
say “The sun has risen.” [Warn player that the sun has risen]

A thing can be distant or near. A thing is usually near.
[/code]

Your code is working for me. (When I add lines defining the sun and moon as backdrops, and defining a room.)


>z
Time passes.

>z
Time passes.

>z
Time passes.

>z
Time passes.

>z
Time passes.

The sun is getting ready to set

hmm, I hadn’t caught that. It’s definitely working, but it’s not quite displaying the text where I’d like It to…For some reason it’s displaying it after the room description, and just before another Every turn rule, which is followed by a say command…I’d like it to display after both…any ideas? in my source.

“Every turn” is a rulebook; there are several ways to control the order of its rules. See chapter 18. The simplest is to write your time rule as:

The last every turn rule:
   [...]