dudeim
New Member
- Reaction score
- 22
Hey,
I'm having a bit of a problem with creating a custom create method the way I want to.
Quick example of how I want to do it (may not even run and could be a few errors in it):
This is just an example of how I want to do it
Basicly I want to attach values to units and I want to be able to change them anytime anywhere and keep the same values then.
So how do I do that?
Thanks!
I'm having a bit of a problem with creating a custom create method the way I want to.
Quick example of how I want to do it (may not even run and could be a few errors in it):
JASS:
library a
struct Unit
integer value1
integer value2
unit U
//etc.. anything i need in here
static method create takes unit uc returns Unit
local Unit u = Unit.allocate()
set u.U = uc
set u.value1 = 15 //just an example
set u.value2 = 20
return u
endmethod
endstruct
endlibrary
//ok this is done but now I have a trigger which fires when I press esc
function Trig_Untitled_Trigger_002_Actions takes nothing returns nothing
local Unit u = Unit(//say we input a unit A in here the unit is a preset and is thereby in this case always the same)
//now if I do this
call BJDebugMsg("Value1: " +I2S(u.value1)) //this always displays 15
call BJDebugMsg("Value2: " +I2S(u.value2)) //this always displays 20
set u.value1 = 35
set u.value2 = 120
call BJDebugMsg("Value1: " +I2S(u.value1)) //this always displays 35
call BJDebugMsg("Value2: " +I2S(u.value2)) //this always displays 120
//now I want to keep the value1 and value2 the same if I change them somewhere for the particular unit
//how can I do that?
endfunction
//===========================================================================
function InitTrig_Untitled_Trigger_002 takes nothing returns nothing
set gg_trg_Untitled_Trigger_002 = CreateTrigger( )
call TriggerRegisterPlayerEventEndCinematic( gg_trg_Untitled_Trigger_002, Player(0) )
call TriggerAddAction( gg_trg_Untitled_Trigger_002, function Trig_Untitled_Trigger_002_Actions )
endfunction
This is just an example of how I want to do it
Basicly I want to attach values to units and I want to be able to change them anytime anywhere and keep the same values then.
So how do I do that?
Thanks!