(Inform 7) Please Help With Custom Time Period

I’m having a FEW problems here. I’m trying to do “times of day” as generalities.

Defined as such:
A Day_Time is a kind of value. The Day_Times are Morning, Afternoon, Evening, and Night.

Then in the intro to the game I do:
Now the Day_Time is morning;

Inform then complains that:
Problem. In the sentence ‘Now the Day_Time is morning’ , I was expecting to read a condition, but instead found some text that I couldn’t understand - ‘the Day_Time is morning’.

Also, when I try to print Day_Time in the status line, using Emily Short’s Basic Screen Effects, It won’t accept “Day_Time” as something to print.
It complains that:
Problem. You wrote ‘" [Day_Time]"’ , but ‘Day_Time’ is used in a context where I’d expect to see a (single) specific example of a sayable value, not a description.

Here’s the Fancy Status Table as I’ve defined it:
``
Table of Fancy Status

left central right
" Day [day]" “” “Gold: [gold-found]oz.”
" [Day_Time]" “[location]” " [cash-held]"
``

If I comment out
Now the Day_Time is morning;
And in the Fancy Status table change “Day_Time” to “Time of day” it compiles just fine.
Leaving “Time of day” in the Table of Fancy Status and UN-commenting the “Now the Day_Time is morning;” bit, it will no longer compile. It throws that Problem message.

I’m screaming with madness, internally. I cannot for the life of me see what’s wrong here.

You’ve defined Day_Time as a kind of value, but you also need to have a variable to hold that kind of value.

What you probably want is something like this:

A Day_Time is a kind of value. The Day_Times are Morning, Afternoon, Evening, and Night.

The clocktime is a Day_Time that varies. When play begins: now the clocktime is morning.
3 Likes

OH! I forgot …
To advance the Day_Time, I pulled code directly from the Recipe Book (Section 4.1 The Passage of Time – The Hang of Thursdays example) … I copy-pasted it and changed the variable name.

[This is the new advance time rule:
	If the current Day_Time is less than night:
		Now the current Day_Time is the Day_Time after the current Day_Time;
	Otherwise:
		Now the current Day_Time is morning;
		Now the current day is day plus 1.
		
The new advance time rule is listed instead of the advance time rule in the turn sequence rules.]

If I un-comment that, it throws me A WHOMPTON of errors. So many it’s overwhelming and I have no freakin clue where to even START with troubleshooting it.

Okay … So how do I then automatically synchronize those, such that every time ‘Day_Time’ changes, ‘clocktime’ also changes?

Given the underscores, I’m guessing you’re coming from a language like C or Java?

Your original code is something like:

enum Day_Time{Morning, Afternoon, Evening, Night};
// then later
Day_Time = Morning;

In other words, you created a kind of value, but you didn’t actually create a variable. So the compiler sees “now the Day_Time is morning” as equivalent to “now the number is five”—what number, exactly?

Patrick is changing it to be something like

Day_Time clocktime = Morning;

In other words, “clocktime” is a variable of type “Day_Time”.

1 Like

Your new advance time rule would work if you had this line somewhere (similar idea to Patrick’s, just a different variable name):

The current Day_Time is initially Morning.

This declares a variable of type Day_Time called current Day_Time and sets its initial value to Morning, all at once. Without this, current Day_Time is meaningless.

Having said that, you’d have to be careful to do something else (e.g. include Modified Timekeeping by Daniel Stelzer) to prevent time advancing when the player makes a typo or otherwise does something that shouldn’t pass any time (such as looking).

It may be better to not replace the standard rule and to explicitly advance time for each action that you want to do so.

1 Like

Okay. I get it now. I think.

Not coming from C or Java (a small bit of Python, and some Inform 6) … moreso from the days in general that spaces weren’t allowed in file names. I just got in the habit of using _ as a space. LOL
And writing in Inform 7 I’m not even consistent in this. As I bash out code I find I often simply use spaces. Then when I go back to debug and I see a variable with a space, I think "well … maybe … " and replace the space with _

1 Like

Actually there was potentially some other confusion; you’re mixing up day and current day. Assuming you really wanted the latter then the complete example would be:

A Day_Time is a kind of value. The Day_Times are Morning, Afternoon, Evening, and Night.

The current day is initially 1.
The current Day_Time is initially Morning.

Table of Fancy Status
left	central	right
" Day [current day]"	""	"Gold: [gold-found]oz."
" [current Day_Time]"	"[location]"	" [cash-held]"

This is the new advance time rule:
	If the current Day_Time is less than Night:
		Now the current Day_Time is the Day_Time after the current Day_Time;
	Otherwise:
		Now the current Day_Time is Morning;
		Increment current day.
		
The new advance time rule is listed instead of the advance time rule in the turn sequence rules.

But like I said, don’t forget to include Modified Timekeeping by Daniel Stelzer or equivalent too.

1 Like

YES! Okay. Now it’s working. The status bar changes between the four defined periods of the day, and the day # advances.
NOW I just need to figure out how to make it such that the period doesn’t change every turn.

Thanks @mirality and @Draconis

Any tips or ideas on how to slow down the progression of time now?

… and to think. several years ago I had this all working perfectly in an Inform 6 game I was developing. (well … still am … but now I’m going to re-write it in Inform 7)

EDIT: Also, after further scrutinizing the example code, I noticed and realized that it had defined a variable with the name “current time period,” but I was thinking that the work ‘current’ was itself a word Inform 7 “knows.”
D’OH!
Must learn to read example code for closely and accurately.

If you include that extension I mentioned then that will change things so that time advances only on a successful turn (and not for certain actions such as looking, which you can extend). So successfully going north will advance time but trying to go north when there isn’t an exit that way won’t, for example.


If you don’t want it to change every turn at all, then remove the final line (that replaces the advance time rule). Then whenever you do want the time to change, write:

follow the new advance time rule;

(I’d recommend also giving it a better name in that case, but that’s up to you.)


A third option is to make use of recurring scenes instead of tracking time through these variables – you can make them chain into each other fairly easily, and make rules that only apply at certain times of day or changes to the world that automatically happen at different times. Having said that, it’s a bit trickier to actually advance from one scene to the next and I haven’t really played with them too much myself so I can’t help too much on that front.

1 Like

That extension isn’t in my Inform 7 install, nor is that extension author. Pretty sure I’ve DLed all available extensions. At least, all available when DLing directly within the Inform IDE.
At this point I’m not up to manually installing extensions.
Also, thanks for the tip about “slowing down” the advancement of time.