Suggestions
Cut - vBot extension
#74
This allows you to add a "cut" button inside the bot. (face the web/bars and press the button)
Edit your CONFIGNAME\vBot\cavebot.lua
add this line as you would with other extensions.
dofile("/cavebot/cut.lua")
create a file CONFIGNAME\cavebot\cut.lua and add code below.
--[[
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.
]]--
-- Lee
-- This function only is needed once across all extensions add somewhere in your bot.
function getPosByDir(withItem)
-- if withItem is set to true, it will get the first item in the tile items list such as rope hole.
local dir = player:getDirection()
local dir_pos = pos()
if dir == 0 then
dir_pos.y = dir_pos.y - 1
elseif dir == 1 then
dir_pos.x = dir_pos.x + 1
elseif dir == 2 then
dir_pos.y = dir_pos.y + 1
elseif dir == 3 then
dir_pos.x = dir_pos.x - 1
end
local ret = dir_pos.x .. "," .. dir_pos.y .. "," .. dir_pos.z
if withItem then
local tile = g_map.getTile(dir_pos)
local item = tile:getItems()[1]
ret = ret .. ','.. item:getId()
end
return ret
end
CaveBot.Extensions.Cut = {}
CaveBot.Extensions.Cut.setup = function()
CaveBot.registerAction("Cut", "orange", function(value, retries)
local pos = string.split(value, ",")
local tries = nil
local tool = nil
if #pos >= 4 then
tool = tonumber(pos[4])
end
if #pos == 5 then
tries = tonumber(pos[5])
end
if not pos[1] or not pos[2] or not pos[3] then
warn("CaveBot[Cut]: invalid value. It should be position (x,y,z), is: " .. value)
return false
end
if retries >= (tries and tries or 20) then
print("CaveBot[Cut]: too many tries, can't cut")
return false -- tried 20 times, can't open
end
pos = {x=tonumber(pos[1]), y=tonumber(pos[2]), z=tonumber(pos[3])}
local cutTile = g_map.getTile(pos)
if not cutTile then
return "retry"
end
if not cutTile:isWalkable() then
if not tool then
useWith(3308, cutTile:getTopUseThing())
else
useWith(tool, cutTile:getTopUseThing())
end
delay(500)
return "retry"
else
print("CaveBot[Cut]: possible to cross, proceeding")
return true
end
return "retry"
end)
CaveBot.Editor.registerAction("cut", "cut", {
value=function() return getPosByDir() end,
title="Cut",
description="hole position (x,y,z) and tool id (optional) and retries (optional)",
multiline=false,
})
end
24 Dec 2021