Home Button Home Login Button Login Download Button Download Lua scripts list button Scripts list Lua documentation Button Lua scripting docs About FAQ Button FAQ

autoRun(integer repetitionDelay,function scriptFunction)

Will run the provided function in scriptFunction parameter every miliseconds amount provided in repetitionDelay parameter.

For example:

                    
local function spamTalk()
    talk("spam")
end

autoRun(2000, spamTalk)
                    
                

This will run spamTalk function every 2000 miliseconds(time is counted from the end of function execution)

print(string textToPrint)

Will add a new line to Logs/LuaPrint. You can use it to debug scripts or to read game state informations.

integer nowMs()

Returns current time in milliseconds. Useful for measuring time. Example:
                    
local start = nowMs()
someTimeConsumingFunction()
local now2 = nowMs()
local timeElapsed = now2 - start
                    
                

integer getPlayerHppc()

Returns your character's current hp in percentage (for example if your character has 700hp out of 1000 it will return 70)

integer getHp()

Returns the current health points

integer getMaxHp()

Returns the MAX health points

integer getPlayerMppc()

Returns your character's current mana in percentage (for example if your character has 700mp out of 1000 it will return 70)

integer getMana()

Returns the current mana points

integer getMaxMana()

Returns the MAX mana points

bool isHasted()

Will return true if your character is hasted. Otherwise returns false

table{x, y, z} getSelfPosition()

Will return x=65535, y=65535, z=255 when character is offline. Otherwise will return table with values: x, y, z. For example: local pos = getSelfPosition(). If you want to access x position then you should use pos.x etc.

string or NIL getSelfName()

Will return NIL, when character is offline. Otherwise will return the name of your character.

integer getPlayerStates()

Will returns number representing the state of your character (paralyzed, hasted, in combat etc.) These states are written in single integer and each bit contains information if the state is on or off. For example if your character is in combat it means that first least significant bit is on. So if your character only had in combat state, the function would return 1. Let's asume hasted is second least significant bit, if our character only had hasted state this function would return 2. Since states are represented as bits in returned value if your character is hasted and in combat this function would return 3 (2 for hasted bit and + 1 for combat bit)

bool playerHasState(integer state)

Will return true if the player has specified state. For example if we assume number 2 represents hasted state, then to check if your character is hasted you should Use playerHasState(2)

integer getSelfOutfitId()

Will return id of current outfit.

integer getSoul()

Will return current soul.

integer getSkillLevel(integer skillId)

Returns the current level of a skill (fishing, sword etc.). SkillId parameter is a number assigned uniquely to each skill. For example fist fighting is usually 1, so getSkillLevel(1) would return fist fighting skill level. Some servers can have different values for the same skill

integer getStamina()

Returns the stamina (in minutes). E.g 42:00 is 42 hours by 60 minutes = 2520

integer getCapacity()

Returns the current capacity of player.

integer getItemStackSize(Item item)

Returns stack size of given item. E.g 100 arrows in backpack is one item with stack size of: 100

equipItem(integer itemSlot, integer itemId, integer itemsAmount)

Will equip item with chosen itemId from open containers to chosen itemSlot. If item has less count than specified it will be equiped anyways

unequip(integer itemSlotId)

Will unequip item from equipment to one of open containers.

Possible itemSlotId values:

helmet - 1 or HELMET_SLOT
necklace - 2 or NECKLACE_SLOT
backpack - 3 or BP_SLOT
armor - 4 or ARMOR_SLOT
leftHand - 5 or LEFT_HAND_SLOT
rightHand - 6 or RIGHT_HAND_SLOT
legs - 7 or LEGS_SLOT
boots - 8 or BOOTS_SLOT
ring - 9 or RING_SLOT
ammo - 10 or AMMO_SLOT

integer getInventoryItemId(integer itemSlotId)

Returns id of an item which player has equiped. 0 indicates empty

Item getInventoryItem(integer itemSlotId)

Returns an item which player has equiped.

Item getTopUseItem(integer x, integer y, integer z)

Returns usable item on top of provided position (water and other ground tiles are counted as top usable item)

moveItem(Item itemToMove, integer x, integer y, integer z)

Moves item to given position

useItem(integer itemId)

Will try to use item which player has in one of his backpacks with a chosen itemId. In a way it simulated an 8.0 tibia hotkey use so player can use item with backpack closed

