HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Elapsed Time Trigger

01-03-2006, 06:43 AM#1
Johnthebaker
I really need help on making an elapsed time trigger. I would like it to be on a leaderboard starting from 00:00:00 and rising, thanks.

moderator edit: removed colour

01-03-2006, 07:49 AM#2
Anitarf
First of all, don't use colour in your posts like that. Read the forum rules and FAQs.

As for your problem, I'm not entirely sure I understand correctly, do you want a board to display the current game-time? You can use a leaderboard or a multiboard for that. Either way, you need a periodic trigger that will change the text displayed there every second. When figuring out what to display, you use integer variables to store the elapsed seconds/minutes, and increase those every second with your periodic trigger as well.
01-03-2006, 09:07 AM#3
Johnthebaker
i am a newbie to triggers and i just need the event-condition-actions only please
01-03-2006, 10:31 AM#4
Earth-Fury
no. giving it to you makes you learn nothing, telling you what to do and making you do it makes you learn. Anitarf has told you te way, now try to do it :) if you fail, then ask for more help.
01-03-2006, 09:26 PM#5
harel
You can try using a timer if a leadreboard is not that important (timer window looks a lot like leaderboard window).
01-03-2006, 09:30 PM#6
Earth-Fury
Quote:
Originally Posted by harel
You can try using a timer if a leadreboard is not that important (timer window looks a lot like leaderboard window).

sorry to burst tat buble, but timers count down not up.
01-04-2006, 02:08 AM#7
Johnthebaker
i made this, but it only counts the seconds, i need one that makes minutes and seconds



Untitled Trigger 008
Events
Map initialization
Conditions
Actions
Countdown Timer - Start Time as a Repeating timer that will expire in 10000.00 seconds

Untitled Trigger 009
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Multiboard - Create a multiboard with 2 columns and 2 rows, titled Elapsed Time
Multiboard - Show (Last created multiboard)
Multiboard - Change the title of (Last created multiboard) to (Elapsed Time: + (String((Integer((Elapsed time for Time))))))
01-04-2006, 05:58 AM#8
Anitarf
See, you're getting somewhere. However, using variables in this case seems easier than using timers. Also, you could just reuse the same multiboard rather than create a new one every time.

So, go to the variable editor (the yellow x icon at the top of the trigger editor) and create two integer variables there, one for seconds and one for minutes. Also, create a multiboard variables, so you'll just have to create one multiboard at the start of the map, store it to that variable and use the variable from there on.

Now, in your trigger that runs every second, simply increase the seconds variable by 1 (set seconds = seconds + 1). Then, with an if-then-else statement, check if the variable has reached 60 and if it has, reset it to 0 and increase the minutes variable by 1. Then, just display these two variables in your multiboard with a " : " between them.
01-05-2006, 04:09 PM#9
JeffreyQ
I would like to ask, if i put an IF statement in a periodic event, will it lag the game? especially for every 1 second"..?
01-05-2006, 04:32 PM#10
Earth-Fury
Quote:
Originally Posted by JeffreyQ
I would like to ask, if i put an IF statement in a periodic event, will it lag the game? especially for every 1 second"..?

no, not really. when you play a game like world of warcraft, theres atleast 10 if statements going off every secont. (usually more if you use a custom UI. and tats just the LUA code for the UI!)

now, if your using loops in a periodic event, you have to be more carefull. (its still fine to use them, but dont go crazy with it.)
01-05-2006, 05:24 PM#11
Azazel_
This is an example of what Anitarf may mean :

Code:
    set udg_Second = udg_Second + 1
    if ( udg_Second >= 60 ) then
        set udg_Second = 0
        set udg_Minute = udg_Minute + 1
    endif
    if ( udg_Minute >= 60 ) then
        set udg_Minute = 0
        set udg_Hour = udg_Hour + 1
    endif
    call MBSet( udg_SquadStatus,1,2,("Mission Time : " + udg_Clock[udg_Hour] + ":" + udg_Clock[udg_Minute] + ":" + udg_Clock[udg_Second]) )

Below is an illustration of how the timer looks like. The variable Clock is defined at initialisation using 2 loops, setting the values 0 to 9 as '01,02,03..,09', while the second loop sets the values 10 to 59 as '10,11,12,..,59'. This is not necessary and just a cosmetic step.

01-05-2006, 11:56 PM#12
Extrarius
Quote:
Originally Posted by Earth-Fury
no, not really. when you play a game like world of warcraft, theres atleast 10 if statements going off every secont. (usually more if you use a custom UI. and tats just the LUA code for the UI!)[...]
Of course, Lua is a highly optimized scripting language developed over many years by somebody with experience doing so, and Jass was an accident by Blizzard.

Despite the difference, though, you can still put quite a bit of code into a timer event without causing lag.
01-05-2006, 11:59 PM#13
Vexorian
Well simply enough, periodic events don't directly cause lag (unless you are using a 0 seconds one) their actions do, but a single if then else or even 100 won't be that hurtful (note that 100 as long as it is the only periodic event or it has kind of a big delay like 2 seconds.