Is there a shorter way to convert itemtype to string (name of item)?

afisakov

You can change this now in User CP.
Reaction score
37
What I am looking for is some sort of native or short function to take an item rawcode and convert it into a chat string.
GetItemName doesn't work very well since it relies an item, not itemtype, and I cannot use GetLastcreateditem since it doesn't seem compatible with "call UnitAddItemById(u,resultid)"
the best I can come up with is below, but it doesn't seem a very elegant solution
Code:
GetItemName(GetItemOfTypeFromUnitBJ(GetTriggerUnit(),resultid))

P.S. resultid is a local integer that holds item rawcode, passed on from another trigger
yes the item does get added properly

Thanks in advance for your help
 

G_Freak45

New Member
Reaction score
0
Also, if you were to make a simple function that did this itself vexorians (if memory serves) map optimizer will inline it. here is a version of what you were doing with no BJ's in it, just replace that call with UnitItemName.

Code:
function UnitItemName takes unit u, integer itemId returns string
    local integer x = 0
    local item indexItem
 
    loop
        set indexItem = UnitItemInSlot(u, x)
        exitwhen (indexItem != null) and (GetItemTypeId(indexItem) == itemId)
 
        set index = x + 1
        exitwhen x >= bj_MAX_INVENTORY
    endloop
 
    if indexItem == null then
        return "Some Error Message saying the item doesnt exist"
    endif
 
    return GetItemName(indexItem, itemId)
endfunction

forgive me if there are errors, i typed this into the browser
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top