Advanced Anti Furniture Trap
Description:
Advanced Anti Furniture Trap, will check your screen for furnitures trapping you and will destroy them with disintegrate rune or a weapon.
It checks for furnitures and for tiles trashed.
If you want to use Disintegrate Runes they must be visible on your backpacks, also leave the option enabled.
It will first check if you have disintegrate runes to use, if not will open the browse field and destroy it with a weapon.
Default weapon is a machete.
Code:
init start
itemToBreak = 'machete'
disintegrate = true --will try to use disintegrate rune on the field
-- DO NOT EDIT BELOW THIS LINE
--@desc new anti furniture trap, will check for furnitures trapping you and will destroy them with disintegrate rune or a weapon
--@param standtime: your stand time in seconds to active the function
--@param itemb: item used to break the furniture trapping
function antitrap(standtime,itemb)
local standtime = standtime or 30
local itemb = itemb or 'machete'
if $standtime > standtime*1000 then
for x,y,z in screentiles() do
if (not tilewalkable(x,y,z) or gettile(x,y,z).itemcount >= 10) and tilereachable(x,y,z) and tiledestructible(x,y,z) then
pausewalking(30000)
closewindows('browse field') wait(1000,2000)
while windowcount('browse field') == 0 do
browsefield(x,y,z) wait(1000,2000)
end
local bf = getcontainer('browse field')
for k = 1,bf.lastpage do
for i = 0,bf.itemcount do
local bfId = bf.item[i].id
while itemcount(bfId, 'browse field') > 0 and shouldbreak(bfId) do
if itemcount(3197) > 0 and disintegrate then
useitemon(3197,bfId,'browse field') wait(500,1000)
else
useitemon(itemb,bfId,'browse field') wait(500,1000)
end
end
if bf.curpage ~= bf.lastpage then
nextpage('browse field') wait(1000,2000)
end
end
end
pausewalking(0)
end
end
end
end
function shouldbreak(id)
if (not iteminfo(id).isunmove and iteminfo(id).isunpass) or (iteminfo(id).destructible) then
return true
end
return false
end
function tiledestructible(x,y,z)
tileinfo = gettile(x,y,z)
if tileinfo.itemcount >= 10 then
return true
else
for i = 1,tileinfo.itemcount do
if shouldbreak(tileinfo.item[i].id) then
return true
end
end
end
return false
end
init end
auto(1000)
antitrap(30,itemToBreak)