Returns true if yor are currently connected to the game, false otherwise.
g_game.isOnline()
Returns LocalPlayer object if connected to the game, nil otherwise.
g_game.getLocalPlayer()
Attacks provided Creature object.
local creature
for v, k in pairs(g_game.getCreatures()) do
if k:getName() == "Monk" then
creature = k
break
end
end
if not g_game.isAttacking() and creature then
g_game.attack(creature)
end
Attack the first found creature with name "Monk".
Follows provided Creature object.
local creature
for v, k in pairs(g_game.getCreatures()) do
if k:getName() == "Monk" then
creature = k
break
end
end
if not g_game.isFollowing() and creature then
g_game.follow(creature)
end
Follows the first found creature with name "Monk".
Returns a table that contains all of the talk messages received until logging in.
g_game.getTalkMessages()
Returns a table that contains all of the text messages received until logging in.
g_game.getTextMessages()
Returns the last received talk message.
g_game.lastTalkMessage()
Returns the last received text message.
g_game.lastTextMessage()
Returns true if currently attacking, false otherwise.
g_game.isAttacking()
Returns currently attacking creature.
g_game.getAttackingCreature()
Returns true if currently following, false otherwise.
g_game.isFollowing()
Sends specified message in local chat.
g_game.talk("hello")
Sends the specified message in the specified channelId.
g_game.talkChannel(6, "hello")
Sends the specified message to the receiver via whisper.
g_game.talkPrivate("PlayerName", "hello")
Sets chase mode to the specified one.
g_game.setChaseMode(ChaseModes.ChaseOppontent)
Available ChaseModes:
ChaseModes = {
DontChase = 0,
ChaseOpponent = 1
}
Sets fight mode to the specified one.
g_game.setFightMode(FightModes.FightBalanced)
Available FightModes:
FightModes = {
FightOffensive = 0,
FightBalanced = 1,
FightDefensive = 2
}
Sets safe fight mode to specified state.
g_game.setSafeFight(true)
Sets PvP mode to the specified one.
g_game.setPVPMode(PVPModes.YellowHand)
Available PVPModes:
PVPModes = {
WhiteDove = 0,
WhiteHand = 1,
YellowHand = 2,
RedFist = 3
}
Turns to the specified direction.
g_game.turn(Directions.North)
Available Directions:
Directions = {
North = 0,
East = 1,
South = 2,
West = 3,
}
Stops character's walking.
g_game.stop()
Uses top use item on specified position.
g_game.useMapItem({x = 123, y = 346, z = 7})
Uses specified item.
g_game.useItem(item)
Uses first found item with specified itemId.
g_game.use(3031)
Uses top use item from specified position on specified creature.
g_game.useMapItemOnCreature({x = 123, y = 346, z = 7}, g_game.getLocalPlayer():asCreature())
Uses top use item from specified fromPos on specified toPos.
g_game.useMapItemOnPosition({x = 123, y = 346, z = 7}, g_game.getLocalPlayer():getPosition())
Uses item with specified itemId (if supported by server will use items even with closed containers).
g_game.useInventoryItem(3031)
Uses item with specified itemId (if supported by server will use items even with closed containers) at specified creature.
g_game.useInventoryItemOnCreature(3031, g_game.getAttackingCreature())
Uses item with specified itemId (if supported by server will use items even with closed containers) at specified position.
g_game.useInventoryItemOnPosition(3031, g_game.getAttackingCreature():getPosition())
Uses item with specified itemId at specified creature.
g_game.useItemOnCreature(3031, g_game.getAttackingCreature())
Uses item with specified itemId at specified position.
g_game.useItemOnPosition(3031, g_game.getAttackingCreature():getPosition())
Returns direction with most monsters around the LocalPlayer.
g_game.turn(g_game.getBestTurnDirection())
Turns to the direction with most monsters around the LocalPlayer.
Returns a table with monsters that are in front of a LocalPlayer.
if #g_game.getMonstersInFront() >= 1 then
g_game.talk("exevo vis hur")
end
Sends "exevo vis hur" if there is atleast 1 monster in front of LocalPlayer.
Returns a table with monsters that are within specified range.
if #g_game.getMonstersAround(4) >= 3 then
g_game.talk("exevo gran mas vis")
end
Sends "exevo gran mas vis" if there are atleast 3 monsters within 4 sqm distance of LocalPlayer.
Returns a table containing all open containers.
if #g_game.getContainers() == 0 then
g_game.forceLogout()
end
Exits to the character list if there are no open containers.
Returns a container with specified containerId
if g_game.getContainer(1):getName() ~= "backpack" then
g_game.forceLogout()
end
Exits to the character list if the first open container name isn't "backpack".
Returns a count of open containers.
if g_game.getContainersCount() == 0 then
g_game.forceLogout()
end
Exits to the character list if there are no open containers.
Closes all open containers.
if g_game.getContainersCount() >= 6 then
g_game.closeAllContainers()
end
Closes all containers if there are atleast 6 open containers.
Reconnects to the
if not g_game.isOnline() then
g_game.reconnect()
sleep(5000)
end
If not in game then tries to reconnect to the
Opens the specified container item.
g_game.openItem(containerItem)
Opens the first found item with specified itemId.
g_game.open(1234)
Moves the first found item with specified itemId and count to the specified position.
g_game.move(1234, {x= 65535, y = 64, 0}, 1)
Moves the specified item to the specified position.
if not g_game.isOnline() then
return
end
local items = {}
local containers = g_game.getContainers()
for v, container in pairs(containers) do
if container:getItemsCount() > 0 then
local containerItems = container:getItems()
for j, item in pairs(containerItems) do
if item:getCount() ~= 100 then
if not items[item:getId()] then
items[item:getId()] = {}
end
table.insert(items[item:getId()], item)
end
end
end
end
for v, k in pairs(items) do
if #items[v] > 1 then
if items[v][2]:isStackable() then
g_game.moveItem(items[v][2], items[v][1]:getPosition(), items[v][2]:getCount())
break
end
end
end
auto(200)
Stacks items with the same IDs.
Return a table that contains all visible creatures.
g_game.talk(tostring(#g_game.getCreatures()))
Sends the visible creatures count on local chat.
Returns true if creature with provided name is visible.
if g_game.isOnScreen("Wolf") then
g_game.forceLogout()
end
If "Wolf" is on screen then exit to character list.
Returns character's name.
g_game.getLocalPlayer():getName()
Returns character's current health.
g_game.getLocalPlayer():getHealth()
Returns character's current health percent.
g_game.getLocalPlayer():getHealthPercent()
Returns character's level.
g_game.getLocalPlayer():getLevel()
Returns character's magic level.
g_game.getLocalPlayer():getMagicLevel()
Returns character's current mana.
g_game.getLocalPlayer():getMana()
Returns character's current mana percent.
g_game.getLocalPlayer():getManaPercent()
Returns character's max health.
g_game.getLocalPlayer():getMaxHealth()
Returns character's max mana.
g_game.getLocalPlayer():getMaxMana()
Returns character's position.
g_game.getLocalPlayer():getPosition()
Returns character's skill value from specified skillId.
g_game.getLocalPlayer():getSkill(2)
Returns character's soul.
g_game.getLocalPlayer():getSoul()
Returns character's speed.
g_game.getLocalPlayer():getSpeed()
Returns character's condition states.
g_game.getLocalPlayer():getStates()
Returns character's condition states.
g_game.getLocalPlayer():hasState(PlayerStates.Haste)
Available states:
PlayerStates = {
None = 0,
Poison = 1,
Burn = 2,
Energy = 4,
Drunk = 8,
ManaShield = 16,
Paralyze = 32,
Haste = 64,
Swords = 128,
Drowning = 256,
Freezing = 512,
Dazzled = 1024,
Cursed = 2048,
PartyBuff = 4096,
PzBlock = 8192,
Pz = 16384,
Bleeding = 32768,
Hungry = 65536
}
Returns character's current facing direction.
g_game.getLocalPlayer():getDirection()
Returns character's count of items specified by itemId.
g_game.getLocalPlayer():getItemsCount(3031)
Returns character's item in a specified slot.
g_game.getLocalPlayer():getInventoryItem(InventorySlots.Backpack)
Available slots:
InventorySlots = {
Head = 0,
Necklace = 1,
Backpack = 2,
Armor = 3,
Right = 4,
Left = 5,
Legs = 6,
Feet = 7,
Ring = 8,
Ammo = 9,
}
Returns all character's items from the inventory and containers.
g_game.getLocalPlayer():getItems()
Returns all character's items from the inventory and containers with a given itemId.
g_game.getLocalPlayer():getItemsById(3031)
Returns the "x" coordinate of given Position.
g_game.getLocalPlayer():getPosition().x
Returns the "y" coordinate of given Position.
g_game.getLocalPlayer():getPosition().y
Returns the "z" coordinate of given Position.
g_game.getLocalPlayer():getPosition().z
Returns distance between Position and toPos.
g_game.getLocalPlayer():getPosition():getDistance({x = 123, y = 456, z = 7})
Returns true if given Position is within xRange and yRange of toPos.
g_game.getLocalPlayer():getPosition():isInRange({x = 123, y = 456, z = 7}, 3, 5)
Returns current health percent of a given Creature.
g_game.getCreatures()[1]:getHealthPercent()
Returns ID of a given Creature.
g_game.getCreatures()[1]:getId()
Returns name of a given Creature.
g_game.getCreatures()[1]:getName()
Returns position of a given Creature.
g_game.getCreatures()[1]:getPosition()
Returns direction of a given Creature.
g_game.getCreatures()[1]:getDirection()
Returns true if a given Creature is monster, false otherwise.
local monstersOnScreen = 0
for _, creature in pairs(g_game.getCreatures()) do
if creature:isMonster() then
monstersOnScreen = monstersOnScreen + 1
end
end
g_game.talk("Monsters on screen: " .. monstersOnScreen)
Sends the detected amount of monsters in the local chat.
Returns true if a given Creature is NPC, false otherwise.
local npcOnScreen = 0
for _, creature in pairs(g_game.getCreatures()) do
if creature:isNpc() then
npcOnScreen = npcOnScreen + 1
end
end
g_game.talk("NPCs on screen: " .. npcOnScreen)
Sends the detected amount of NPCs in the local chat.
Returns true if a given Creature is player, false otherwise.
local playersOnScreen = 0
for _, creature in pairs(g_game.getCreatures()) do
if creature:isPlayer() then
playersOnScreen = playersOnScreen + 1
end
end
g_game.talk("Players on screen: " .. playersOnScreen)
Sends the detected amount of players in the local chat.
Returns size of a given Container.
g_game.getContainer(1):getSize()
Returns table containing all items of a given Container.
g_game.getContainer(1):getItems()
Returns position of given Container.
g_game.move(1234, g_game.getContainer(1):getSlotPosition())
Moves item with ID of 1234 to the first container's position.
Returns id of a given Container.
g_game.getContainer(1):getId()
Returns capacity of a given Container.
g_game.getContainer(1):getCapacity()
Returns name of a given Container.
g_game.getContainer(1):getName()
Returns true if a given Container is inside another container, false otherwise.
g_game.getContainer(1):hasParent()
Returns the first found Item of a given itemId in a given Container.
g_game.useItem(g_game.getContainer(1):findItemById(1234))
Uses item with ID of 1234 from the first open container.
Returns the amount of items with a given itemId in a given Container.
if g_game.getContainer(1):getItemsCount(1234) < 100 then
gotolabel("EXIT", "gototown")
end
If amount of items with ID of 1234 is less than 100 then go to the cavebot section "EXIT" and label "gototown".
Returns position of a given Item.
g_game.getContainer(1):getItems()[1]:getPosition()
Returns ID of a given Item.
g_game.getContainer(1):getItems()[1]:getId()
Returns count of a given Item.
g_game.getContainer(1):getItems()[1]:getCount()
Returns stack position of a given Item.
g_game.getContainer(1):getItems()[1]:getStackPos()
Returns true if a given Item is a Container, false otherwise.
g_game.getContainer(1):getItems()[1]:isContainer()
Returns true if a given Item is stackable, false otherwise.
g_game.getContainer(1):getItems()[1]:isStackable()
Returns the mode of a given TextMessage.
g_game.lastTextMessage().mode
Returns the channelId of a given TalkMessage.
g_game.lastTalkMessage().channel
Returns the position of a given TalkMessage.
g_game.lastTalkMessage().position
Returns the level of a given TalkMessage.
g_game.lastTalkMessage().level
Returns the mode of a given TalkMessage.
g_game.lastTalkMessage().mode
Returns the name of a given TalkMessage.
g_game.lastTalkMessage().name
Delays the script of a given millis amout of time in milliseconds. If given a second argument, randomly picks a number between the two provided.
sleep(100, 200)
Allows the script to run periodically for a given millis amount of time in milliseconds. If given a second argument, randomly picks a number between the two provided.
auto(100, 200)
Sets the current waypoint to the one of labelName Label in sectionName Section.
gotolabel("HUNTING", "start-hunting")
Sets the given option to the given value.
setOption("Cavebot/Enabled", "false")
Disables cavebot.
Available options:
options = {
"Cavebot/ShovelID",
"Cavebot/RopeID",
"Cavebot/MacheteID",
"Cavebot/PickID",
"Cavebot/Enabled",
"Cavebot/PauseBotOnDeath",
"Cavebot/MapWalkDistance",
"Cavebot/WalkThroughPlayers",
"Cavebot/IgnoreNonPathable",
"SpellHealer/Enabled",
"ItemHealer/Enabled",
"ConditionHealer/Enabled",
"Alerts/Enabled",
"Targeting/Enabled",
"Targeting/AllowDiagonalMovement",
"Targeting/AutoSwitchProfiles",
"Targeting/NonPvpMode",
"Targeting/TargetReachable",
"Targeting/TargetShootable",
"Looting/Enabled",
"Looting/LootingRange",
"Looting/LootingPolicy",
"Looting/EatFoodFromCorpse",
"Looting/OpenBPsAtLogin",
"Looting/OpenNextBP",
"Global/BotPaused",
"Global/AlwaysOnTop"
}
Gets the given option value.
if getOption("Cavebot/Enabled") == "false" then
setOption("Cavebot/Enabled", "true")
end
If cavebot is disabled, enable it.
Available options:
options = {
"Cavebot/ShovelID",
"Cavebot/RopeID",
"Cavebot/MacheteID",
"Cavebot/PickID",
"Cavebot/Enabled",
"Cavebot/PauseBotOnDeath",
"Cavebot/MapWalkDistance",
"Cavebot/WalkThroughPlayers",
"Cavebot/IgnoreNonPathable",
"SpellHealer/Enabled",
"ItemHealer/Enabled",
"ConditionHealer/Enabled",
"Alerts/Enabled",
"Targeting/Enabled",
"Targeting/AllowDiagonalMovement",
"Targeting/AutoSwitchProfiles",
"Targeting/NonPvpMode",
"Targeting/TargetReachable",
"Targeting/TargetShootable",
"Looting/Enabled",
"Looting/LootingRange",
"Looting/LootingPolicy",
"Looting/EatFoodFromCorpse",
"Looting/OpenBPsAtLogin",
"Looting/OpenNextBP",
"Global/BotPaused",
"Global/AlwaysOnTop"
}
Sends the specified key to the client.
g_game.sendKey("F1")
Available keys:
Keys = {
"F1",
"F2",
"F3",
"F4",
"F5",
"F6",
"F7",
"F8",
"F9",
"F10",
"F11",
"F12"
}
Plays the specified sound with fileName from the sounds folder in bot's directory
playSound("alarm.wav")
Walks to the specified direction.
g_game.walk(Directions.North)
Available Directions:
Directions = {
North = 0,
East = 1,
South = 2,
West = 3,
NorthEast = 4,
SouthEast = 5,
SouthWest = 6,
NorthWest = 7,
}