useItem(Item item)

Uses an item

useItemInContainer(integer itemId)

Will try to use item which is present in open containers

openItemInContainer(integer itemId)

Will try to open item which is present in open containers

usePosition(integer x, integer y, integer z)

Will use the item at position x, y, z

bool moveItemToContainerWithId(integer containerId, integer movedItemId)

Will move item with provided id (movedItemId) to a open container with id (containerId).

Returns true if bot found aproperiate items and tried to move. False otherwise

bool useInventoryItemOnNearbyGroundItem(integer itemFromInventoryId, integer groundItemId)

Will try to use item which character has in one of his bps with id(itemFromInventoryId) on the groundItem with id(groundItemId) withing 1 sqm

Returns true if bot found aproperiate items and tried to use on ground item. False otherwise

bool useItemFromOpenContainerOnNearbyGroundItem(integer itemFromInventoryId, integer groundItemId)

This one requires open backpack with wanted item. Simulates useWith from backpack on the ground.

Returns true if bot found aproperiate items and tried to use on ground item. False otherwise

useInventoryItemOnNearbyGroundItems(integer itemFromInventoryId, integer groundItemId)

Same as useInventoryItemOnNearbyGroundItem but will try to use on all nearby items instead of one.

useItemFromOpenContainerOnNearbyGroundItems(integer itemFromInventoryId, integer groundItemId)

Same as useItemFromOpenContainerOnNearbyGroundItem but will try to use on all nearby items instead of one.

useInventoryItemOnThing(integer itemId, Thing thing)

Will make your character use item on provided Thing(creature, item)

useItemFromOpenContainerOnThing(integer itemId, Thing thing)

Will make your character use item on provided Thing(creature, item). Requires backpack to be open with inventory item (this is like doing use with from backpack on a sqm with given item/creature).

useItemFromOpenContainerOnSelf(integer itemId)

Uses item on yourself. Requires backpack to be open with inventory item (this is like doing use with from backpack on self).

useItemWithSubtypeFromOpenContainerOnSelf(integer itemId, integer subtype)

Uses item with given subtype on yourself. Requires backpack to be open with inventory item (this is like doing use with from backpack on self). On some server manafluid has the same id as life fluid. But they have differnt subtype. Using this function you can avoid problem of bot trying to use empty vials.

useManafluidOnSelf()

Will use mana fluid from backpack on your character (works as if you clicked use with on your character). Supports only 7.4 and 8.0 mana fluids

useLifefluidOnSelf()

Will use life fluid from backpack on your character (works as if you clicked use with on your character). Supports only 7.4 and 8.0 life fluids

useNearbyGroundItem(integer groundItemId)

Will make your character use item with id(groundItemId) withing 1 sqm.

integer getItemCount(integer itemId)

Will return the amount of items that are visible in opened containers

useInventoryItemOnInventoryItem(integer itemFromInventoryId, integer otherInventoryItemId)

Will try to use item which character has in one of his bps with id(itemFromInventoryId) on the item with id(otherInventoryItemId) in any of open backpacks

useInventoryItemOnInventoryItem2(integer itemFromInventoryId, integer groundItemId)

Will try to use item which character has in one of his bps with id(itemFromInventoryId) on the item with id(otherInventoryItemId) in any of open backpacks. Please use this version if useInventoryItemOnInventoryItem doesn't work

useItemOnMostMonsters(integer itemId, integer range, integer runeAoe)

