- Joined
- Jul 18, 2010
- Messages
- 2,377
JASS:
function UnitOrder takes nothing returns nothing
local integer orderId = GetIssuedOrderId()
local string orderString = OrderId2String(orderId)
local string targetName
// Is Their a Target?
if ( GetOrderTarget() != null ) then
//Get Targets Name according to its type.
if (GetOrderTargetUnit() != null) then
set targetName = GetUnitName(GetOrderTargetUnit())
else
if GetOrderTargetItem() != null then
set targetName = GetItemName(GetOrderTargetItem())
else
if ( GetOrderTargetDestructable() != null) then
set targetName = GetDestructableName(GetOrderTargetDestructable())
endif
endif
endif
endif
// If no Order-String Avaible try to get Objects-Name
if orderString == null then
set orderString = GetObjectName(orderId)
// Replace Default string with " "
if orderString == "Default string" then
set orderString = " "
endif
endif
// Print "-> targetName" ?
if ( GetOrderTarget() != null ) then
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 8.00, GetUnitName(GetTriggerUnit()) + " - " + orderString +" / "+ I2S(orderId) + " -> " + targetName )
else
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0, 8.00, GetUnitName(GetTriggerUnit()) + " - " + orderString +" / "+ I2S(orderId) )
endif
endfunction
//===========================================================================
function InitTrig_UnitOrder takes nothing returns nothing
local trigger tr = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER )
call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER )
call TriggerRegisterAnyUnitEventBJ( tr, EVENT_PLAYER_UNIT_ISSUED_ORDER )
call TriggerAddAction( tr, function UnitOrder )
set tr = null
endfunction
I wonder if their is a getWidgetsID, would simplefy my first if else block.
Couldn't find one in the jass api.