Your browser does not support JavaScript or its disabled!
Please turn it on, or be aware that some features on this website will not work correctly.
1K
Cut Webs/Wooden Bars #43
Searches around a player for webs/wooden bars and repeat cuts the first found until broken.
1.01kb | 32 lines.
 --[[
  Script made by Lee (Discord: l33_) - www.trainorcreations.com
  If you want to support my work, feel free to donate at https://trainorcreations.com/donate
  PS. Stop ripping off my work and selling it as your own.
 ]]--
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

01 Jul 2021
Ads