how to open main container:
local containers = getContainers()
if not containers[0] and getBack() then
g_game.open(getBack())
endhow to get the target bot's "Danger" count in Lua:
TargetBot.Danger() -- returns inthow 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
return player:hasState(PlayerStates.ManaShield)
end
macro(3000, "manarune heal", function()
if getManaPercent() >= 70 then
say("more than 70%")
return
end
local idManaRune = 3201
local manaruneItem = g_game.findPlayerItem(idManaRune, 1)
if not manaruneItem then
say("no manarune")
return
end
say("using manarune")
g_game.useWith(manaruneItem, g_game.getLocalPlayer(), 1)
end)
macro(100, "manarune heal in front of you", function()
if getManaPercent() >= 70 then
return
end
local idManaRune = 3201
local manaruneItem = g_game.findPlayerItem(idManaRune, 1)
if not manaruneItem then
return
end
local pos = player:getPosition()
pos.x = pos.x + 2
local tile = g_map.getTile(pos)
if not tile then
return
end
local targetThing = tile:getTopUseThing()
if not targetThing then
targething = tile:getTopThing()
if not targetThing then
return
end
end
g_game.useWith(manaruneItem, targetThing, 1)
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
endturn 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