• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

world time

It is possible in Lua (via os.date()), but there are a couple of important notes:
  1. The map must have its script mode set to Lua for this to work as it relies on a built-in Lua function (Scenario > Map Options > Script Language). If you do end up changing this, I recommend making a back-up of your map first because they don't let you switch back to JASS once this is set.
  2. This will read the system time, i.e. from the operating system. Just note that users can set their computer's time to anything--so be wary of that if you design a map system around it.
  3. If this is a multiplayer map, each player may have different "current times". For example, if I am playing with someone in New York, my time would be "2:41 PM" whereas their time would be "5:41 PM". Make sure you keep this in mind if you do any conditional logic based off it, or else players might get disconnected! For example, if you decided that you would spawn a unit at midnight--then that would likely lead to a disconnect as the unit would only be created for certain players and not others (depending on their clock), and then the game engine would detect the discrepancy and disconnect the game (desync). If you do want to do something like this, you'll probably want to use the map host's time and sync that to the other players.
The simplest example is this:
Lua:
print(os.date("\37H:\37M:\37S")) -- e.g. 14:35:10
...which will display the system time in the HH:MM:SS format (24-hour time). \37 is just the % symbol, since the editor seems to have that reserved.

Or if you are using GUI, you could make a string variable "CurrentTime" and just do something like:
  • Custom script: udg_CurrentTime = os.date("\37H:\37M:\37S")
I've attached a sample map below if you want to play around with it. Good luck!
 

Attachments

  • SystemClock.png
    SystemClock.png
    319.2 KB · Views: 6
  • ClockTest.w3m
    9.5 KB · Views: 2
Top