Cut Webs/Wooden Bars
#43
local spider_web = { 182,183,2295,2296 }
local spider_web_cut = { 188,189,3145 } -- unused
UI.Button("Cut Web Example", function()
cutWeb(pos())
end)
local web_tile = null
cut_macro = macro(1000, function()
if not web_tile then return end
local topThing = web_tile:getTopUseThing()
if not topThing then return false end
if table.find(spider_web, topThing:getId()) then
useWith(3308, topThing)
else
cut_macro:setOff()
end
end)
cut_macro:setOff()
function cutWeb(position)
local dirs = { { 0, 1 }, { -1, 0 }, { 1, 0 }, { 1, -1 } ,{ -1, 1 }, { 1, 1 }, { -1, -1 }, { 0, -1 }}
for i = 1, #dirs do
local tile = g_map.getTile({ x = position.x - dirs[i][1], y = position.y - dirs[i][2], z = position.z })
if tile then
local topThing = tile:getTopUseThing()
if topThing and table.find(spider_web, topThing:getId()) then
web_tile = tile
cut_macro:setOn()
return
end
end
end
end
- remove | + add
01 Jul 2021