Rope - vBot extension
#76
This allows you to add a "rope" 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/rope.lua")
create a file CONFIGNAME\cavebot\rope.lua and add code below.
Edit your CONFIGNAME\vBot\cavebot.lua add this line as you would with other extensions.
dofile("/cavebot/rope.lua")
create a file CONFIGNAME\cavebot\rope.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.Rope = {}
CaveBot.Extensions.Rope.setup = function()
CaveBot.registerAction("Rope", "orange", function(value, retries)
local pos = string.split(value, ",")
local tries = nil
if #pos >= 4 then
rope = 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[Rope]: invalid value. It should be position (x,y,z), is: " .. value)
return false
end
pos = {x=tonumber(pos[1]), y=tonumber(pos[2]), z=tonumber(pos[3])}
local playerPos = player:getPosition()
if playerPos.z ~= pos.z then
return true
end
if retries >= (tries and tries or 20) then
print("CaveBot[Rope]: too many tries, can't use rope")
return false -- tried 20 times, can't use
end
local ropeTile = g_map.getTile(pos)
if not ropeTile then
return "retry"
end
local ropeitem = ropeTile:getItems()[1]
if ropeitem then
if not rope then
useWith(3003, ropeitem)
else
useWith(rope, ropeitem)
end
delay(200)
return "retry"
end
return "retry"
end)
CaveBot.Editor.registerAction("rope", "rope", {
value=function() return getPosByDir() end,
title="Rope Hole",
description="rope position (x,y,z) and rope id (optional) and retries optional",
multiline=false,
})
end
24 Dec 2021