I seem to remember that this can be done, but I can’t find it now.
I want to set the time that can be displayed and incremented to the ACTUAL real time of the local computer (or server) it is being played on.
I am displaying the time in the status bar I am using the command:
The time of day is 10:27 AM.
And that works fine. But what if I want it to be the actual time of the player based on their computer setting? I have tried a few plugins that are great at “say” statements. But I want to actually set the variable that will continue throughout the current players activity. So each load/reload gets the REAL time of the users computer. Not a preset or default.
I feel like I have seen this done before… just can’t find it now.
This is possible with these Glk functions, though I don’t think anyone has made a nice Inform 7 extension for it yet. How’s your Inform 6?
What exactly do you want to be able to do with it? Just display the current time in the status bar? Access it through the built in time of day variable? Do you want it to keep updating in real time? After the player enters a command? Or just be set once, and then the game can increment it each turn as it normally does?
“Real Date and Time” is also available from the Public Library (on the Extensions tab in the front end); we should be encouraging people to use that rather than GitHub where possible.
Also I suspect that the OP has already found that one, as it matches their description of being able to print the real time, but it doesn’t explicitly provide a way to set the game time to be the same as the real time. That should be possible somehow.
I had tried that, but not in a rule. I was trying to do it the same as I when I set the time in the original post. As an “every turn” rule it works. Also had to add it as a “When play begins” rule so it wouldn’t wait until after first turn. But I do want it to track the real time as play progresses, so I also use the “every turn” rule.
Okay, three hours of looking and I am no closer to finding out how to set a timed event that can update the status bar if player is idle.
I like your idea @Draconis but can you point me in the right direction? The docs mention timed events, but they are based on preset times for things to happen. Such as “At 11:30 chime clock”.
Do I set a variable to be the player’s time and trigger an event if that changes? Seems logical in normal situations. But a turn based system seems to suspend time until the next turn, or until a preset threshold is reached.
How do I force an update timer to trigger a status bar update? Or am I looking at this wrong? Is there another way… Maybe it is something like “When player’s time = player’s time +1 then update status bar”.
One thing I have noticed is that when I am stumped, it is because I am making the problem bigger than it really is. That is why when you said it might be overkill I thought “That’s for me!”.
Playing with Glulx events is never particularly easy. Fortunately, zarf’s got a new extension that helps a lot. This code is untested, since I don’t have I7 on this computer, but here goes nothing:
Include Unified Glulx Input by Andrew Plotkin.
When play begins: set the timer to one second. [Tell Inform we want notifications every second]
Rule for accepting input when handling timer-event: [This rule runs every time the timer ticks]
now the time of day is the player's time; [Update the time]
redraw the status line; [Update the text on the screen]
reject input event. [We're done with this event, don't run normal processing on it]
This is based on the Tick Tick Tick Button example, but you’re free to just treat it as a magic incantation if you like: you don’t need to dig into how it works.
I got it working. It took a bit as it seems to conflict with some other plugin or command in two other projects (compiles to I6 but I6 gets confused) I tested it in. The “Sorry, something went wrong” error. I tried to hunt down what, but decided it would be easier to create a new project, combine what I needed for the basics and it works.
Yeah, unfortunately the two aren’t compatible. Unified Glulx Input has more capabilities overall (for hyperlinks etc), but Glulx Real Time is more user-friendly if you want multiple timers on different intervals.
In this case I’d recommend sticking with UGI, since you only need a single timer that’s always going to do the same thing. So you can just code it once and forget about it.