2: It's really weird because I corrected the mistake and it worked... (The mistake wasn't about scope.) Added (2009-07-20, 3:14 Pm)
---------------------------------------------
Sorry for the double post. I made the same indexing system as you to understand more how it works and I would like to know if it is ok. (I changed something)
Code
library thecheeselover
// Thanks to Fireeye
struct CheeseStruct
// init var
unit caster = null
real CheeseTLeft = 0.00
static method create takes nothing returns CheeseStruct
// set var
local CheeseStruct cs = CheeseStruct.allocate()
set cs.caster = null
set cs.CheeseTLeft = 0.00
return cs
endmethod
method onDestroy takes nothing returns nothing
// end var
local CheeseStruct cs = CheeseStruct.allocate()
set cs.caster = null
set cs.CheeseTLeft = 0.00
endmethod
endstruct
globals
private CheeseStruct array GlobalCheese
private integer CStruct = 0
private timer CheeseTimer = CreateTimer()
endglobals
private function CheeseEnd takes nothing returns nothing
local CheeseStruct cs
local integer i = 0
loop
exitwhen i == CStruct
set cs = GlobalCheese[i]
if cs.CheeseTLeft < 0.03 then
call cs.destroy()
set CStruct = CStruct - 1
set GlobalCheese[i] = GlobalCheese[CStruct]
else
set i = i - 1
endif
endloop
endfunction
function CheeseFunc takes nothing returns nothing
local CheeseStruct cs = CheeseStruct.create()
set GlobalCheese[CStruct] = cs
set CStruct = CStruct + 1
set cs.CheeseTLeft = 0.04
if cs.CheeseTLeft < 0.03 then
call TimerStart( CheeseTimer, 0.03, TRUE, function CheeseEnd)
endif
endfunction
endlibrary
It is not a spell indexing system but a library indexing system. I have another question too: How can we use the same cs. if we use 2 functions for the spell.
Exemple:
Struct CheeseStruct
timer t = CreateTimer()
endstruct
function test takes nothing returns nothing
?????
call DestroyTimer(cs.t)
endfunction
function testinit takes nothing returns nothing
local CheeseStruct cs = CheeseStruct.create()
call TimerStart( cs.t, 2, TRUE, function test)
endfunction
Can you awnser me plz!
Added (2009-08-03, 4:07 Am)
---------------------------------------------
I have another questio.
What is the maximum array of a struct variable?