Setting time from local computer

#1

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.

Thanks!

0 Likes

#2

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?

1 Like

#3

I’m not at my Inform computer now to dig for the source, but I recall the extension is Ron Newcomb’s Real Date And Time. If it’s not in the built-in library, you should be able to google it.

-Wade

1 Like

#4

Ah nice: https://github.com/i7/archive/blob/master/Ron%20Newcomb/Real%20Date%20and%20Time.i7x

Using this extension the player's time will return a time value of the current time. You can easily plug that into status line code or whatever else.

1 Like

(David Kinder) #5

“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.

1 Like

#6

All that needs is now time of day is the player's time in an appropriate rule, perhaps an every turn rule.

1 Like

#7

Yes, this is what I was referring to.

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.

Thanks for the help!

1 Like

(Daniel Stelzer) #8

If you want the clock display to update in real-time (so it ticks up on the status bar even when you aren’t typing) you can also use a Timed Event, but that might be overkill.

1 Like

#9

Hmmmm… hadn’t thought of that, but I like the idea. Damn. Back to the docs I go.

0 Likes

#10

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!”.

0 Likes

(Daniel Stelzer) #11

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.

1 Like

#12

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.

Thanks! That was what I needed!

0 Likes

(Nathanaël Marion) #13

There’s also Erik Temple’s Glulx Real Time extension (I guess it should work with the latest version of Inform).

But I don’t really know what is the differences with it and Unified Glulx Input. If I’m not mistaken, Unified Glulx Input won’t work with extensions used for multiple windows or hyperlinks.

1 Like

(Daniel Stelzer) #14

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.

1 Like

#15

I have UGI working now… but as I add in other extensions I may create a mirror project to see which one I break less. This is as much a learning experience as a creative one for me.

This is probably what I will do. But knowing the ins and outs of both will be good for the future.

0 Likes