Byrth / Lua-Byrth

Lua Addons and Scripts
3 stars 2 forks source link

not an issue just answering a question for you (even if you have figured this out) #435

Closed smd111 closed 6 years ago

smd111 commented 7 years ago

i once saw that you needed to know how to tell when the server finished updating the users inventory (all storage bags) (using the latest gearswap code its this)

parse.i[0x01D] = function (data)
   --the item update is finished when this packet is sent
   --it is sent every time your items change
end
smd111 commented 7 years ago

this packet is received every time an item is changed --when an item is moved from one bag to another --when an item's count changes --when an item like an xp ring is ready to use --when an item like an xp ring's timer is done --every time gear is equipped or unequipped

Byrth commented 7 years ago

Yeah, I needed something that tells me SE is done updating items.

smd111 commented 7 years ago

i thought you did

and this is the code i added to my gearswap to do updates for items etc. so it keeps the item exdata up to date in the gearswap[bag][item] table

function gearswap.refresh_item_list(itemlist)
    retarr = gearswap.make_user_table()
    for i,v in pairs(itemlist) do
        if type(v) == 'table' and v.id and v.id ~= 0 then
            if gearswap.res.items[v.id] and gearswap.res.items[v.id][language] and not retarr[gearswap.res.items[v.id][language]] then
                retarr[gearswap.res.items[v.id][language]] = {id=v.id,count=v.count,shortname=gearswap.res.items[v.id][language]:lower(),extdata = gearswap.extdata.decode(v)}
                if gearswap.res.items[v.id][language..'_log'] and gearswap.res.items[v.id][language..'_log']:lower() ~= gearswap.res.items[v.id][language]:lower() then
                    retarr[gearswap.res.items[v.id][language]].longname = gearswap.res.items[v.id][language..'_log']:lower()
                    retarr[gearswap.res.items[v.id][language..'_log']] = retarr[gearswap.res.items[v.id][language]]
                end
            elseif gearswap.res.items[v.id] and gearswap.res.items[v.id][language] then
                retarr[gearswap.res.items[v.id][language]].count = retarr[gearswap.res.items[v.id][language]].count + v.count
            end
        end
    end
    return retarr
end

gearswap.parse.i[0x01D] = function (data)
    gearswap.refresh_globals()
    if not loaded then
        loaded = true
        include("SMDinclude/includes/Include.lua")
        if auto_ring and check_ring_buff() then
            schedule_xpcp_ring()
        end
    end
end
if not loaded then
    mf = {}
    return
end
smd111 commented 7 years ago

oh ya just remember that if any item is changed/moved/updated/equipped/unequipped/etc. for any reason it runs this packet

thats why my above code is the way it is --so it wont reload my include every time that packet is sent --see here:https://github.com/smd111/Gearswap/blob/master/SMDinclude/includes/Include.lua

smd111 commented 7 years ago

after some testing i think this is what it needs to be

parse.i[0x01D] = function (data)
    for i,bag in pairs(res.bags) do
        local bag_name = to_windower_bag_api(bag.en)
        if items[bag_name] then
            player[bag_name] = refresh_item_list(items[bag_name])
        end
    end
end
smd111 commented 7 years ago

@Byrth here is a modded gearswap/packet_parsing.lua for you to check out http://pastebin.com/B9n3Vhn4

Changes 1) packet 0x063 (in file above lines 374-479) you ran the loop "for n,new in pairs(newbuffs) do" three time i was able to shorten it to one time

2) added Automation skill levels to player.skills (in file above lines 249-255) Automation skills should only show in player.skills when your job is PUP(tho i could be wrong) --this packet also containg all pet stat updates

3) added packet 0x01D info (in file above lines 138-147) i left this packed commented out so as to not get triggered until your ready to use it --remember that this packet tells you any time an item's is modified ---i.e. Equipped/Unequipped/Count change(stack-able items)/Used(item is used up)/Added to any of your bags(like items gained from battle or bought from stores)/Moved from one bag to another/Exdata update(i.e. reuse timer finish/Use count change(like xp rings)/etc.)/basically any time SE changes any data that involves any item in any or your bags

--yes i know i could do a pull request but all the one i have done seam to be ignored or never implemented and this takes less time to do then that

Byrth commented 6 years ago

Going to close this as I don't really need this for GearSwap.