Whats "String2OrderIdBJ" used for?

Dois

New Member
Reaction score
1
String2OrderIdBJ()

JASS:
function String2OrderIdBJ takes string orderIdString returns integer
    local integer orderId
    
    // Check to see if it's a generic order.
    set orderId = OrderId(orderIdString)
    if (orderId != 0) then
        return orderId
    endif

    // Check to see if it's a (train) unit order.
    set orderId = UnitId(orderIdString)
    if (orderId != 0) then
        return orderId
    endif

    // Unrecognized - return 0
    return 0
endfunction
JassCraft says that...

But whats the use of it since theres
JASS:
constant native OrderId                     takes string  orderIdString     returns integer


Do I need to worry about something if I replace "String2OrderIdBJ" with "OrderId"?

Either way it will return the OrderId... if (orderId == 0) won't it just return 0 anyway?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> Either way it will return the OrderId

It might return the result from calling "UnitId".
Though, as the comment says, that's for train orders only.
 

Dois

New Member
Reaction score
1
so should I use orderID? or that string2ASDASD thing?

or i guess use OrderID when the Event isn't train unit?
 

Dois

New Member
Reaction score
1
ok but what happens if the event is "a unit is trained" or whatever thatll make me need the complicated one?
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Let's put it like this:
You are supposed to know what events your trigger is waiting for...

If you go with the rather generic "a unit is issued an order with no target"... that might just be any order, and, maybe, OrderId won't return a useful result.
As you can see from the "bigger" function, if it returns 0...
 

Dois

New Member
Reaction score
1
ok nvm ive just realized ive asked the question wrongly... it should be more like "when do i need to use the complicated one" but i get it now anyway...

thanks again acehart...
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top