gFunc.Equip (any any equipping probably?) blocks swaps if it can't equip the item
Closed this issue · 4 comments
This blocks equipment swaps depending on where you put the swap in your code.
Example:
Have a WS set
Have a function to equip fenrir earring in ear1 if it's not night time after the WS set
Don't have the fenrir earring in any inventory you cant equip items form
Press a WS at night, you will not swap ear1 to your WS sets ear1
I had to bypass this with:
function GetItemByName(item)
local itemResource = AshitaCore:GetResourceManager():GetItemByName(item , 0);
return itemResource.Id
end
function HasItemInEquippableInventory(itemId)
local containers = {0, 8, 10, 11, 12, 13, 14, 15, 16}
for _, containerId in ipairs(containers) do
for slot = 1, 80 do
local item = AshitaCore:GetMemoryManager():GetInventory():GetContainerItem(containerId, slot)
if item ~= nil and item.Id == itemId then
return true
end
end
end
return false
end
function IsNightTime()
local environment = gData.GetEnvironment()
if (environment.Time > 18.00) or (environment.Time < 7) then
return true
end
return false
end
function FenrirsEarringCheck()
if not IsNightTime() and HasItemInEquippableInventory(GetItemByName('Fenrir\'s Earring')) then
gFunc.Equip('Ear1', 'Fenrir\'s Earring')
end
end
This isn't a bug, equips are only calculated once at the end of section. When you call gFunc.Equip('ear1'
the pending ear1 gets changed to the string Fenrir's Earring
, regardless of whether you have it or not. That is intended behavior.
After your Handle call returns, your inventory is parsed once to equip any pending swaps.
As an addendum, there is already a validate function, as well as the packer plugin, that can be used to ensure you have the items your lua is using.
As an addendum, there is already a validate function, as well as the packer plugin, that can be used to ensure you have the items your lua is using.
This doesn't help if you're using outside files/functions/tables to equip items.
Any user who makes and uses a staff or obi table, fully fills them out without owning every obi/staff will encounter this bug.
It's not a bug. It's a feature request, at best. A bug is something not functioning as designed; this is known behavior. It's the same way Ashitacast v3, Ashitacast v4, gearswap, and any other macro system work. People should be aware of their own files.
Aside from it being considerable work to reconstruct the entire equipment code, it would add additional complexity to things like dual rings, a ring moving from one slot to the other. It reduces performance by adding additional inventory queries for each set equipped, with no upside for people who have all of their gear. It's not uncommon for people to layer 3-4 item sets, at which point you might be doing 30+ searches of whole inventory instead of the max 16 in current system.. maybe not an insane cost, but a cost with no benefit to most users.