System time in ZScript

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: System time in ZScript

Re: System time in ZScript

by 3saster » Sat Nov 28, 2020 1:42 pm

This was added in 4.5.0 and can be closed. See relevant wiki page.

Re: System time in ZScript

by ZZYZX » Fri Nov 29, 2019 6:05 am

Graf Zahl wrote:What's the point of Unix time? Getting that displayed requires quite a bit of support code.
Yup, I'd rather have something like strftime() ported. This time we also don't need any 64-bit ints :)

(edit: actually looked at 3saster's code and there is strftime)

Re: System time in ZScript

by 3saster » Fri Nov 22, 2019 9:49 pm

Re: System time in ZScript

by 3saster » Fri Nov 22, 2019 2:09 pm

GetRealTime() can be trivially implemented, because, well, it already exists :P I agree that GetTime() doesn't make much sense unless SetTime() is implemented, which I only suggested cause Rachel suggested a debug parameter did earlier. The global idea was stupid, because I went full dumb and forgot the methods were static. Perhaps I'll just go ahead and make a PR, and we move the discussion there.

Re: System time in ZScript

by Graf Zahl » Fri Nov 22, 2019 1:55 pm

What's the point of Unix time? Getting that displayed requires quite a bit of support code.

Re: System time in ZScript

by _mental_ » Fri Nov 22, 2019 1:45 pm

Points one and two seem OK, the third one is WTF, and the forth is “sorry, I didn’t get it” too.

Re: System time in ZScript

by 3saster » Fri Nov 22, 2019 1:27 pm

Any word on this? It, uh, seems to have gone dormant...

I simply ask because it seems that since you are okay with UI-scope only, all that would need to be done is make this method public. I'll say that it does make the location in althud a little odd though.

Since Nightfright and I largely just want this for our own mod, I'd be willing to do the work myself, but I need to be clear on the specifications. This is what I am thinking:
  • Make a Clock class that is UI-scope in ZScript.
  • Add the static native public methods GetTime(), which returns the Unix timestamp, and GetRealTime(), which returns the Unix timestamp taking timezone into account.
  • Add a static public method SetTime() that lets you set the current time (i.e. a debug override).
  • Make a global variable of this type that can be accessed directly.
Does this seem okay, or totally off? Are there any other things to consider?

Re: System time in ZScript

by Rachael » Tue Sep 10, 2019 8:12 am

ZZYZX wrote:(Sep 07 is an old post? :о)
If you're going to make an argument about a comment out of context without taking into account the context within which the point was made, it's not only foolish, but it's a waste of time, and quite annoying to boot.

Don't do that.

And if this savegame discussion continues I will not invest any effort into this feature at all. I'm already quite sick of it and it already seems not worth it with people more interested in pointlessly arguing a point that's already been conceded, than they are in any actual productive or constructive discussion about it.

Re: System time in ZScript

by ZZYZX » Tue Sep 10, 2019 7:14 am

I can already easily detect savegames by comparing level time at global map load handler. I don't understand the concerns.
I can even store my precious terrywad-critical information between saves and loads by using a cvar! (but I could also store global player progress and inventory there)

(Sep 07 is an old post? :о)

Re: System time in ZScript

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

Of course you respond to a really old post without looking at the further discussion :P

Re: System time in ZScript

by 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?

Re: System time in ZScript

by 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

Re: System time in ZScript

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

Re: System time in ZScript

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

Would the debug override be accessible by the player to circumvent any savegame detection?

Re: System time in ZScript

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

Excellent. Thanks a lot in advance, guys!

Top