• 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.
  • 💡 We're thrilled to announce that our upcoming texturing contest is in the works, and we're eager to hear your suggestions! Please take this opportunity to share your ideas in this theme discussion thread for the Texturing Contest #34!
  • 🏆 Hive's 7th HD Modeling Contest: Icecrown Creature is now open! The frozen wastes of Icecrown are home to some of Azeroth’s most terrifying and resilient creatures. For this contest, your challenge is to design and model a HD 3D monster that embodies the cold, undead, and sinister essence of Icecrown! 📅 Submissions close on April 13, 2025. Don't miss this opportunity to let your creativity shine! Enter now and show us your frozen masterpiece! 🔗 Click here to enter!

How get the information of an item just with the type-id? (Or at least help me with the function)

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,927
Hello, I'm creating a save-load system, also a menu for that, it shows what items have, for the charged items I wanna also show how many charges have, the thing is I don't know how to get if a item is charged only with the type-id so I opted to create the item for get that information, the thing is (I just notice it now) where I create the item is in a if player == GetLocalPlayer() then block causing a desync, and it would be a mess put it outside, unless you have a better solution, this is the function:
Lua:
-- This function always should be in a "if player == GetLocalPlayer() then" block
local function UpdateInformation()
    local data = PlayerDatas[LocalPlayer][Pressed[LocalPlayer]]
    if data then
        BlzFrameSetText(TooltipName, "|cffff6600Information|r")
        BlzFrameSetText(TooltipGold, "|cffFFCC00Gold: |r" .. data.gold)
        BlzFrameSetText(TooltipLumber, "|cff20bc20Lumber: |r" .. data.lumber)
        for i = 1, #data.digimons do
            local s = ""
            local inv = data.inventories[i]
            for j = 0, 5 do
                if inv.items[j] then
                    local m = CreateItem(inv.items[j], 0, 0) -- I don't know how to get the name and the class with only the type id
                    s = s .. GetItemName(m)
                    if GetItemType(m) == ITEM_TYPE_CHARGED then
                        s = s .. "(" .. inv.charges[j] .. ")"
                    end
                    RemoveItem(m)
                    if j ~= 5 then
                        s = s .. ", "
                    end
                end
            end
            BlzFrameSetText(TooltipDigimonItemsT[i-1], "|cff00ffffItems: |r" .. s)
            BlzFrameSetTexture(TooltipDigimonIconT[i-1], BlzGetAbilityIcon(data.digimons[i]), 0, true)
            BlzFrameSetText(TextTooltipLevelT[i-1], "|cffFFCC00Level " .. data.levels[i] .. "|r")
        end
    else
        BlzFrameSetText(TooltipName, "|cffff6600Empty|r")
        BlzFrameSetText(TooltipGold, "|cffFFCC00Gold:|r")
        BlzFrameSetText(TooltipLumber, "|cff20bc20Lumber:|r")
        for i = 0, 5 do
            BlzFrameSetText(TooltipDigimonItemsT[i], "|cff00ffffItems:|r")
            BlzFrameSetTexture(TooltipDigimonIconT[i], "ReplaceableTextures\\CommandButtons\\BTNCancel.blp", 0, true)
            BlzFrameSetText(TextTooltipLevelT[i], "|cffFFCC00Level 0|r")
        end
    end
end
 
Last edited:

Uncle

Warcraft Moderator
Level 72
Joined
Aug 10, 2018
Messages
7,754
Like what Avahor said, you can preload all of the items at the start of the game and store information about them using tables. Something like this:
Lua:
itemType = {
    classification = {},
    baseCharges = {},
    maxCharges = {}
}

function ItemTypeAdd(id)
    local m = CreateItem(id, 0, 0)
    itemType[id].classification = GetItemType(m)
    itemType[id].baseCharges = GetItemBaseCharges(m) -- not the real function
    itemType[id].maxCharges = GetItemMaxCharges(m)   -- not the real function
    RemoveItem(m)
end

function ItemTypeInit()
    ItemTypeAdd(FourCC('bspd')) -- boots of speed
    ItemTypeAdd(FourCC('wlsd')) -- wand of lightning shield
    -- etc
end
 
Status
Not open for further replies.
Top