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!
It is possible in Lua (via os.date()), but there are a couple of important notes:
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.
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.
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:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.