I'll start by mentioning the only non backward compatible part of this commit. 'inventory.EquipSlots[]' has been moved to 'equipment.BagSlot[]'. So if you have any code that directly accesses that table, eg. code to use a Rune Bow, then it wont work and will have to be changed.
Basically, we now can use other item containers besides the inventory. The other containers are 'equipment' (which replaces inventory.EquipSlots), 'bank' and 'guildbank'. They have similar functions 'update()' and 'findItem()'. 'inventory' still has all the original functions and 'equipment' also has the equipment functions that used to be part of inventory. Eg. equipment:getDurability(), equipment:getAmmunitionCount().
They each use their own item classes bassed on what is now a general purpose 'item' class similar to how the pawn class is the base of the player class. The items are in a sub table called 'BagSlot', eg bank.BagSlot[1], guildbank.BagSlot[5]. They use the same name for compatibility reasons. Because they share the same item classs they also share all the item functions. So as an example, if you want to get something from your bank you can use
Code: Select all
item = bank:findItem("itemname")
if item then
item:moveTo("bags")
end
Code: Select all
item = inventory:findItem("itemname")
if item then
item:moveTo("bank")
end
Code: Select all
local runebow = inventory:findItem("Rune Catapult") or inventory:findItem("Rune War Bow")
if runebow then
runebow:moveTo("ranged weapon") yrest(1000)
equipment:findItem("ranged weapon"):use() yrest(3000)
inventory:useItem("Runic Thorn")
yrest(2000)
runebow:moveTo("ranged weapon")
end
There are a lot more 'ranges' now that can be used with 'findItem' and 'moveTo' and such functions. Look at the 'getInventoryRange()' function in inventory.lua for the full list of valid ranges now.
A new function to the 'item' class is 'pickup()'. It's used extensivly now when moving items.
I was inspired by the way some addons can move items so fast, so I made changes to the bot to make lightning fast moves a reality. There are limitations, eg. when merging items, but you will be surprised at how fast items can now move between containers and how reliable it still is.
Added a 'cursor' class. It basically has information about the item on the cursor and a couple of functions. The main use is to check 'cursor:hasItem()' instead of using a RoMScript command. I also use the information to clear the cursor when necessary using 'cursor:clear()'.
I did a lot of general tidying up that should improve speed a bit, eg. the findItem function no longer does a whole container update() which updates every item in the container. Instead it updates only the items it is checking. And I removed a lot of needless 'self:updates()'.
Last minute addition is 'ItemQueueCount()' which I nearly didn't add. The bot doesn't use it and I doubt many users will use it. It returns the number if items in the item queue. That's the queue of items entering your bags. Basically the only time you would need it is if you've just bought a lot of items or collected some mail and you want to wait until they all enter your bag because you intend to immediately use the items received. Then you would do,
Code: Select all
while ItemQueueCount() > 0 then yrest(500) end