• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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: 59
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