Ocre
Now the system has been changed, the last version was bad i know, but i think this one is much better, just give feedback.
Changes:
3.14
Now uses 1 trigger, and conditions to evaluate, it must be faster now
1.00
- Now its a global timer use system, but with some extras against some others already made.
Features:
- No H2I
- Allows you to specify period
- Easy to use ( Start / GetData / Stop )
- Uses only 1 trigger to evaluate the conditions
Important:
- Remember when you are done with your function use return true, if not use return false
Functions:
Now the system has been changed, the last version was bad i know, but i think this one is much better, just give feedback.
Changes:
3.14
Now uses 1 trigger, and conditions to evaluate, it must be faster now
1.00
- Now its a global timer use system, but with some extras against some others already made.
Features:
- No H2I
- Allows you to specify period
- Easy to use ( Start / GetData / Stop )
- Uses only 1 trigger to evaluate the conditions
Important:
- Remember when you are done with your function use return true, if not use return false
Functions:
JASS:
function Ocre_Start takes function FUNC, integer DATA, real PERIOD returns nothing
JASS:
function Ocre_GetData takes nothing returns integer
JASS:
library Ocre initializer init
globals
//========================================================================
public constant real PERIOD = 0.025
//========================================================================
private timer TIMER
private integer RUN = 0
public real array periodz
public real array maxperiodz
public integer Data
public integer Index
private triggercondition array TC
private conditionfunc array CF
private trigger Trig
private integer array DATAS
endglobals
//==================================================================================================================
// Timerz System
//==================================================================================================================
public function GetData takes nothing returns integer // GetValue func
return Data
endfunction
public function GetIndex takes nothing returns integer // GetIndex func
return Index
endfunction
private function onLoop takes nothing returns nothing
local integer count = RUN
local boolean B
loop
exitwhen count <= 0
set count:periodz = count:periodz-PERIOD
set Data = count:DATAS
set Index = count
if count:periodz <= 0 then
set count:periodz = count:maxperiodz
set count:TC = TriggerAddCondition(Trig, count:CF)
set B = TriggerEvaluate(Trig)
call TriggerRemoveCondition(Trig, count:TC)
if B == true then
set count:CF = RUN:CF
set count:TC = null
set count:DATAS = RUN:DATAS
set count:periodz = RUN:periodz
set count:maxperiodz = RUN:maxperiodz
set RUN = RUN-1
endif
endif
set count = count-1
endloop
endfunction
public function Start takes code func, integer data, real period returns integer
set RUN = RUN + 1
set RUN:CF = Condition(func)
set RUN:DATAS = data
set RUN:periodz= period
set RUN:maxperiodz = period
return RUN
endfunction
private function init takes nothing returns nothing
set Trig = CreateTrigger()
set TIMER = CreateTimer()
call TimerStart( TIMER, PERIOD, true, function onLoop)
endfunction
endlibrary
Last edited: