You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
New Ammo Belts next_use_time incorrect in extdata? #1706
I think it's returning nil for .next_use_time, though I can't diagnose as much as I'd like as I don't own the items, so I may be wrong, trying to test through someone else, but they say:
function get_item_next_use(name)--returns time that you can use the item again
for _,n in pairs({"inventory","wardrobe","wardrobe2","wardrobe3","wardrobe4"}) do
local item = player[n][name]
if item then
local ex = extdata.decode(item)
if ex and ex.charges_remaining >= 1 then
return ex
end
end
end
end
if you want to know how many seconds you need to wait to use it again this is what you use os.time(os.date("!*t", get_item_next_use.next_use_time))-os.time()
it is accurate to +/- 2 seconds
Thanks for this and I'll check it out, but I use the code I mentioned for every usable item I've tried up till now the new ammo belts aren't working like everything else is, so I figured they've got an issue.
With your get_item_next_use function is also giving me a nil value, I'm not sure if I'm doing something wrong on that end, I just know the way I usually use works for most items, just not the new belts.
i recommend this (because sometimes you will get bad extdata with wrong names)
local ex = get_item_next_use('Warp Ring')
if ex then
add_to_chat(123,(os.time(os.date("!*t", ex.next_use_time))-os.time()))
else
add_to_chat(123,"ERROR: extdata for item does not exist")
end
if you want the best code you can try this
--put this at the top of your gearswap, it must be the first thing that gets loaded by gearswap as it overwrights one of gearswaps functions
function gearswap.refresh_item_list(itemlist)--gearswap item list generator
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) --last packet recived after items are fully updated
local cur_equip = table.reassign({},gearswap.items.equipment)
gearswap.player.equipment = gearswap.make_user_table()
table.reassign(gearswap.player.equipment,gearswap.to_names_set(cur_equip))
for i,bag in pairs(gearswap.res.bags) do
local bag_name = gearswap.to_windower_bag_api(bag.en)
if gearswap.items[bag_name] then gearswap.player[bag_name] = gearswap.refresh_item_list(gearswap.items[bag_name]) end
end
if not loaded then
loaded = true
add_to_chat(1,"Gearswap loaded")
end
end
--this can be placed anywhere
function get_item_next_use(name)--returns extdata of item if it has any
for _,n in pairs({"inventory","wardrobe","wardrobe2","wardrobe3","wardrobe4"}) do
local item = player[n][name]
if item then
local ex = item.extdata
if ex and ex.charges_remaining >= 1 then
return ex
end
end
end
end
local ex = get_item_next_use('Warp Ring')
if ex then
add_to_chat(123,(os.time(os.date("!*t", ex.next_use_time))-os.time()))
end
you will have to wait after you login for about 1-2 min before all the items are updated with the extdata
--this is not gearswap but ffxi
I was using un-abbreviated names, and come to think of it basically none of the other items I use needs such so that is perhaps it, again, I don't have those items myself so I'll have to get that friend who does to test it, I'll also see if I can get your method of doing so working as well, with mine I have to use an offset and while I have it working fine for most things, it's often a pain helping new people set it up, thanks again for your help and I'll post again with updates.
After testing yours, the number I got was about 3,600 seconds off (1 hour), I imagine I could use it with the same sort of method I'm determining offset now for my users etc, but, no need to rework everything in that case, hopefully it was just using long-names instead, will test as soon as I can.
if you look in the items.lua file i told you about you will see for each item
--lets use Chocobo Bedding
[1] = {id=1,en="Chocobo Bedding",ja="チョコボの寝ワラ",enl="pile of chocobo bedding",jal="チョコボの寝ワラ",category="General",flags=24660,stack=1,targets=0,type=10},
en="Chocobo Bedding" and enl="pile of chocobo bedding" are what we are looking for
en is the shortname or the name you need to use the item in a command like //item,//ma,//ja,etc. as well in the inventory
enl is the long name usually shown in the description text
there is no way it could be 3600 seconds off unless your pc clock is off or on some time variation
--like DST (Daylight saving time)
Yeah I did look in the items file and that's what I used, I'm waiting on a reply from one of the people who uses my luas who has these belt items, thanks for that.
And yeah, all my users have issues with determining recast like that, and it seems to be based on their time zone, had to use an offset for anyone who wasn't in the same time zone as me, wrote a function to have them use a capacity ring and it tells them their offset to put in their settings, if I was more savvy I'd make that fully automated as well, and yeah it was exactly 3600 seconds off when I used your formula, I'm in Central US, I'm guessing you are an hour one way or the other from that, and my clock was correct, my users often reported the same issue with the MyHome addon (though I haven't used that one myself as I have something similar built into my gearswaps).
os.time keeps things in GMT which is what ffxi uses for its timers, so the 3600 seconds is because of DST which mostly happens in the us
--3600 seconds = 1 hour
DST ends on nov 3 so the 1 hour difference will disappear
you could try this
local ex = get_item_next_use('Warp Ring')
if ex then
local now = os.time()
local t = os.date("*t", now)
if t.isdst then
now = (now-3600)
end
add_to_chat(123,(os.time(os.date("!*t", ex.next_use_time))-now))
end
Activity
smd111 commentedon Oct 19, 2018
try using
if you want to know how many seconds you need to wait to use it again this is what you use
os.time(os.date("!*t", get_item_next_use.next_use_time))-os.time()it is accurate to +/- 2 seconds
Selindrile commentedon Oct 22, 2018
Thanks for this and I'll check it out, but I use the code I mentioned for every usable item I've tried up till now the new ammo belts aren't working like everything else is, so I figured they've got an issue.
Selindrile commentedon Oct 22, 2018
add_to_chat(123,(os.time(os.date("!*t", get_item_next_use('Warp Ring').next_use_time))-os.time()))
With your get_item_next_use function is also giving me a nil value, I'm not sure if I'm doing something wrong on that end, I just know the way I usually use works for most items, just not the new belts.
smd111 commentedon Oct 22, 2018
are you using the correct names
these are the latest ammo items added to ffxi (September 2018) for bullets
Chrono Bullet Pouch => Chr. Bul. Pouch
Devastating Bullet Pouch => Dev. Bul. Pouch
Eradicating Bullet Pouch => Era. Bul. Pouch
Living Bullet Pouch => Liv. Bul. Pouch
make sure you use the short name for items it makes things easier
you can find them in res\items.lua in your windower folder
i also do not recommend doing this
i recommend this (because sometimes you will get bad extdata with wrong names)
if you want the best code you can try this
you will have to wait after you login for about 1-2 min before all the items are updated with the extdata
--this is not gearswap but ffxi
smd111 commentedon Oct 22, 2018
if you look at the first 51 lines of my gearswap file i have this and more edited gearswap functions
https://github.com/smd111/Gearswap/blob/master/SMDinclude/includes/Include.lua
i have tried to get this added to gearswap but so far it has not been accepted
Selindrile commentedon Oct 22, 2018
I was using un-abbreviated names, and come to think of it basically none of the other items I use needs such so that is perhaps it, again, I don't have those items myself so I'll have to get that friend who does to test it, I'll also see if I can get your method of doing so working as well, with mine I have to use an offset and while I have it working fine for most things, it's often a pain helping new people set it up, thanks again for your help and I'll post again with updates.
Selindrile commentedon Oct 22, 2018
After testing yours, the number I got was about 3,600 seconds off (1 hour), I imagine I could use it with the same sort of method I'm determining offset now for my users etc, but, no need to rework everything in that case, hopefully it was just using long-names instead, will test as soon as I can.
smd111 commentedon Oct 22, 2018
if you look in the items.lua file i told you about you will see for each item
--lets use Chocobo Bedding
en="Chocobo Bedding" and enl="pile of chocobo bedding" are what we are looking for
en is the shortname or the name you need to use the item in a command like //item,//ma,//ja,etc. as well in the inventory
enl is the long name usually shown in the description text
there is no way it could be 3600 seconds off unless your pc clock is off or on some time variation
--like DST (Daylight saving time)
Selindrile commentedon Oct 26, 2018
Yeah I did look in the items file and that's what I used, I'm waiting on a reply from one of the people who uses my luas who has these belt items, thanks for that.
And yeah, all my users have issues with determining recast like that, and it seems to be based on their time zone, had to use an offset for anyone who wasn't in the same time zone as me, wrote a function to have them use a capacity ring and it tells them their offset to put in their settings, if I was more savvy I'd make that fully automated as well, and yeah it was exactly 3600 seconds off when I used your formula, I'm in Central US, I'm guessing you are an hour one way or the other from that, and my clock was correct, my users often reported the same issue with the MyHome addon (though I haven't used that one myself as I have something similar built into my gearswaps).
smd111 commentedon Oct 26, 2018
os.time keeps things in GMT which is what ffxi uses for its timers, so the 3600 seconds is because of DST which mostly happens in the us
--3600 seconds = 1 hour
DST ends on nov 3 so the 1 hour difference will disappear
you could try this
if its off change -3600 to +3600