how to open main container:
local containers = getContainers()
if not containers[0] and getBack() then
g_game.open(getBack())
end
how to get the target bot's "Danger" count in Lua:
TargetBot.Danger() -- returns int
how to move an item to under my feet:
interestingItem=findItem(1337);
g_game.move(interestingItem, player:getPosition(), 1)
how to move an item to a container:
bp0=getContainer(0);
interestingItem=findItem(1337);
g_game.move(interestingItem, bp0:getSlotPosition(0), 1)
how to open container in current window, rather than a new window:
g_game.open(container, container:getParentContainer())
how to send a custom packet, like "\x01\x00\x65":
local protocol = g_game.getProtocolGame()
local msg = OutputMessage.create()
msg:addU8(1)
msg:addU8(0)
msg:addU8(113)
protocol:send(msg)
how to schedule something in the future:
schedule(1000, function()
-- this will execute in 1000 milliseconds
end)
misc functions:
function getManaPercent()
return (player:getMana() / player:getMaxMana()) *100
end
function getHealthPercent()
return (player:getHealth() / player:getMaxHealth()) *100
end
function hasManashield()
return (player:getStates() & (1 << 4)) ~= 0
end
converting 100gp to 1plat, 100plat to 1 cc, 100 cc to something:
for i, container in pairs(getContainers()) do
for j, item in ipairs(container:getItems()) do
if item:getCount() == 100 and (item:getId() == 3031 or item:getId() == 3035 or item:getId() == 3043) then
g_game.use(item)
delay(100)
return "retry"
end
end
end
turn off cavebot:
CaveBot.setOn(false)
Stacking itmes:
macro(5000, "Auto stacking items", function()
local containers = g_game.getContainers()
for i, container in pairs(containers) do
local toStack = {}
for j, item in ipairs(container:getItems()) do
if item:isStackable() and item:getCount() ~= 100 then
local otherItem = toStack[item:getId()]
if otherItem then
g_game.move(item, otherItem, item:getCount())
end
toStack[item:getId()] = container:getSlotPosition(j - 1)
end
end
end
end)
https://pastebin.com/u/Zeroun_Scripts