Documentation › Lua

Engine

The Engine module turns the bot's modules on and off, switches profiles, handles alarms and PvP options, and loads other scripts.

Turning modules on and off#

Each module has a pair enableX(on) / isXEnabled(). Calling enableX() with no parameter turns it on.

On/offQueryDrenoxBot module
Engine.enableHealing(b)Engine.isHealingEnabled()Healing
Engine.enableHealFriend(b)Engine.isHealFriendEnabled()Heal Friend
Engine.enableTargeting(b)Engine.isTargetingEnabled()Targeting
Engine.enableMagicShooter(b)Engine.isMagicShooterEnabled()Shooter
Engine.enableCaveBot(b)Engine.isCaveBotEnabled()CaveBot
Engine.enableEquipment(b)Engine.isEquipmentEnabled()Equipment
Engine.enableBot(b)Engine.isBotEnabled()The whole bot (pause and resume)
Engine.enableTimer(b)Engine.isTimerEnabled()Scripts turned on by themselves when the bot opens
lua
-- No mana potions: turn off the CaveBot and warn
if Game.getItemCount(268) == 0 then
  Engine.enableCaveBot(false)
  Client.showMessage("Out of mana potions")
end

PvP and Tools#

On/offQueryWhat it is
Engine.holdTargetEnable(b)Engine.isHoldTargetEnabled()Hold target
Engine.antiPushEnable(b)Engine.isAntiPushEnabled()Anti-push
Engine.autoSSAEnable(b)Engine.isAutoSSAEnabled()Auto SSA
Engine.autoMightRingEnable(b)Engine.isAutoMightRingEnabled()Auto might ring
Engine.runeMaxEnable(b)Engine.isRuneMaxEnabled()Rune max
Engine.reconnectEnable(b)Engine.isReconnectEnabled()Reconnect by itself

Settings:

FunctionWhat it does
Engine.setFirstAntiPushId(itemId) / Engine.setSecondAntiPushId(itemId)Items the anti-push drops
Engine.getRuneMaxId() / Engine.setRuneMaxId(itemId)Rune used by rune max
lua
Engine.antiPushEnable(true)
Engine.setFirstAntiPushId(3031)

Profiles#

A profile is a config saved with profile save in the Console (files profiles/*.json). The profile number is the file's position in the folder, in alphabetical order, starting at 0. Switching a module's profile loads only that module's part.

ModuleSwitchCurrentName
Healing (and Conditions)Engine.healingSwitchProfile(n)Engine.healingGetProfile()Engine.healingGetProfileName(n)
TargetingEngine.targetingSwitchProfile(n)Engine.targetingGetProfile()Engine.targetingGetProfileName(n)
EquipmentEngine.equipmentSwitchProfile(n)Engine.equipmentGetProfile()Engine.equipmentGetProfileName(n)
ShooterEngine.magicShooterSwitchProfile(n)Engine.magicShooterGetProfile()Engine.magicShooterGetProfileName(n)

xSwitchProfile takes the profile's number or its name (Engine.magicShooterSwitchProfile("Boss")), and returns false if the profile does not exist. xGetProfileName with no parameter gives the current profile's name.

lua
-- Switch Targeting to profile 1 when a player shows up
Game.registerEvent(Game.Events.ALARM, function(kind)
  if kind == Enums.AlarmType.PLAYER_ON_SCREEN then
    Engine.targetingSwitchProfile(1)
    print("Targeting: " .. Engine.targetingGetProfileName())
  end
end)

Engine.targetingGetProfileSettings(n) and Engine.targetingSetProfileSettings(n, table)#

Reads and writes the Targeting part of a profile, as a table. Writing to the profile in use applies it right away.

lua
local t = Engine.targetingGetProfileSettings(0)
Engine.targetingSetProfileSettings(0, t)

Engine.loadConfig(name)#

→ boolean

Loads a whole saved config, like profile load <name> in the Console.

lua
Engine.loadConfig("rotworm")

Alarms#

FunctionWhat it does
Engine.setAlarm(type, on)Turns an Enums.AlarmType alarm on or off. Alarms with a limit (health, cap, stuck, idle) turn on with a default value (30%, 100 oz, 60 s, 10 min) and turn off with 0. Returns false for an invalid type
Engine.isAlarmEnabled(type)Whether the alarm is on
Engine.allAlarmsEnable(on)false silences every alarm (and the ALARM event)
Engine.isAllAlarmsDisabled()Whether they are silenced
lua
Engine.setAlarm(Enums.AlarmType.PLAYER_ON_SCREEN, true)

Scripts#

FunctionWhat it does
Engine.loadScript(name)Turns on scripts/<name>.lua (and keeps it on when the bot opens)
Engine.unloadScript(name)Turns the script off
Engine.reloadScript(name)Restarts the script
Engine.isScriptLoaded(name)Whether the script is running
Engine.getScriptsDirectory() / Engine.getScriptsDirectoryUtf8()Path of the scripts/ folder

All of them return true or false.

lua
if not Engine.isScriptLoaded("alarme") then Engine.loadScript("alarme") end

Information#

FunctionReturns
Engine.getBotVersion()A fixed text with the scripting API version
Engine.getLicenseTime()Always a very large number (exists for ZeroBot scripts)
Engine.getUserId(lowercase)The Windows user name; true returns it in lowercase
lua
print(Engine.getUserId(true))