Results 1 to 9 of 9

Thread: AeroLib - Interacting with the game interface

  1. #1
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default AeroLib - Interacting with the game interface

    AeroLib scripting
    Interacting with your in-game interface

    As an attempt to better familiarize scripters with AeroLib I've decided to write a few tutorials outlining some of the basics needed to write scripts. Throughout the tutorials I'm going to assume you have at least basic experience working with Simba already. Before we begin I would recommend you read my tutorial about AeroLib Core functionality for a more complete understanding of the very basics of the include as we'll be using this knowledge and putting the code to work. Also, this tutorial will not feature all of the available functions & procedures in each of the given fields, only what I consider the most vital and convenient for scripting. If you'd like to see the full cache of what's available, I invite you to simply explore AeroLib for yourself.


    Basically everything excluding the mainscreen. This pretty much pertains to gathering information about your player; your items, levels and so on. So starting with the very beginning of the tutorial, let's take a look at handling game tabs.


    Part 1: Code references

    GameTabs
    AeroLib/core/gametabs/

    getCurrentTab()
    - Gets the currently opened gametab
    - Possible results are: TAB_COMBAT, TAB_STATS, TAB_QUEST, TAB_INV, TAB_EQUIP, TAB_PRAYER, TAB_MAGIC, TAB_FRIENDS, TAB_IGNORE, TAB_LOGOUT, TAB_OPTIONS, TAB_EMOTES, TAB_MUSIC

    gameTab(Tab: Integer)
    - Switches to the desired game tab via moving the mouse & clicking.
    - Will result in True if successfully switched, False if not successful

    FTab(Tab: Integer)
    - Same as gameTab however F-buttons are used to switch to the desired gametab.


    Inventory
    AeroLib/core/gametabs/Inventory.simba

    invBox(I: Integer)
    - Results in a TBox of the inventory slot I

    itemInSlot(I: Integer)
    - Results True if an item exists in the inventory slot I, False if the slot is empty
    - If you've the deposit box screen opened, the function will check if the given slot in the deposit box is currently occupied

    getInvCount()
    - Gives you the current number of items in your inventory

    isInvFull() / isInvEmpty()
    - Result True if the inventory is full/empty (respectively), False if not.

    getItemAmount(Pnt: TPoint)
    - Returns the amount of the item at the given point (not slot)
    - Only works for an item in a single slot

    interactSlot(Slot: Integer; action: Variant; miss: Boolean=False)
    - Moves the mouse to Slot and initiates an action. This could be left/right clicking the item (MOUSE_LEFT/MOUSE_RIGHT) or right-click and selecting an option (ex: 'Drop')

    fastDropSlots(Slots: TIntegerArray)
    - Quickly drop an array of items within Slots using the shift-click drop method (this must be enabled in your game settings!)

    moveItemTo(Slot, targetSlot: Integer)
    - Drag an item from Slot to the targetSlot

    dragItemToPoint(Slot: Integer; Point: TPoint)
    - Same as moveItemTo but drags the item in Slot to a given point, in the parameter Point

    slotActivated(Slot: Integer)
    - Returns True if the item in Slot is activated (highlighted by selecting "Use"), False if not

    anySlotActivated()
    - Returns True if any inventory slot is currently activated, False if not

    waitInvChange(MaxTime: Integer)
    - Waits a given time (MaxTime) for the inventory count to change, whether an item is added or removed


    Combat
    AeroLib/core/gametabs/Misc.simba

    getCombatLevel() (Located in AeroLib/core/gametabs/Skills.simba
    - Returns your combat level

    setFightMode(Mode: Integer)
    - Switch your player's fight mode (1-4)

    getSpecialPercent()
    - Returns the percent of special special power you have left, if any

    enableSpecialAttack(SwitchBack: Boolean=false)
    - Initiates a special attack. If SwitchBack is set to True, the script will return to your previous game tab

    setRetaliate(Enable: Boolean)
    - Enables or disables your auto-retaliate setting


    Skills
    AeroLib/core/gametabs/Skills.simba

    getSkillCurrentLevel(Skill: Variant) / getSkillMaxLevel(Skill: Variant)
    - Returns your current or max skill level for Skill. Valid Skill parameters are SKILL_ATTACK through SKILL_FARMING or 'attack' through 'farming'

    getTotalLevel()
    - Returns your skill total level

    getSkillXP(skill: variant)
    - Returns the XP you have in skill. Valid Skill parameters are SKILL_ATTACK through SKILL_FARMING or 'attack' through 'farming'


    Prayer
    AeroLib/core/gametabs/Prayer.simba

    isPrayerActive(PrayerName: String)
    - Returns True if the prayer PrayerName is active, False if not. A valid PrayerName parameter must be the exact name of the prayer, capitalized. Ex: isPrayerActive('Rapid Heal')

    togglePrayer(PrayerName: string; Enable: Boolean)
    - Toggles the prayer PrayerName on or off via the parameter Enable


    Magic
    AeroLib/core/gametabs/Magic.simba

    isSpellSelected
    - Returns True if any spell is currently selected, False if none

    isSpellActive(SpellName:String)
    - Returns True if the spell SpellName is able to be cast (Ex: The player has sufficient runes for the given spell), False if the spell is grayed out

    castSpell(SpellName: String)
    - Left-clicks on the given spell SpellName if the spell is active. Result True if successful, False if not (Ex: Wrong spell book or grayed out spell icon)


    Logout / WorldSwitcher
    AeroLib/entities/player/Login.simba
    AeroLib/core/gametabs/WorldSwitcher.simba

    logoutPlayer()
    - Logs out the player, even if the world-switcher is currently open

    WS_toggle(Open: Boolean = True)
    - Toggles the world-switcher. If Open is set to true, the world-switcher will be opened, if set to False it will be closed

    WS_switchWorlds(World: Integer)
    - Hops to the world labeled as World. Results in True if successful, False if unsuccessful

    WS_switchRandomWorld()
    - Switches worlds to a random world based off your player's member status


    Settings
    AeroLib/core/gametabs/Settings.simba

    fixGraphics()
    - Sets your client settings to the default settings required for most scripts (Max brightness, default camera zoom, 2 mouse buttons, audio disabled, and accept aid disabled)


    ChatBox
    AeroLib/core/Chat.simba

    getDisplayName()
    - Returns your display name

    clickContinue(DoWait: Boolean)
    - Clicks the "Click here to continue" option in the chat box. If DoWait is set to True the script will wait until the message is no longer visible

    continueChat(Wait: Boolean = True)
    - Same as the above function however the space bar is used as opposed to left-clicking

    getChatBoxText(Line, TextCol: Integer)
    - Gets the chatbox text on Line with the given color of TextCol

    findGameMessageAnyLine(Text: string)
    - Returns True if the message Text is found in any chat box line. This function only search for game message (black text)

    findBlackChatMessage(ChatMsg: string)
    - Returns True if a black chat message is found anywhere in the chat box, False if not

    findMSChat()
    - Returns True if chat text (yellow text) is found in the mainscreen, False if not

    areTalking()
    - Returns True if you're currently talk with a NPC, False if not

    chatOptionScreen()
    - Returns True if chat options screen is open, False if not

    findChatOption(Text: string; Click: Boolean)
    - Returns True if the chat option Text is found in the chat box, False if not. Also the option will be left-clicked if Click is set to True

    doConversation(resultText: TStringArray)
    - This will continually continue a chat conversation with an NPC until the chat option(s) resultText is(are) found. If True then the specified chat option will be left-clicked


    Orbs
    AeroLib/core/minimap/Orbs.simba

    clickNorth(RightClick: Boolean=False)
    - Left-clicks the compass near the minimap to reset your camera angle to perfect north

    toggleXPBar(Enable: Boolean; DoWait: Boolean=False)
    - Enables the XP bar if Enable is set to True, disables if set to False

    getHealthPercent() / getPrayerPercent()
    - Returns your current health percent / prayer percent

    getCurrentHealth() / getPrayerPoints()
    - Returns your current amount of hitpoints / prayer points

    getRunEnergy()
    - Returns your current amount of run energy

    toggleRunning(Enable: Boolean)
    - Enables running if Enable is set to True, disables if set to False

    toggleQP(Enable: Boolean)
    - Enables quick-prayers if Enable is set to True, disables if set to False


    Minimap
    AeroLib/core/minimap/Minimap.simba
    AeroLib/core/minimap/Mapwalk.simba
    AeroLib/core/minimap/Symbol.simba

    getCompassAngle()
    - Returns your current compass angle

    setCompass(Direction: Variant)
    - Sets your angle to Direction. This parameter accepts an integer as the angle or the abbreviated letter for the desired direction (Ex: 'N' for North)

    setAngle(Angle: Integer)
    - Sets your camera angle (pitch) to either highest or lowest by setting Angle to either ANGLE_HIGH or ANGLE_LOW

    flagDistance()
    - Returns the distance between you and the flag on the minimap, if present

    FFlag(Dist: Integer)
    - Waits until your player is within distance Dist of the minimap flag

    getClosestDot(WhatDot: String)
    - Returns a TPoint of the nearest minimap dot WhatDot to your player. This parameter accepts: 'player', 'npc', 'item', 'friend', 'team'

    percentBlackMM()
    - Returns the percent of the minimap which is black

    isPlayerWalking()
    - Returns True if the player is currently walking, False if standing still

    foundSymbol(Name: string)
    - Returns True if the given symbol Name is found on the minimap, False if not. For a full list of all accepted symbol names, please refer to AeroLib/core/minimap/Symbol.simba

    findSymbol(var Pnt: TPoint; Name: string)
    - Same as the above function however this will give you the point of nearest found symbol, retrieved as the variable Pnt

    MMtoMS(MM: TPoint)
    - Converts the minimap point MM to a point on point on the mainscreen. The result is the mainscreen point

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Part 2: Utilizing the code

    Now that we've an idea of what's available let's actually put these snippets to work and take a look at how to use them in scripts.

    GameTabs
    - Getting current tab & switching to a different tab
    Simba Code:
    if getCurrentTab() = TAB_EQUIP then
        gameTab(TAB_INV);
    Inventory
    - Checking if a slot is occupied and getting the item amount in that slot
    Simba Code:
    procedure inventoryCheck();
    var
      slotBox : TBox;
      amount  : Integer;
    begin
      if itemInSlot(4) then
        slotBox := invBox(4);

      amount := getItemAmount(middleBox(slotBox));

      writeln('We have '+toStr(amount)+' of items in slot 4.');
    end;
    - Counting the inventory
    Simba Code:
    writeln('We have '+toStr(getInvCount())+' total items.');

      if isInvEmpty() then
        writeln('We have no items; #hobolife')
      else if isInvFull() then
        writeln('Full inventory, better run to the bank');
    - Interacting with items
    Simba Code:
    if itemInSlot(1) then
        interactSlot(1, 'Use');

      if itemInSlot(16) then
        interactSlot(16, MOUSE_LEFT);

      if anySlotActivated() then
      begin
        fastClick(MOUSE_RIGHT);
        chooseOption('Cancel');
      end;

      if itemInSlot(3) and (not itemInSlot(7)) then
        moveItemTo(3, 7);

      fastDropSlots([1,3,7,16]);

      if isPlayerFishing() then
        if waitInvChange(3000) then  // 3 seconds
          writeln('We got a fish!')
        else
          beginFishing();
    Combat
    Simba Code:
    writeln('My combat level is '+toStr(getCombatLevel()));

      if TRAININGSTRENGTH then
        setFightMode(2);

      if getSpecialPercent() > 50 then
        enableSpecialAttack(True);
    Skills
    Simba Code:
    writeln('My total level is '+toStr(getTotalLevel()));

      if getSkillMaxLevel(SKILL_ATTACK) >= 40 then
        item_RuneScimitar.interact(MOUSE_LEFT);

      if getSkillXP(SKILL_MINING) >= XP_TARGET then
        writeln('Mining XP target has been reached!');
    Prayer
    Simba Code:
    if not isPrayerActive('Ultimate Strength') then
        togglePrayer('Ultimate Strength', True);
    Magic
    Simba Code:
    if isSpellActive('High Level Alchemy') then
        writeln('Ready to high-alch')
      else
        writeln('Out of runes!');

      if not isSpellSelected() then
        castSpell('High Level Alchemy');
    Logout / WorldSwitcher
    Simba Code:
    if isLoggedIn() then
        logoutPlayer();

      if WS_toggle() then
        WS_switchRandomWorld();
    Settings
    Simba Code:
    if FIRSTTIMEUSING then
        if isLoggedIn() then
          fixGraphics();
    ChatBox
    - Handling chat messages
    Simba Code:
    writeln(getDisplayName()+' has finished a fletching all of the logs');

      if clickContinue(True) then
        mineRocks();

      if findGameMessageAnyLine('died') then
      begin
        writeln('Oh no, I  died!');
        equipItems();
        walkToNPCs();
      end;

      if findBlackChatMessage('currently no ore') then
        findANewRock();

      if findMSChat() then
      begin
        writeln('Possible nearby chatting detected, hopping worlds');
        findNewWorld();
      end;
    - NPC chatting
    Simba Code:
    while areTalking() do
        if chatOptionScreen() then
          if findChatOption('open my bank', True) then
            waitForBankscreen();

      if areTalking() then
        doConversation(['Yes please','open my bank']);
    Orbs
    Simba Code:
    if loginPlayer() then
      begin
        clickNorth();
        toggleXPBar(True);
      end;

      if getHealthPercent() <= CRITICALHEALTH then
        eatFood();

      if getPrayerPercent() <= 25 then
        sipPrayerPot();

      if getCurrentHealth() > 1 then
        eatRockCake();

      if getCurrentPrayer() < 10 then
        restorePrayerAtAltar();

      if getRunEnergy() >= 30 then
        toggleRunning(True);

      if timer_PrayerFlick.timeElapsed() > 21000 then  // 21 seconds
      begin
        toggleQP(True);
        wait(randomRange(100,250));
        toggleQP(False);
      end;
    Minimap
    - Using the compass
    Simba Code:
    if inRange(getCompassAngle(), 90, 270) then
        setCompass('N');

      if loginPlayer() then
        setAngle(ANGLE_HIGH);
    - Minimap flags & walking
    Simba Code:
    if percentBlackMM() > 10 then
        writeln('Currently underground');

      if flagDistance() > 5 then
        FFlag(1);

      while isPlayerWalking() do
        wait(150);
    - Minimap dots, symbols and converting to mainscreen points
    Simba Code:
    NPCMMPoint := getClosestDot('NPC');
      mouse(MMtoMS(NPCMMPoint), 10, 10, MOUSE_LEFT);

      if foundSymbol('store') then
        writeln('Found the store symbol');

      if findSymbol(SymbolPnt, 'store') then
      begin
        writeln('Walking to the store');
        walkToPoint(SymbolPnt);
      end;


    And that concludes this tutorial on reading & interacting with your in-game interface. I tried keeping everything as simple as possible and I hope you've learned something from reading it all. If you've questions about anything I cited in the tutorial feel free to ask them here; I'll be happy to answer if I can. I'll certainly try to pump out some other tutorials on scripting with AeroLib, hopefully sooner than later. The next tutorial will cover interacting with your game screen (mainscreen), including mouse moving, clicking, typing, choosing menu options, reading text and so on. Thanks for reading and happy scripting!

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

  4. #4
    Join Date
    Feb 2012
    Location
    Canada
    Posts
    1,164
    Mentioned
    26 Post(s)
    Quoted
    433 Post(s)

    Default

    Awesome tutorial! You give some solid explanations on some stuff I didn't know was possible! Looking forward to using it!

  5. #5
    Join Date
    Dec 2016
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    thanks for the tips my friend

  6. #6
    Join Date
    Nov 2011
    Location
    root@fsociety:~#
    Posts
    106
    Mentioned
    1 Post(s)
    Quoted
    44 Post(s)

    Default

    Thanks Flight. Awesome tutorial, I am looking forward to making scripts again. This helps a ton!
    Home sweet home.

  7. #7
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    This is great. thanks for the new tutorials! I would be struggling without them!

  8. #8
    Join Date
    Jul 2020
    Posts
    3
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Question

    gameTab(TAB_INV);
    is not working ..
    all other tabs works but TAB_INV doesn't, hours of debugging the core with no luck! ..
    even tabExists(TAB_INV) or tabExists(4) / tabExists(24) and FTab(TAB_INV) returns false ..

    using AEROLIB 2.1.1 and while i'm on INV tab i run WriteLn(getCurrentTab); outputs 24

    weird! any fix maybe after like 2 years? hoping ..
    Last edited by madnessguy; 08-12-2020 at 05:14 AM.

  9. #9
    Join Date
    Feb 2015
    Posts
    8
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Fix could be the simple java reflection

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •