• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Order Tracking Submission

Status
Not open for further replies.
Level 7
Joined
Apr 17, 2017
Messages
316
JASS:
library OrderTrack initializer init


public function actions takes nothing returns nothing
   local integer i
   local string name
   local string order2str
   local string obj
   set i = GetIssuedOrderId()
   set name = GetUnitName(GetTriggerUnit())
   set order2str = OrderId2String(i)
   set obj = GetObjectName(i)
   call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i)+"  "+"Order2String:"+" "+order2str+"  "+"Object Name:"+" "+obj)
endfunction

public function init takes nothing returns nothing
   local trigger t
   set t = CreateTrigger()
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
   call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
   call TriggerAddAction(t, function actions)
   set t = null
endfunction
endlibrary
 

Attachments

  • Order Track - Submission.w3m
    18.4 KB · Views: 63
Level 7
Joined
Apr 17, 2017
Messages
316
JASS:
library OrderTrack initializer init


public function actions takes nothing returns nothing
    local integer i
    local string name
    local string order2str
    local string obj
    set i = GetIssuedOrderId()
    set name = GetUnitName(GetTriggerUnit())
    set order2str = OrderId2String(i)
    set obj = GetObjectName(i)
    if StringLength(obj) > 0 then
       call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i)+"  "+"Order2String:"+" "+order2str+"  "+"Object Name:"+" "+obj)       
   else
       call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i)+"  "+"Order2String:"+" "+order2str)
   endif
endfunction

public function init takes nothing returns nothing
    local trigger t
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
    call TriggerAddAction(t, function actions)
    set t = null
endfunction
endlibrary

Here is the final one as you suggested.
 
Level 7
Joined
Apr 17, 2017
Messages
316
Have you looked at the output? ;p The if statement with string condition does not look right to me.
Oh I forgot about the order2string thingie.
JASS:
library OrderTrack initializer init


public function actions takes nothing returns nothing
    local integer i
    local string name
    local string order2str
    local string obj
    set i = GetIssuedOrderId()
    set name = GetUnitName(GetTriggerUnit())
    set order2str = OrderId2String(i)
    set obj = GetObjectName(i)
   if StringLength(order2str) > 0 then
       if StringLength(obj) > 0 then
          call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i)+"  "+"Order2String:"+" "+order2str+"  "+"Object Name:"+" "+obj)
       elseif StringLength(obj) == 0 then
           call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i)+"  "+"Order2String:"+" "+order2str)
       endif
   endif
   if StringLength(order2str) == 0 then
       if StringLength(obj) > 0 then
           call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i)+"  "+"Object Name:"+" "+obj)
       elseif StringLength(obj) == 0 then
           call BJDebugMsg("Name:"+" "+name+"  "+"Order id:"+" "+I2S(i))
       endif
   endif
endfunction

public function init takes nothing returns nothing
    local trigger t
    set t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER)
    call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_ISSUED_UNIT_ORDER)
    call TriggerAddAction(t, function actions)
    set t = null
endfunction
endlibrary
 
I meant that the ObjectName of an invalid object does not return null/empty but "Default string", so its length is > 0, that's why I asked if it was tested. ;p Anyways, it's fine

edit: nothing very serious, but I just remembered that with using

function OrderId2StringBJ takes integer orderId returns string

instead of pure

constant native OrderId2String takes integer orderId returns string

one could also catch train orders with it.
 
Status
Not open for further replies.
Top