Uses the item (itemId) on most monsters within range. runeAoe can either be:
  • 0 or RUNE_GFB
  • 1 or RUNE_Fireball
  • Example: useItemOnMostMonsters(3191, 7, RUNE_GFB)

    collectNearbyGroundItem(integer containerId, integer groundItemId)

    Will take ground item with provided id(groundItemId) within 1 sqm of the character to a open container with id (containerId)

    collectNearbyGroundItemMoveCorpses(integer containerId, integer groundItemId)

    Will take ground item with provided id(groundItemId) within 1 sqm of the character to a open container with id (containerId). If the ground item is covered by corpse or any other item the item will be moved to player position first

    collectGroundItem(integer containerId, integer groundItemId)

    Will take ground item with provided id(groundItemId) from distance

    dropItem(integer itemId, integer itemCount)

    Drops item under your character.

    bool isContainer(Item item)

    Returns true if item is a container. Otherwise returns false

    integer getId(Thing thing)

    Returns id of a thing (itemId for item, unique creatureId fo creatures)

    table{x, y, z} getPosition(Thing thing)

    Will return x=65535, y=65535, z=255 when thing argument is invalid. Otherwise will return table with values: x, y, z.

    attack(Creature creatureToAttack)

    Will attack creatureToAttack.

    integer countScreenCreatures(string pattern)

    Will return the amount of creatures that have a name which contains the pattern. For example monsterName is Dragon. countScreenCreatures("Drag") will count Dragons as well as any other monster which has Drag in it's name. So if there are Dragon Lords and Dragons the countScreenCreatures("Drag") will count both of them

    Creature{} getScreenPlayers()

    Will return array with all visible players on the same floor.

    Creature{} getScreenMonsters()

    Will return array with all visible monsters on the same floor.

    Creature{} getCreaturesMultiFloor()

    Will return array with all visible creatures on all aware floors (includes your character).

    integer getScreenMonstersCountInRange(integer range)

    Will return amount of monsters within range

    integer getScreenPlayersCountInRange(integer range)

    Will return amount of players within range (excluding yourself)

    string getCreatureName(Creature wantedCreature)

    Will return the name of wanted creature.

    integer getCreatureHppc(Creature wantedCreature)

    Will return percentage of current hp of the wanted creature.

    integer getPartyShield(Creature wantedCreature)

    Will return the id of party shield icon for specified creature (wanted creature parameter)

    integer getSkull(Creature wantedCreature)

    Will return the id of wanted creature skull icon

    integer getEmblem(Creature wantedCreature)

    Returns id of creature emblem (e.g warmode emblems)

    integer getType(Creature wantedCreature)

    Returns type of a creature (from game server source code: 0 - player, 1 - monster, 2 - npc, 3 - summon own, 4 - summon other)

    integer getOutfitId(Creature creature)

    Will return id of creature's outfit

    setOutfit(Creature creature, integer outfitId)

    Will set the outfit of creature to provided outfitId

    mapClick(integer x, integer y, integer z)

    Makes mapclick on given position

    mapClickChase(Creature chasedCreature)

    Will send mapclick on sqm which is closest to the chasedCreature

    bool isMonster(Creature creature)

    Returns true if creature is a monster. Otherwise returns false

    bool isPlayer(Creature creature)

    Returns true if creature is a player. Otherwise returns false

    integer getDirection(Creature creature)

    Returns a number which corresponds to the direction that a creature is facing

    0 or DIR_NORTH - north
    1 or DIR_EAST - east
    2 or DIR_SOUTH - south
    3 or DIR_WEST - west
    4 or DIR_NE - north east
    5 or DIR_SE - south east
    6 or DIR_SW - south west
    7 or DIR_NW - north west

    Container{} getOpenContainers()

    Will return array with all open containers

    Item{} getItems(Container container)

    Will return array of items that are inside the container.

    Item or NIL getContainerItem(Container container)

    Returns an item associated with the container. Returns NIL if invalid container was passed.

    moveItemToContainer(Item item, Container container, integer count)

    Moves item to first available slot in the container. Count bigger than 1 affects stackable items. E.g if you have 50 arrows you can use count 35 to move just 35 arrows from that stack.

    open(Item item, Container parentContainer)

    Opens an item in the same window. The item must be present in parentContainer. E.g it can open bag in a bag.

    openInNewWindow(Item item)

    Opens an item in the new window.

    sendKey(string hotkey)

    Will simulate key press. Available keys:

    a) F1 - F12 keys
    b) alphabetical keys (A-Z)
    c) special keys ("Enter", "Left", "Right", "Up", "Down")

    talk(string message)

    Will send a message on default channel

    move(integer direction)

    Will move your character to one of following directions:

    0 or DIR_NORTH- north
    1 or DIR_EAST - east
    2 or DIR_SOUTH - south
    3 or DIR_WEST - west
    4 or DIR_NE - north east
    5 or DIR_SE - south east
    6 or DIR_SW - south west
    7 or DIR_NW - north west

    Creature or NIL getCreatureByName(string name)

    Returns creature, which is visible on screen and has provided name. Returns NIL if such creature isn't visible on the screen

    goToLabel(string labelName)

    Will make cavebot jump to waypoint which is labeled by provided labelName

    integer getKilledMonstersCount(string monsterName)

    This function only works when Hunt is started in HuntFrame. It will return the amount of monsters you have killed. This works based on loot of a MOB_NAME message so please remember about leaving the party

    resetKilledMonstersCount(string monsterName)

    Will reset kill count for provided monster. It is useful after you complete a task.

    acceptParty(string{} partyLeaders)

    Will accept party from player whose name is specified in partyLeaders. For example: acceptParty({"Leader1, Big Ben"}) Whenever Leader1 or Big Ben invite you to the party you will accept the invite.

    partyInvite(string{} partyMemberNamesToInvite)

    Will invite a player present in the partyMemberNamesToInvite if he isn't in the party. For example: partyInvite({"Bob", "Elite Maciek"}) Whenever Bob or Elite Maciek is visible on screen, he will be invited to the party.

    sleep(integer miliseconds)

    Will pause the script for provided miliseconds time.

    setChaseMode(integer mode)

    Will change the chase mode. 0 - stand, 1 - chase

    foreachMessage(function functionHandlingNewMessage)

    Will call functionHandlingNewMessage everytime new message was sent to the client.

    For example:
     local function alarm(msg)
      if msg.content == "Are you botting?" and msg.sender == "GM Antibot" then
       playSound("botcheck.wav")
      end
     end

    foreachMessage(alarm)

    msg parameter has the following attributes:
    string msg.content - the content of message
    string or NIL msg.sender - the sender of message
    integer or NIL msg.level - the level of sender
    integer msg.mode - the mode of message (all modes will be provided in further section)
    integer or NIL msg.channel - the id of message channel (the id may change depending on which channel is open)
    integer or NIL msg.x - x position of the message
    integer or NIL msg.y - y position of the message
    integer or NIL msg.z - z position of the message

    msg modes(some may be unused) The number corresponds to the msg.mode value integer:
    1. MessageSay
    2. MessageWhisper
    3. MessageYell
    4. PrivateFrom
    5. MessagePrivateTo
    6. MessageChannelManagement
    7. MessageChannel
    8. MessageChannelHighlight
    9. MessageSpell
    10. MessageNpcFrom
    11. MessageNpcTo
    12. MessageGamemasterBroadcast
    13. MessageGamemasterChannel
    14. MessageGamemasterPrivateFrom
    15. MessageGamemasterPrivateTo
    16. MessageLogin
    17. MessageWarning
    18. MessageGame
    19. MessageFailure
    20. MessageLook
    21. MessageDamageDealed
    22. MessageDamageReceived
    23. MessageHeal
    24. MessageExp
    25. MessageDamageOthers
    26. MessageHealOthers
    27. MessageExpOthers
    28. MessageStatus
    29. MessageLoot
    30. MessageTradeNpc
    31. MessageGuild
    32. MessagePartyManagement
    33. MessageParty
    34. MessageBarkLow
    35. MessageBarkLoud
    36. MessageReport
    37. MessageHotkeyUse
    38. MessageTutorialHint
    39. MessageThankyou
    40. MessageMarket
    41. MessageMana
    42. MessageMonsterYell
    43. MessageMonsterSay
    44. MessageRed
    45. MessageBlue
    46. MessageRVRChannel
    47. MessageRVRAnswer
    48. MessageRVRContinue
    49. MessageGameHighlight
    50. MessageNpcFromStartBlock

    playSound(string fileName)

    Will play .wav file from Alarms directory

    setGlobal(string globalName, string or integer data)

    Will store value(data parameter) in global storage of name(globalName). The global storage can be used to share data in between scripts/cavebot

    string or integer or NIL getGlobalstring globalName)

    Will return value from global storage which was previoused saved by setGlobal. If no global was set then NIL will be returned

    flashWindow()

    Will flash the current game window

    writeToFile(string fileName, string content)

    Will the content to the file specified in fileName relative to the bot directory. It means that if fileName is "logs.txt", then a file logs.txt will be created in bot directory
    If you want to enter newLine then use "\n". For example writeToFile("test message\n", "logs.txt")

    npcTalk(string message)

    Will send a message on npc channel

    tradeTalk(string message)

    Will send a message on trade channel. May not work on some server because they have different channelId. Use talkChannel function in such case

    talkChannel(integer mode, integer channelId, string message)

    Will send a message on specified channel with specified mode. Useful because some servers have different channelId for game chat. Therefore you can adjust channelIds manually to talk on wanted chat

    talkPrivate(string receiver, string message)

    Sends a private message to receiver.

    cancelAttack()

    Will stop attacking the current target

    turn(integer direction)

    Will make your character turn to one of following directions:

    0 or DIR_NORTH- north
    1 or DIR_EAST - east
    2 or DIR_SOUTH - south
    3 or DIR_WEST - west

    allowWalk(integer itemId)

    Makes the item walkable. The cavebot and targetings will be able to move through these items.

    disallowWalk(integer itemId)

    Makes the item NOT walkable. The cavebot and targetings will NOT move through these items.

    enableTargeting(bool on)

    Will enable or disable (on - true will enable, or - false will disable) main's frame targeting. If you switch to pvp tab it will work only for pvp targeting (likewise for pve).

    enableCavebotTargeting(bool on)

    Will enable or disable (on - true will enable, or - false will disable) cavebot targeting.

    Creature or NIL getAttackingCreature()

    Will return creature which is currently being attacked (also known as targeted) or NIL if no creature is currently attacked.

    hideOrShowMainWindow()

    Hides the main bot window if it is shown. Shows the main bot window if it is hidden.

    integer or NIL getDistanceFromThing(Thing wantedThing)

    Will return distance from wantedThing. When player is offline it returns NIL. When thing is on different floor it also returns NIL.

    loadWaypoints(string fileName)

    Will load waypoints from Cavebot directory

    stackItems()

    Will stack items in open containers

    shutdownPc()

    Will shutdown your PC

    xlog()

    Will show login screen. The character is still online

    enableFollowWaypoints(bool on)

    Will enable or disable (on - true will enable, or - false will disable) following waypoints. Cavebot scripts and targeting will work. Reenabling cavebot in GUI will enable it back

    reachGroundItem(integer itemId)

    Will make your character mapclick near the ground item with itemId.

    integer countGroundItems(integer itemId)

    Will return the amount of ground items currently visible by the player with given id

    enableScript(string scriptName, bool on)

    Turn on (on = false) or off (on = false) all scripts which have name equal to provided scriptName. IMPORTANT: You cannot make script disable itself. In such case the script will hang and will not be recoverable.

    enableCavebotScript(string scriptName, bool on)

    Turn on (on = false) or off (on = false) all cavebot scripts which have name equal to provided scriptName. IMPORTANT: You cannot make script disable itself. In such case the script will hang and will not be recoverable.

    enableBot(bool on)

    Turn on (on = false) or off (on = false) all most of bot functionalities (except extras, hunt and hotkeys)

    enableSpellcasting(bool enable)

    Will enable or disable spellcasting for currently active tab(PVE or PVP) depending on enable parameter(true - enable, false - disable)

    forceOffensiveSpell(string spellName, integer time)

    Will pause offensive spellcasting rotation and only try to use the spell with spellName parameter for specifiec amount of time(time parameter in miliseconds). The chosen spell will use pre and post casts delay as well condition to see if it should be used. Good usage: For example our character has 3 spells which are casted one after another for best DPS. However we also have special spells which we don't use very often. In order to use this special spell on demand we can create hotkey: forceOffensiveSpell("Stun", 1100). Now if we click this hotkey multiple times the spell should be cast and later on the character will fallback to using the offensive rotation. Using forceOffensiveSpell("MW", 1100) is a special invokation for disabling offensive rotation. It is worth on some servers which have magic walls which share cooldown. For example you could have F3 hotkey with mwall crosshair + F3 hotkey in the bot with forceOffensiveSpell("MW", 1100) so the wall can be used ASAP.

    forceSupportiveSpell(string spellName, integer time)

    Same as forceOffensiveSpell but for supportive spellcasting rotation.

    bool areSpellRangeConditionsMet(string spellName)

    Checks if spell with spellName is defined in currently active spellcasting and checks if area/range requirements are met.

    bool areSpellRangeConditionsMetForCreature(string spellName, Creature creature)

    Checks if spell with spellName is defined in currently active spellcasting and checks if area/range requirements are met for a given creature.

    castSpell(string spellName)

    If spell with spellName is defined in currently active spellcasting it will use this spell and apply all required actions (like auto turn)

    ITEMS FRAME

    forceItemUse(string spellName, integer time)

    Same as forceOffensiveSpell but for item rotation