| 07-29-2007, 12:21 AM | #1 |
I'm trying to avoid creating/destroying new timers every time this function runs, so I'm just pausing it, telling it to run a null function on a 0.00 second callback, and then pausing it again in order to clear the time remaining. However, this function will display the remaining time as 0.00 but still display the "Un-Slept" message... Why? Is it because of Wc3's floating point and the time remaining is really something like 0.000001? JASS:function CSF_UnSlept takes nothing returns boolean local unit U = GetTriggerUnit() local string UTable = GetAttachmentTable(U) local timer T = GetTableTimer(UTable, "CSF Unit Timer") call BJDebugMsg(R2S(TimerGetRemaining(T))) if TimerGetRemaining(T) > 0.00 and GetUnitTypeId(GetEventDamageSource()) != CSF_DummyUnitId() then call SetTableBoolean(UTable, "CSF Short Duration", false) call PauseTimer(T) call TimerStart(T, 0.00, false, null) call PauseTimer(T) call BJDebugMsg("Un-slept") call ExecuteFunc("CSF_UnSleptExecute") endif set U = null set T = null return false endfunction |
| 07-29-2007, 12:31 AM | #2 |
try display time remaining or maybe the timer has to run if its called. |
| 07-29-2007, 12:32 AM | #3 | ||
Quote:
Quote:
|
| 07-29-2007, 12:39 AM | #4 |
i think that the timer has to run once and thus time remaining is forced over 0 |
| 07-29-2007, 01:57 AM | #5 |
Woah. Weird, funky bug! If you pause the timer before calling a TimerStart(), it keeps its previous elapsed time even after it expires on the new function. If you do not pause it, the new elapsed time becomes 0. JASS:function CSF_UnsleepDummyFunc takes nothing returns nothing call BJDebugMsg("Expired") call PauseTimer(GetExpiredTimer()) endfunction function CSF_UnSleptExecute takes nothing returns nothing call BJDebugMsg("Attacker: "+GetUnitName(GetEventDamageSource())+"; Damage: "+R2S(GetEventDamage())) endfunction function CSF_UnSlept takes nothing returns boolean local unit U = GetTriggerUnit() local string UTable = GetAttachmentTable(U) local timer T = GetTableTimer(UTable, "CSF Unit Timer") call BJDebugMsg(R2S(TimerGetRemaining(T))) if TimerGetRemaining(T) > 0.00 and GetUnitTypeId(GetEventDamageSource()) != CSF_DummyUnitId() then call SetTableBoolean(UTable, "CSF Short Duration", false) // call PauseTimer(T) call TimerStart(T, 0.01, false, function CSF_UnsleepDummyFunc) call BJDebugMsg("Un-slept") call ExecuteFunc("CSF_UnSleptExecute") endif set U = null set T = null return false endfunction |
| 07-29-2007, 02:22 AM | #6 | |
this is soo damn easy... call timer 0.00 store timer remaining and declare it as ZERO Quote:
after it if TimerGetRemaining(T) > 0.00 Ex_ZERO_OF_TIMER |
| 07-29-2007, 02:47 AM | #7 |
I really don't understand what you're saying. |
