[Added] System time in ZScript

Moderator: GZDoom Developers

System time in ZScript

Postby NightFright » Sat Sep 07, 2019 1:47 am

I am looking for a way to show current system time instead of level/hub time. If possible in both 12h and 24h formats (e.g. 08:15 PM vs 20:15).

Is this possible in ZScript, and if so, how is it done?
User avatar
NightFright
Spotlight Team
 
Joined: 02 May 2008
Location: Germany

Re: System time in ZScript

Postby Graf Zahl » Sat Sep 07, 2019 3:13 am

Currently there is no access to the system time from ZScript.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: System time in ZScript

Postby NightFright » Sat Sep 07, 2019 3:28 am

Is this something you'd be considering for a feature request? I am sure this could prove useful, not only for my own project.
User avatar
NightFright
Spotlight Team
 
Joined: 02 May 2008
Location: Germany

Re: System time in ZScript

Postby Rachael » Sat Sep 07, 2019 3:45 am

Only way this will happen is if it's UI-scope only. The game world is deterministic by nature and external influences (such as time) would ruin that.

I'm thinking the best way to implement this is to create and expose a UI element that can be accessed that gives a Unix timestamp only, and possibly a local timezone offset. Then, functions can be made to extend that element to internally determine the correct time from that timestamp.

Unfortunately, however, without access to 64-bit ints, such an implementation would be weak to the 32-bit timestamp overflow issue happening in 2038.

This however, sounds like a gateway to a lot of really hacky projects - I am not sure if it's really a good idea to make this information available to mods whatsoever, even in the UI scope. This could be used to detect loading a saved game, which I am really not a fan of.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: System time in ZScript

Postby NightFright » Sat Sep 07, 2019 4:18 am

I see. Was asking since the feature was/is somewhat available via hud_showtime for the ZDoom alternate HUD. I assume there's no way to tap into that via ZScript, either?
User avatar
NightFright
Spotlight Team
 
Joined: 02 May 2008
Location: Germany

Re: System time in ZScript

Postby Void Weaver » Sat Sep 07, 2019 4:34 am

So there is no way to use GetRealTime() from althud's DrawTime for ex.?
User avatar
Void Weaver
Keeper of the Diablo bestiary storage Also amateur DECORATE-spaghetti weaver ಠ_ಠ
 
Joined: 18 Dec 2014

Re: System time in ZScript

Postby Graf Zahl » Sat Sep 07, 2019 5:13 am

It's deliberately declared private. Guess why... ;)

As a pure UI widget this is fine but as soon as this can be used to alter gameplay, it will become problematic. It cannot be on the 'play' side, because even Unix time stamps depend on the locally set time on each system so they would differ.

@Rachael: This value could be safely stored in a double, we don't need 64 bits ints just for that.
As for the savegame thing, there's already a ZScript and ACS event for that, so this wouldn't add much of a problem for that. The play synchronization issue is the biggest caveat here.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: System time in ZScript

Postby NightFright » Sat Sep 07, 2019 5:18 am

Well, I would just want to use it just like in the ZDoom HUD, simple display of system time onscreen. If you want to prevent it from doing anything else, that'd work for me.
User avatar
NightFright
Spotlight Team
 
Joined: 02 May 2008
Location: Germany

Re: System time in ZScript

Postby Rachael » Sat Sep 07, 2019 5:52 am

Well - I might come up with something then. It doesn't seem to difficult to implement. I'm going to force it to be UI-only though - if an author wants to pass the system time to the game sim, s/he can still use a NetEvent for that.

I'm probably going to put in a debug override for this, too, though - that way it would be possible to test certain dates (ie Christmas) without manipulating the actual system time.
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: System time in ZScript

Postby NightFright » Sat Sep 07, 2019 6:27 am

Excellent. Thanks a lot in advance, guys!
User avatar
NightFright
Spotlight Team
 
Joined: 02 May 2008
Location: Germany

Re: System time in ZScript

Postby Matt » Sun Sep 08, 2019 11:54 pm

Would the debug override be accessible by the player to circumvent any savegame detection?
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: System time in ZScript

Postby Rachael » Mon Sep 09, 2019 6:44 am

The whole point of the debug override is to be accessible by the player - for any reason, whatsoever, and not strictly to circumvent anything.
Last edited by Rachael on Mon Sep 09, 2019 8:15 am, edited 2 times in total.
Reason: reworded, clarified
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Re: System time in ZScript

Postby phantombeta » Mon Sep 09, 2019 6:54 am

As Graf said, I wouldn't worry about it being used for savegame detection. It would be extremely janky, and there's a far better way that isn't really fixable at all.

Semi-related:
@Graf What ACS event? I don't remember any such thing, and can't find it anywhere either O_o
User avatar
phantombeta
Tired of being treated like trash by control freaks
 
Joined: 02 May 2013

Re: System time in ZScript

Postby Rip and Tear » Mon Sep 09, 2019 12:31 pm

Rachael wrote:Only way this will happen is if it's UI-scope only. The game world is deterministic by nature and external influences (such as time) would ruin that.

I'm thinking the best way to implement this is to create and expose a UI element that can be accessed that gives a Unix timestamp only, and possibly a local timezone offset. Then, functions can be made to extend that element to internally determine the correct time from that timestamp.

Unfortunately, however, without access to 64-bit ints, such an implementation would be weak to the 32-bit timestamp overflow issue happening in 2038.

This however, sounds like a gateway to a lot of really hacky projects - I am not sure if it's really a good idea to make this information available to mods whatsoever, even in the UI scope. This could be used to detect loading a saved game, which I am really not a fan of.


Isn't it possible to detect savegames from the WorldLoaded event handler?
User avatar
Rip and Tear
I <3 ZScript
 
Joined: 02 May 2017
Operating System: Mac OS X 10.8 or later
Graphics Processor: Intel (Modern GZDoom)

Re: System time in ZScript

Postby Rachael » Mon Sep 09, 2019 4:17 pm

Of course you respond to a really old post without looking at the further discussion :P
User avatar
Rachael
Admin
 
Joined: 13 Jan 2004
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Next

Return to Closed Feature Suggestions

Who is online

Users browsing this forum: No registered users and 0 guests