Documentation › Lua
CaveBot
The CaveBot module controls the CaveBot route from a script: jump to a label, pause, read and edit waypoints, change lure settings and the sell and refill lists.
Waypoints are counted from 0. Route changes made by the script take effect without stopping the CaveBot.
Navigating the route#
CaveBot.GoTo(label)#
CaveBot.GoTo(label) → boolean
Jumps the route to the Label waypoint with that text (case-insensitive). Returns false if the label does not exist. Inside a Script waypoint, it also ends the script.
if Game.getItemCount(268) < 50 then CaveBot.GoTo("refill") endCaveBot.selectWaypoint(index)#
CaveBot.selectWaypoint(index)
Jumps the route to the waypoint by its number. Inside a Script waypoint, it also ends the script.
CaveBot.selectWaypoint(0) -- back to the startCaveBot.getSelectedWaypointId()#
→ number
Current waypoint. Returns -1 when the route is empty.
print("current waypoint: " .. CaveBot.getSelectedWaypointId())CaveBot.pause(ms)#
CaveBot.pause(ms)
Pauses the route for ms milliseconds. 0 resumes right away, including the pause from the LABEL event.
CaveBot.pause(10000) -- waits 10 s
CaveBot.pause(0) -- resumesCaveBot.stopCurrentScript()#
CaveBot.stopCurrentScript()
Stops the Script waypoint that is running.
CaveBot.stopCurrentScript()Reading waypoints#
CaveBot.getWaypoints()#
→ list
Every waypoint, as {x, y, z, type, data}. type is the Enums.WaypointType number and data is the waypoint's text (label, script code).
for i, w in ipairs(CaveBot.getWaypoints()) do print(i - 1, w.type, w.data) endCaveBot.getWaypointsCount()#
→ number
How many waypoints the route has.
print(CaveBot.getWaypointsCount())CaveBot.getWaypointTypeById(index) and CaveBot.getWaypointDataById(index)#
→ number / → table or nil
The waypoint's type (-1 if the index does not exist) and the whole waypoint {x, y, z, type, data} (nil if it does not exist).
local w = CaveBot.getWaypointDataById(CaveBot.getSelectedWaypointId())
if w then print(w.x, w.y, w.z) endEditing waypoints#
type is Enums.WaypointType (an unknown number becomes Node). data is the waypoint's text, optional.
| Function | What it does |
|---|---|
CaveBot.addWaypoint(type, x, y, z, data) | Adds at the end |
CaveBot.insertWaypoint(index, type, x, y, z, data) | Inserts at the position |
CaveBot.replaceWaypoint(index, type, x, y, z, data) | Replaces the waypoint |
CaveBot.deleteWaypoint(index) | Deletes the waypoint |
CaveBot.clearWaypoints() | Deletes all of them and restarts the route |
local p = Player.getPosition()
CaveBot.addWaypoint(Enums.WaypointType.WAYPOINT_TYPE_STAND, p.x, p.y, p.z)
CaveBot.addWaypoint(Enums.WaypointType.WAYPOINT_TYPE_LABEL, 0, 0, 0, "back")Files#
CaveBot.saveFile(name) and CaveBot.loadFile(name)#
→ boolean
Save and load the route to a file inside the scripts/ folder (ZeroBot uses Documents/ZeroBot). With a name ending in .lua, saveFile writes a ZeroBot script with the route and the settings; with any other name, it writes DrenoxBot's route JSON. loadFile reads both formats and restarts the route. They return false for a path outside scripts/ or a file that does not exist.
CaveBot.saveFile("routes/rotworm.lua")
CaveBot.loadFile("routes/rotworm.lua")Walking#
| Function | What it does |
|---|---|
CaveBot.setWalkMode(mode) | Enums.WalkMode: 1 (ARROW_KEYS) walks step by step, any other value walks by path |
CaveBot.setWalkDelay(ms) | Wait between steps |
CaveBot.setNodeSettings(distance) | Distance at which a Node counts as reached (default 3) |
CaveBot.setStartFromNearestWaypoint(enable) | Starts the route from the nearest waypoint |
CaveBot.disablePlayerWalkthrough(enable) | Turns on the setting to not walk through players (default true) |
CaveBot.getCoreTeleportIds() / CaveBot.setCoreTeleportIds(ids) | List of teleport ids the CaveBot knows |
CaveBot.setWalkMode(Enums.WalkMode.MAP_CLICK)
CaveBot.setNodeSettings(2)CaveBot.isDebugEnabled() and CaveBot.setDebugHUDSettings(a, b, c)#
→ boolean
DrenoxBot has a single text debug HUD: setDebugHUDSettings turns the HUD on if any of the three parameters is true. ZeroBot's separate path and tile drawings do not exist here.
CaveBot.setDebugHUDSettings(true, false, false)Lure#
CaveBot.setLureSettings(toRun, dynamic, skipUnreachable) and CaveBot.getLureSettings()#
How many monsters must follow before moving on (creaturesToRun), whether dynamic lure is on (dynamicLure) and whether unreachable creatures are skipped (skipUnreachableCreatures, default true). getLureSettings returns the table with these three fields.
CaveBot.setLureSettings(3, false, true)
print(CaveBot.getLureSettings().creaturesToRun)CaveBot.setSafetyLureSettings(distance, count, trap) and CaveBot.getSafetyLureSettings()#
Lure safety: nearCreatureDistance, nearCreatureCount and avoidStuckTrapCount.
CaveBot.setSafetyLureSettings(1, 4, 3)CaveBot.setEndLureSettings(...) and CaveBot.getEndLureSettings()#
End Lure rules, in this order: creaturesToStop, creaturesToLeave, tryWalkToCenter, creaturesToLeaveByHp, creaturesToLeaveByHpValue, creaturesToLeaveByHpCount, dontLeaveIfHp, dontLeaveIfHpValue, dontLeaveIfHpCount. getEndLureSettings returns a table with these names.
CaveBot.setEndLureSettings(5, 1)
print(CaveBot.getEndLureSettings().creaturesToStop)CaveBot.setLureIgnoreList(names)#
List of monster names the lure ignores.
CaveBot.setLureIgnoreList({ "Rat", "Cave Rat" })Special areas#
CaveBot.addSpecialArea(x, y, z, type, width, height, fromWp, toWp)#
→ boolean
Creates a rectangular area starting at x, y, z. type is Enums.SpecialAreaType: 0 both things, 1 the CaveBot does not walk through it, 2 Targeting ignores the monsters in it. fromWp and toWp (optional) limit the area to a stretch of the route. Returns false with width or height 0 or an invalid type.
CaveBot.addSpecialArea(32000, 32000, 7, Enums.SpecialAreaType.SPECIAL_AREA_CAVEBOT, 5, 3)CaveBot.deleteSpecialArea(index) and CaveBot.clearSpecialAreas()#
Deletes one area (false if the index does not exist) or all of them.
CaveBot.clearSpecialAreas()Sell, refill and recording#
| Function | What it does |
|---|---|
CaveBot.getSellList() / CaveBot.setSellList(ids) | List of item ids to sell |
CaveBot.getRefillList() / CaveBot.setRefillList(text) | Refill list, as text |
CaveBot.setAutoRecorderSettings(step, type) | Auto recording: tiles between waypoints (default 3) and type (0 Stand, other Node) |
CaveBot.enableAutoRecorder(enable) | Turns auto recording on or off; false if the recorder is not available |
CaveBot.setSellList({ 3357, 3359 })
CaveBot.enableAutoRecorder(true)
Comments
to comment.