- Joined
- Sep 8, 2004
- Messages
- 98
I put in some test triggers to see if it was working, but for some reason it isn't storing the real.
First I put in this line to test to see if the X and Y of the unit wasn't working right.:
into the SetTargLoc trigger, and it displays the unit's X and Y fine.
I also put in this line to test to see if it was storing it right.
Only it just displays 0.000 for both the X and Y every time I select the unit.
Here are my triggers.
This is the auto-reorder trigger that's supposed to constantly order a unit to it's destination.
This is the SetTargLoc trigger. It runs, but It doesn't seem to store the reals.
This is the test trigger to test storing of the X and Ys.
This is what is in my map script:
Anyone know why storing reals isn't working?
First I put in this line to test to see if the X and Y of the unit wasn't working right.:
Code:
call DisplayTextToPlayer(Player(0),0,0,"X: " + R2S(GetUnitX(u)) + " Y: " + R2S(GetUnitY(u)))
I also put in this line to test to see if it was storing it right.
Code:
call DisplayTextToPlayer(Player(0),0,0,"X: " + R2S(GetStoredReal(udg_ordercache,I2S(H2I(u)),"X")) + " Y: " + R2S(GetStoredReal(udg_ordercache,I2S(H2I(u)),"Y")))
Only it just displays 0.000 for both the X and Y every time I select the unit.
Here are my triggers.
This is the auto-reorder trigger that's supposed to constantly order a unit to it's destination.
Code:
function AutoReorderUnits takes nothing returns nothing
local group tempgroup = GetUnitsOfPlayerMatching(Player(11), null)
local unit TEMP_Unit
loop
set TEMP_Unit = FirstOfGroup(tempgroup)
exitwhen TEMP_Unit == null
if GetOwningPlayer(TEMP_Unit) != Player(11) then
call GroupRemoveUnit(tempgroup,TEMP_Unit)
endif
endloop
loop
set TEMP_Unit = FirstOfGroup(tempgroup)
exitwhen TEMP_Unit == null
call IssuePointOrder(TEMP_Unit,"attack",GetStoredReal(udg_ordercache,I2S(H2I(TEMP_Unit)),"X"),GetStoredReal(udg_ordercache,I2S(H2I(TEMP_Unit)),"Y"))
call GroupRemoveUnit(tempgroup,TEMP_Unit)
endloop
call DestroyGroup(tempgroup)
set tempgroup = null
endfunction
Code:
function InitTrig_AutoReorderUnits takes nothing returns nothing
set gg_trg_AutoReorderUnits = CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_AutoReorderUnits,2.00,true)
call TriggerAddAction(gg_trg_AutoReorderUnits,function AutoReorderUnits)
endfunction
This is the SetTargLoc trigger. It runs, but It doesn't seem to store the reals.
Code:
function STL_Conditions takes nothing returns boolean
return (GetOwningPlayer(GetOrderedUnit()) == Player(11) and GetIssuedOrderId() == String2OrderIdBJ("attack")) == true
endfunction
function SetTargLoc takes nothing returns nothing
local unit u = GetOrderedUnit()
local string id = I2S(H2I(u))
call StoreReal(udg_ordercache,id, "X",GetUnitX(u))
call StoreReal(udg_ordercache,id, "Y",GetUnitY(u))
call DisplayTextToPlayer(Player(0),0,0,"X: " + R2S(GetUnitX(u)) + " Y: " + R2S(GetUnitY(u)))
set u = null
endfunction
function InitTrig_SetTargLoc takes nothing returns nothing
set gg_trg_SetTargLoc = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( gg_trg_SetTargLoc, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerAddAction( gg_trg_SetTargLoc, function SetTargLoc )
call TriggerAddCondition(gg_trg_SetTargLoc,Condition(function STL_Conditions))
endfunction
This is the test trigger to test storing of the X and Ys.
Code:
Test Trigs
Events
Player - Player 1 (Red) Selects a unit
Conditions
(Owner of (Triggering unit)) Equal to Player 12 (Brown)
Actions
Custom script: call testH2I(GetTriggerUnit())
This is what is in my map script:
Code:
function H2I takes handle h returns integer
return h
return 0
endfunction
function testH2I takes unit u returns nothing
call DisplayTextToPlayer(Player(0),0,0,"X: " + R2S(GetStoredReal(udg_ordercache,I2S(H2I(u)),"X")) + " Y: " + R2S(GetStoredReal(udg_ordercache,I2S(H2I(u)),"Y")))
endfunction
Anyone know why storing reals isn't working?