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.
655
Stand - vBot extension #56
This allows you to add a stand button inside the bot so you can tell bot to stand 1 square away from where you are facing.
To install see my Auto extension loader code here
File: stand.lua | 995b | 34 lines.
CaveBot.Extensions.Stand = {}

function getStandPos()
  local dirs = { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 }}
  local dir = player:getDirection() + 1
  local dirPos = pos()
  dirPos.x = dirPos.x + dirs[dir][1]
  dirPos.y = dirPos.y + dirs[dir][2]

  return dirPos.x .. "," .. dirPos.y .. "," .. dirPos.z .. ",0"
end

CaveBot.registerAction("Stand", "#00FFFF", function(value, retries, prev)
  local action = CaveBot.Actions["goto"]
  if action then
    local status, result = pcall(function()
      return action.callback(value, retries, prev)
    end)
    if status then
      if result == "retry" or type(result) == 'boolean' then
        return result
      end
    end
  end
end)

CaveBot.Extensions.Stand.setup = function()
  CaveBot.Editor.registerAction("stand", "stand", {
    value=function() return getStandPos() end,
    title="Stand position",
    description="stand at the position infront of character (x,y,z,0)",
    multiline=false,
  })
end
File: stand_old.lua | 641b | 24 lines.
CaveBot.Extensions.Stand = {}

function getStandPos()
  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
  return dir_pos.x .. "," .. dir_pos.y .. "," .. dir_pos.z .. ", 0"
end
CaveBot.Extensions.Stand.setup = function()
  CaveBot.Editor.registerAction("goto", "stand", {
    value=function() return getStandPos() end,
    title="Stand position",
    description="stand position (x,y,z,0)",
    multiline=false,
})
end

02 Apr 2022