- Joined
- Jan 9, 2005
- Messages
- 2,126
So I have this trigger I'm working on where a unit that's initially made unavailable for training is temporarily made available again, ordered to be trained, and made unavaible again. When I use variables, however, it doesn't work. I need to use the unit id directly, and I'd rather avoid hardcoding it.
It starts out like this
Then in another function I do this:
The above doesn't work. However, if I do this...
...it works correctly. I've checked and made sure the value of m remains the same so the array isn't the problem. UnitType is an integer array, and all functions and variables are used inside the same scope.
It starts out like this
JASS:
if GetUnitTypeId(TrainedUnit) == 'vsd1' then
set GoldCost[m] = 200
set LumberCost[m] = 0
set UnitType[m] = 'vsde'
endif
Then in another function I do this:
JASS:
call SetPlayerUnitAvailableBJ(UnitType[m], true, m.owner)
call IssueImmediateOrderById(m.dummy, UnitType[m])
call SetPlayerUnitAvailableBJ(UnitType[m], false, m.owner)
The above doesn't work. However, if I do this...
JASS:
call SetPlayerUnitAvailableBJ('vsde', true, m.owner)
call IssueImmediateOrderById(m.dummy, 'vsde')
call SetPlayerUnitAvailableBJ('vsde', false, m.owner)
...it works correctly. I've checked and made sure the value of m remains the same so the array isn't the problem. UnitType is an integer array, and all functions and variables are used inside the same scope.