| 01-01-2009, 03:42 PM | #1 |
Sorry for asking this, but I want to remove all waits on my map and substitute by timers, but I can't find a tutorial explaining how can I use a timer and don't loose my variables. What tutorial do you suggest? Thanks! |
| 01-01-2009, 05:42 PM | #2 |
If you want to use the easy solution, use PolledWait (Wait (Game-Time)). Or, you use the not leaking PolledWait2: JASS:function PolledWait2 takes real duration returns nothing local timer t = CreateTimer() local real remaining call TimerStart(t, duration, false, null) loop set remaining = TimerGetRemaining(t) exitwhen(remaining <= 0) if(remaining > .35)then call TriggerSleepAction(.1 * remaining) else call TriggerSleepAction(-1) endif endloop call PauseTimer(t) call DestroyTimer(t) set t = null endfunction Copy and paste that in the Custom Script section ( click map icon / name in trigger editor ). Now you can do waits with: wait 5.5 seconds: Custom Script: call PolledWait2( 5.5 ) |
| 01-01-2009, 05:58 PM | #3 |
http://wc3campaigns.net/showthread.php?t=89072 This is in pure JASS, and its outdated. But you should understand timers after reading it. |
| 01-01-2009, 08:12 PM | #4 | |
Quote:
Also, I wanna know how I attach structs to timers and them remove all leaks correctly. Thanks ^^ |
| 01-01-2009, 08:19 PM | #5 | ||
Quote:
No, because it is (internally) using a timer to do the wait. It is safe to use PolledWait/PolledWait2! Quote:
It will be pointless to explain, unless you know JASS. If you do; get JassNewGenPack, read up on vJASS. There are plenty of tutorials on this. |
| 01-01-2009, 08:25 PM | #6 | |
Quote:
I wanna know where is a tuto that explain that! (Yes, I already tried searching, but most tutorials explain little about that. |
| 01-01-2009, 08:29 PM | #7 | |
Quote:
What about Vexorian's tutorial on vJASS spell making, then? Or, if you'd rather look at a simple example... Example code:// TimerUtils is available in the scripts-section // Functions provided by TimerUtils are highlighted library whatever needs TimerUtils private struct Data unit theOneWeWillGiveToNeutralPlayer endstruct private function TimerExpires takes nothing returns nothing // Ask TimerUtils for the Data-object associated with the timer local Data d=GetTimerData(GetExpiredTimer()) // Retrieve the unit from the Data-object, and give it to player 13 call SetUnitOwner(d.theOneWeWillGiveToNeutralPlayer,Player(12)) // Clean up the data object call d.destroy() // Give the timer back to TimerUtils-system. // This will pause it, and "clean it up". call ReleaseTimer(GetExpiredTimer()) endfunction private function StartHere takes nothing returns nothing // Get a timer from TimerUtils-system local timer t=NewTimer() // Data is the struct we defined earier in this script // Now we're creating a Data-object local Data d=Data.create() // Store the spell target unit in the data-object set d.theOneWeWillGiveToNeutralPlayer=GetSpellTargetUnit() // Let TimerUtils associate the Data-object with the timer. call SetTImerData(t,d) call TimerStart(t,1.0,false,function TimerExpires) endfunction endlibrary |
| 01-02-2009, 12:51 AM | #8 | |
Quote:
|
| 01-02-2009, 11:14 AM | #9 |
use my timing system :( |
