Announcement

Collapse
No announcement yet.

MediviaBotter - Documentation

Collapse
This topic is closed.
X
This is a sticky topic.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • MediviaBotter - Documentation

    Player information


    number getid()
    Returns the unique ID for the character.

    number posx()
    Returns the X-position.

    number posy()
    Returns the Y-position.

    number posz()
    Returns the Z-position.

    number gethp()
    Returns the current hitpoints.

    number getmaxhp()
    Returns the maximum amount of hitpoints.

    number getmana()
    Returns the current mana.

    number getmaxmana()
    Returns the maximum amount of mana.

    number getcap()
    Returns the current capacity.

    number getlevel()
    Returns the current level.

    number getexperience()
    Returns the current experience.

    item getslotitem(number slotid)
    Returns an item object containing the information about the slot id.
    A list of the constants for slot id can be found here

    Example:

    if getslotitem(SLOT_LEFT).id == itemid("blank rune") then
    say("adori gran")
    end


    creature getattacking()
    Returns a creature object containing information about the current target.

    creature getfollowing()
    Returns a creature object containing information the creature that is being followed.

    boolean getonline()
    Returns true if a character is logged in, false otherwise.

    creature getself()
    Returns a creature object containing information about the logged in character.

    bool getplayerstate(number flag)
    Returns true if the player is in the state by the given flag. False otherwise. A list of flags can be found here.

    Example:
    if not getplayerstate(STATE_MANASHIELD) then
    say("utamo vita")
    wait(500,700)
    end


    number getstandtime()
    Returns how long the character has been standing still in milliseconds.

    Player functions


    void move(number direction)
    Moves the character one step in the given direction.
    A list of the constants for direction can be found here.

    void turn(number direction)
    Turns the character to the given direction.
    A list of the constants for direction can be found here.

    void say(string message, optional number mode, optional number channel, optional string receiver)
    Says a message in the given mode and channel. Can be also be used to send private messages by usingthe appropriate channel parameter and specifying the receiver. Only passing the message to the function will say the message in Local Chat.
    A list of the constants for mode and channel can be found here.

    void useitem(number or string id, table item location, optional index, optional stackpos)
    Uses an item given by the id at item location. The id parameter can either passed as the actual id of the item or the name of the item. The item location table can be produced by using the ground(x, y, z), slot(slotid) or container(containerindex, slot) functions. The index parameter is used for opening containers where index will be the index for the newly opened container. The stackpos parameter is used when the item is elevated by objects such as parcels. For an alternative, see the item object use method.

    Example:

    --Eat a brown mushroom from container index 0, slot 5.
    useitem("brown mushroom", container(0, 5))


    void moveitem(number or string id, table from location, table to location, optional number count, optional number stackpos)
    Moves an item given by id from given from location to to location. To create the location tables, see useitem. The count parameter determines how many items to move. If not count parameter is given, the entire stack will be moved. For stackpos reference, see useitem. For an alternative, see the item object move method.

    Example:

    --Move a blank rune from a container to the right hand
    moveitem("blank rune", container(0, 5), slot(SLOT_RIGHT))


    void useitemon(number use id, table from location, number useon id, table to location, optional number fromstackpos, optional number tostackpos)
    Uses an item use id located at from location on another item useon id located at to location. To generate the location tables, see useitem. For reference on fromstackpos and tostackpos, see useitem. For an alternative, see the item object useon method.

    void useoncreature(number itemid, table from location, number creatureid, optional creaturestackpos)
    Uses an item itemid located at from location on a creature with id creature id. This will only work on monsters, not on players due to restrictions on Medivia server side. For reference on creaturestackpos, see useitem. For an alternative, see the item object useoncreature method.

    void attack(number id)
    Attacks the creature with the given id.

    void logout()
    Logs out the character.

    void closecontainer(number index)
    Closes the container with the given index.

    void openparentcontainer(number index)
    Opens the parent container of the container with the given index.

    Item information


    number itemid(string itemname)
    Returns the id of the given itemname.

    string itemname(number itemid)
    Returns the name of the given itemid.

    Tile information


    tile gettile(number x, number y, number z)
    Returns the tile at the given x, y, z location.

    item gettopuseitem(number x, number y, number z)
    Returns the top item object that can be used at the given x, y, z location.

    Creature information


    table getcreatures()
    Returns a table containing all the creatures objects that the client knows of. (Including creatures on other floors)

    Container information


    table getcontainers()
    Returns a table containing all the containers objects that are open.

    number getcontainercount()
    Returns the amount of containers currently open.

    Message information


    table getmessages()
    Returns a table of all the messages as message objects since the bot started. See message object.

    table getnewmessages()
    Returns a table of all the messages as message objects since the last call to getnewmessages() in the same context (i.e. the same script instance). See message object.



    Bot functions


    void print(... string messages)
    Prints the given messages to the Lua console.

    void wait(number min, optional number max)
    Stops the execution of the script for either exactly min milliseconds or a random number of milliseconds between min and max.

    void auto(number min, optional number max)
    Reschedules the current script for execution in either exactly min milliseconds or a random number of milliseconds between min and max.

    table ground(number x, number x, number x)
    Returns a table containing the given ground information to be used for functions that need a location parameter.

    table container(number containerindex, number slot)
    Returns a table containing the given container information to be used for functions that need a location parameter.

    table slot(number slotid)
    Returns a table containing the given equipment slot information to be used for functions that need a location parameter.

    gotolabel(string/number labelorid)
    Switches the current waypoint to the given waypoint label or id.

    table getwaypoints()
    Returns a table of waypoint objects containing information about the waypoints.

    waypoint currentwpt()
    Returns a waypoint object containing information about the current waypoint.

    boolean walk(number x, number x, number x, optional number walktype)
    Walks to the given location x, y, z. Returns true if succeeded, false otherwise. The parameter walktype can be used to specify how the walker should act. Note that this function overrides the cavebot walking, but not the targeting walking and will return false if the targeting overrode the function. The constants for the walktype can be found here.

    void alert(optional string file)
    Plays a sound from the MediviaBotterPath/sound directory given by file. If no file is given, the default sound will be played.

    void flashclient()
    Flashes the client.

    void setcavebot(boolean state)
    Sets the cavebot engine state to the given state.

    void settargeting(boolean state)
    Sets the targeting engine state to the given state.

    void sethealer(boolean state)
    Sets the healer engine state to the given state.

    void setlooting(boolean state)
    Sets the looting engine state to the given state.

    void pausebot(boolean state)
    Sets the input engine state to the given state.

    boolean getcavebot()
    Returns the state of the cavebot engine.

    boolean gettargeting()
    Returns the state of the targeting engine.

    boolean gethealer()
    Returns the state of the healer engine.

    boolean getlooting()
    Returns the state of the looting engine.

    boolean ispaused()
    Returns the state of the bot input engine.

    boolean ishealeractive()
    Returns true if the healer is waiting to cooldown in order to use a healing spell. Useful for creating scripts which uses spells but does not what to interfere with the healer.

    void setsetting(string path, any value)
    Sets the given settings path to the given value.

    Example:
    setsetting('Looting/OpenNextBackpack', false)
    setsetting('Targeting/Danger', 3)


    any getsetting(string path)
    Returns the setting of the given path.

    Example:
    local mustAttackMe = getsetting('Targeting/MustAttackMe')


    seteventcallback(number eventid, function callback)
    Registers for callbacks when events are fired. See the event constants below for potential events.

    Example:
    function loot_item(id, count)
    print(id, count)
    end

    seteventcallback(EVENT_LOOT_ITEM, loot_item)


    HUD functions



    void sethudscript(boolean enabled)
    Enables or disables the current script has a HUD script. This enables the script to make HUD specific function calls.

    void addhudtext(string text, number x, number y)
    Draws the given text at the given coordinates x, y.

    void setfont(number font)
    Sets the font to be used for future addhudtext calls.

    void setfontcolor(variant color)
    Sets the color to be used for future addhudtext calls. The color argument can be passed in three different ways. Either as a integer where the the channels are represented as 0xAARRGGBB. A table containing the keys a, r, g, b is also accepted. Finally you can pass a hex string as '#aarrggbb', '#rrggbb' or simply 'rrggbb'.

    void setfontopacity(float opacity)
    Sets the font opacity to be used for future addhudtext calls. Opacity has to be a number between 0 and 1.

    number getfont()
    Returns the current font.

    variant getfontcolor()
    Returns the current font color.

    float getfontopacity()
    Returns the current font opacity.
    Last edited by ottizy; 06-03-2018, 09:16 PM.

  • #2
    Item object


    Variable members


    number .id The id of the item.
    number .count The count of the item.
    number .slot The equipment or container slot.
    number .x The ground x position.
    number .y The ground y position.
    number .z The ground z position.

    Method members



    void :use(optional number index, optional number stackpos) Uses the item. Optional parameters for opening backpacks at a specific index and if the item is elevated by parcels etc.
    Example:

    --Eat a brown mushroom
    local mushroom = finditem("brown mushroom")
    if mushroom.id ~= 0 then
    mushroom:use()
    end


    void :move(table to location, optional number count, optional number index, optional number stackpos) Moves the item to the given to location. If no count parameter is passed, all items in the stack will be moved.

    Example:

    --Move a blank rune to the right hand
    local rune = finditem("blank rune")
    if rune.id ~= 0 then
    rune:move(slot(SLOT_RIGHT))
    end


    void :useon(table useon location, number useonid, optional number fromstackpos, optional number tostackpos) Uses the item on another item useonid located at useon location.

    Example:

    --Use a HMM on the currently targeted creature
    local target = getattacking()
    local rune = finditem("heavy magic missile rune")
    if target.id ~= 0 and rune.id ~= 0 then
    rune:useon(ground(target.x, target.y, target.z), target.id, 0, target.stackpos)
    end


    void :useoncreature(number creatureid, optional number stackpos) Uses the item on the given creature with the given creatureid. Only works on monsters.

    Example:

    --Use a HMM on the currently targeted monster
    local target = getattacking()
    local rune = finditem("heavy magic missile rune")
    if target.id ~= 0 and rune.id ~= 0 then
    rune:useoncreature(target.id, target.stackpos)
    end
    Last edited by ottizy; 12-02-2017, 02:32 PM.

    Comment


    • #3
      Creature object


      Variable members


      number .id The id of the creature.
      string .name The name of the creature.
      number .x The x coordinate of the creature.
      number .y The y coordinate of the creature.
      number .z The z coordinate of the creature.
      boolean .ismonster True if the creature is a monster, false otherwise.
      boolean .isplayer True if the creature is a player, false otherwise.
      boolean .samefloor True if the creature is on the same floor as the character, false otherwise.
      boolean .onscreen True if the creature is visible on the screen, false otherwise.
      number .hppc The hitpoint percentage of the creature.
      boolean .blacksquare True if the blacksquare is visible on the creature i.e. the creature is attacking the character, false otherwise.
      number .dir The direction of the creature.
      number .stackpos The stackpos of the creature.

      Method members


      void :attack() Attacks the creature.
      Last edited by ottizy; 18-02-2017, 04:10 PM.

      Comment


      • #4
        Tile object


        Variable members


        number .x The x coordinate of the tile.
        number .y The y coordinate of the tile.
        number .z The z coordinate of the tile.
        table .items A table of item objects containing information about the items on the tile.
        Last edited by ottizy; 12-02-2017, 02:02 AM.

        Comment


        • #5
          Waypoint object


          Variable members


          number .id The waypoint id.
          string .label The waypoint label.
          number .type The waypoint type.
          Last edited by ottizy; 12-02-2017, 02:01 AM.

          Comment


          • #6
            Container object


            Variable members


            number .id The id of the container.
            number .index The index of the container.
            number .capacity The capacity of the container.
            string .name The name of the container.
            table .items A table of item objects containing information about the items in the container.

            Method members


            void :close() Closes the container.
            void penparent() Opens the parent container.
            Last edited by ottizy; 07-06-2017, 04:45 PM.

            Comment


            • #7
              Constants


              Slot IDs


              SLOT_HELMET = 1
              SLOT_AMULET = 2
              SLOT_BACKPACK = 3
              SLOT_ARMOR = 4
              SLOT_RIGHT = 5
              SLOT_LEFT = 6
              SLOT_LEGS = 7
              SLOT_FEET = 8
              SLOT_RING = 9
              SLOT_AMMO = 10

              Channel IDs


              MSG_DEFAULT = 1
              MSG_WHISPER = 2
              MSG_YELL = 3
              MSG_PRIVATE = 4
              MSG_CHANNEL = 7
              MSG_MONSTER_YELL = 43

              Speak modes


              SAY_NORMAL = 1
              SAY_WHISPER = 2
              SAY_YELL = 3

              Direction IDs


              DIR_NORTH = 0
              DIR_EAST = 1
              DIR_SOUTH = 2
              DIR_WEST = 3
              DIR_NORTHEAST = 4
              DIR_SOUTHEAST = 5
              DIR_SOUTHWEST = 6
              DIR_NORTHWEST = 7

              Walk types


              WALKER_STAND = 1
              WALKER_NODE = 2
              WALKER_REACH = 8

              Player state flags


              STATE_POISON = 1
              STATE_FIRE = 2
              STATE_ENERGY = 4
              STATE_DRUNK = 8
              STATE_MANASHIELD = 16
              STATE_PARALYZED = 32
              STATE_HASTE = 64
              STATE_COMBAT = 128
              STATE_HUNGRY = 1024
              STATE_INPZ = 2048
              STATE_PZBLOCK = 8192

              -Screen information


              SCREEN_LEFT = -8
              SCREEN_TOP = -6
              SCREEN_BOTTOM = 7
              SCREEN_RIGHT = 9

              Location constants


              LOCATION_INVENTORY = 0
              LOCATION_EQUIPMENT = 1
              LOCATION_GROUND = 2

              Event constants


              EVENT_LABEL_CHANGED = 0
              EVENT_MOUSE_DOWN = 1
              EVENT_MOUSE_UP = 2
              EVENT_MOUSE_MOVE = 3
              EVENT_LOOT_ITEM = 4
              EVENT_SUPPLY_USED = 5
              Last edited by ottizy; 20-02-2017, 08:01 PM.

              Comment


              • #8
                Message object


                Variable members



                string .text The message text.
                string .sender The sender of the message.
                number .mode The message mode. Yell, whisper etc.
                number .channel The channel the message was sent in. Can be more then just channels, also things like MONSTER_YELL etc.

                Comment

                Working...
                X