Jump to content

Displaying game hour?


Jokerine

Recommended Posts

Hey folks. I was wondering yesterday if it would be possible to have an activator (say, a clock) display a message with the current in-game time when activated by the player. Nice and simple.

 

Is this possible? I've looked around the Wiki, but besides GetUserTime (which is apparently useful for checking for the player's actual computer time) from NVSE I didn't see much. I've never scripted with NVSE or any other extender, so perhaps something nice and simple like this could be a good way to start.

 

If anybody has some pointers please let me know. Thank you :)

Link to comment
Share on other sites

Hm... so how would I go about having this display as a message? Sorry if this is dumb but I had never tried to do this before :sad:

 

EDIT: Seems like GetCurrentTime also exists? Perhaps that could be used as well.

Edited by Jokerine
Link to comment
Share on other sites

Going off hlp's suggestion, I'd do it like this:

short game_hour
short game_mins

begin onActivate
    set game_hour to GameHour
    set game_mins to (GameHour - game_hour) * 60
    showMessage MessageWithTime, game_hour, game_mins
end

The variables being defined as short ensures that the decimal part is cut off, effectively flooring the value.

The message text in MessageWithTime needs to contain two format specifiers for displaying the two variables. Here's an example: "The time is: %02.0f:%02.0f"

 

This will show hours and minutes separated with a colon with leading zeroes for both if they're single-digit values.

Breakdown of the format specifier:
% - Every format specifier starts with a percentage sign.
0 - First zero tells the game to use zeroes instead of spaces for unused digits.
2 - This defines the "width" of the value. If there's not enough digits, it will use zeroes for padding.
.0f - Tells the game to show a floating point value with zero decimal places.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...