Counting unit life span

Status
Not open for further replies.
Level 2
Joined
Jun 1, 2022
Messages
5
Hey guys! I'm completely new here - diving head first in map development. I have some experience with coding.
However, I would like some help creating a unit that runs through the players' mazes (It's a team-based TD). When the creature reaches the end it dies without subtracting a life and a message pops up saying how long it took the creature to complete the maze.


Kind regards
Kammerat1
 

Uncle

Warcraft Moderator
Level 69
Joined
Aug 10, 2018
Messages
7,272
So you need a Timer and a way to link the Timer to the Unit. This can be done using a Hashtable in Jass/GUI as well as a table in Lua.

There's also many resources to help make this process easier, such as TimerUtils for Jass.

I went with the Hashtable route and attached a map that's using both GUI + Jass. I use these two functions:
TimerGetElapsed()
TimerGetRemaining()

I found that TimerGetElapsed() does some rounding to the elapsed time so it isn't as precise where as TimerGetRemaining() gets you the exact time or at least what appears to be the exact time.

These functions among some others that I use are only accessible via code (Jass/Lua). Luckily, GUI has the Custom Script action which allows us to write code in our GUI triggers. This allowed me to use functions that are only available in Jass inside of a GUI trigger.
 

Attachments

  • Time Taken.w3m
    18.1 KB · Views: 7
Last edited:
Level 2
Joined
Jun 1, 2022
Messages
5
So you need a Timer and a way to link the Timer to the Unit. This can be done using a Hashtable in Jass/GUI as well as a table in Lua.

There's also many resources to help make this process easier, such as TimerUtils for Jass.

I attached a map that's using both GUI + Jass which has 2 examples using these functions:
TimerGetElapsed()
TimerGetRemaining()

I found that TimerGetElapsed() does some rounding to the elapsed time so it isn't as precise where as TimerGetRemaining() gets you the exact time or at least what appears to be the exact time.

These functions among some others that I use are only accessible via code (Jass/Lua). Luckily, GUI has the Custom Script action which allows us to write code in our GUI triggers in order to create a hybrid style of GUI + code.
Thanks a lot, Uncle! I'll take a look.
 
Status
Not open for further replies.
Top