Splitter Addon/Userfunction by Rock5
Forum rules
Only post additional bot resources here. Please do not ask unrelated questions.
Only post additional bot resources here. Please do not ask unrelated questions.
Re: Splitter Addon/Userfunction by Rock5
Yeah, like I said, I don't think this addon can handle an available bag following a locked bag. I'll think about how I can fix it to avoid the locked bag even in those situations although I still don't understand how you can be moving items from a locked bag.
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Splitter Addon/Userfunction by Rock5
I dont know either. But I talked with my guildies and they told me that there was an addon that let you do that some time ago. To be honest, I dont know how it happen, but it happen.
Rock, I was thinking on another way to overcome this issue regarding the bags. It's possible to know which bag is open or not using GetBagPageLetTime(), and if store the information regarding the slots to search on a table it will be possible to set segmented fors. But that will mess a lot with the actual code. So, I thought about storing the slots free from each bag into an array and give them that to the for instead the total amount.
So, I came up with this to overcome this issue. This code build an array that enclose which bag is active or not, and from where to look for and where to stop. And then, store every slot of the whole backpack in an array that would be use by your getBagSlots() and haveItem() to override the totalSlots from GetBagCount().
This is a new function that return an array with all the slots available in the backpack.
This is the code for getBagSlots that search on every slot returned by the function above instead of using the totalcount.
This is the code for haveItem that search on every slot returned by the function GetBagStatus() instead of using the totalcount.
I test it and it seems to work. Need further testing to see if I didnt mess up.
Thanks in advance.
Rock, I was thinking on another way to overcome this issue regarding the bags. It's possible to know which bag is open or not using GetBagPageLetTime(), and if store the information regarding the slots to search on a table it will be possible to set segmented fors. But that will mess a lot with the actual code. So, I thought about storing the slots free from each bag into an array and give them that to the for instead the total amount.
So, I came up with this to overcome this issue. This code build an array that enclose which bag is active or not, and from where to look for and where to stop. And then, store every slot of the whole backpack in an array that would be use by your getBagSlots() and haveItem() to override the totalSlots from GetBagCount().
This is a new function that return an array with all the slots available in the backpack.
Code: Select all
function GetBagStatus()
local BagPacks = {
Bag1 = { Active = true, Start = 1, End = 30 },
Bag2 = { Active = true, Start = 31, End = 60 },
Bag3 = { Active = true, Start = 61, End = 90 },
Bag4 = { Active = true, Start = 91, End = 120 },
Bag5 = { Active = true, Start = 121, End = 150 },
Bag6 = { Active = true, Start = 151, End = 180 },
}
local SlotsOpen = {}
for i = 1, 6 do
local isLet, letTime = GetBagPageLetTime( i );
if letTime == -1 then
BagPacks["Bag"..i].Active = false
else
BagPacks["Bag"..i].Active = true
end
if BagPacks["Bag"..i].Active then
for y = BagPacks["Bag"..i].Start, BagPacks["Bag"..i].End do
table.insert( SlotsOpen, y )
end
end
end
return SlotsOpen
end
Code: Select all
function getBagSlots(itemName, group)
local data = {}
local totalSlots = GetBagStatus()
--local occupiedSlots, totalSlots = GetBagCount()
--for i = 1, totalSlots do
for __,value in ipairs( totalSlots ) do
local item = Item(value)
if item.name == itemName or (item.name ~= "" and itemName == "all") or (type(itemName) == "table" and itemName[item.name]) then
if group then
if not data[item.name] then
data[item.name] = {item}
else
table.insert(data[item.name],item)
end
else
table.insert(data,item)
end
end
end
return data
end
Code: Select all
-- Returns true if item found in bag --
local function haveItem(itemName)
local totalSlots = GetBagStatus()
--local occupiedSlots, totalSlots = GetBagCount()
--for i = 1, totalSlots do
for __, value in ipairs(totalSlots) do
local item = Item(value)
if item.name == itemName then
return true
end
end
return false
end
Thanks in advance.
Operae pretium est exprimendum sucus
Re: Splitter Addon/Userfunction by Rock5
Hm... Seems more complex than needed. I don't know if I like the idea of an extra function and, even though the way you do it wouldn't make much difference to the performance of getBagSlots, if would make haveItem a lot slower.
How about just doing it like this.
How about just doing it like this.
Code: Select all
-- Get items whos name matches itemName --
function getBagSlots(itemName, group)
local data = {}
-- local occupiedSlots, totalSlots = GetBagCount()
for bag = 1, 6 do
local isLet, letTime = GetBagPageLetTime(bag);
if bag < 3 or letTime ~= -1 then
for i = 1+(bag-1)*30, bag*30 do
local item = Item(i)
if item.name == itemName or (item.name ~= "" and itemName == "all") or (type(itemName) == "table" and itemName[item.name]) then
if group then
if not data[item.name] then
data[item.name] = {item}
else
table.insert(data[item.name],item)
end
else
table.insert(data,item)
end
end
end
end
end
return data
end
-- Returns true if item found in bag --
local function haveItem(itemName)
-- local occupiedSlots, totalSlots = GetBagCount()
for bag = 1, 6 do
local isLet, letTime = GetBagPageLetTime(bag);
if bag < 3 or letTime ~= -1 then
for i = 1+(bag-1)*30, bag*30 do
local item = Item(i)
if item.name == itemName then
return true
end
end
end
end
return false
end
- Please consider making a small donation to me to support my continued contributions to the bot and this forum. Thank you. Donate
- I check all posts before reading PMs. So if you want a fast reply, don't PM me but post a topic instead. PM me for private or personal topics only.
- How to: copy and paste in micromacro
________________________
Quote:- “They say hard work never hurt anybody, but I figure, why take the chance.”
- Ronald Reagan
Re: Splitter Addon/Userfunction by Rock5
Thanks for the code revision, I will check it and let you know.
EDIT
I test it, and works fine. Your modification is simpler than the one I did, but could it be possible that takes longer than the solution I find?
Yesterday, while I was coding I thought using the building array function at variable loads event, because continous executing of that function will increase the addon time execution. But variable loads only loads once, so there is no way to know if someone rent a backpack at one point after the variable load event had been executed. Also, I dont know how addon's works so I think a way to do the deed without messing around with the code a lot, but your solution is simpler and easy to understand that the one I provided. I was banging my head on the wall for not seeing that before.
Thanks again for the revision and your time.
EDIT
I test it, and works fine. Your modification is simpler than the one I did, but could it be possible that takes longer than the solution I find?
Yesterday, while I was coding I thought using the building array function at variable loads event, because continous executing of that function will increase the addon time execution. But variable loads only loads once, so there is no way to know if someone rent a backpack at one point after the variable load event had been executed. Also, I dont know how addon's works so I think a way to do the deed without messing around with the code a lot, but your solution is simpler and easy to understand that the one I provided. I was banging my head on the wall for not seeing that before.
Thanks again for the revision and your time.
Operae pretium est exprimendum sucus
Who is online
Users browsing this forum: No registered users and 2 guests