### Launch PowBot Installer Source: https://powbot.org/guides/logging This command starts the PowBot installer application. It requires Java to be installed and the powbot-install.jar file to be present in the current directory. ```shell java -jar powbot-install.jar ``` -------------------------------- ### Run PowBot Installer Source: https://powbot.org/guides/bluestacks Executes the PowBot installer JAR file from the command line. Requires Java 11 or higher to be installed. ```bash java -jar powbot-install.jar ``` -------------------------------- ### Run PowBot Installer from Downloads (Windows) Source: https://powbot.org/guides/installation This sequence of commands navigates to the Downloads directory in the Windows Command Prompt or PowerShell and then runs the PowBot installer JAR file. It's a common troubleshooting step for running the installer. ```batch cd Downloads java -jar powbot-install.jar ``` -------------------------------- ### Run PowBot Installer from Downloads (macOS/Linux) Source: https://powbot.org/guides/installation This sequence of commands navigates to the Downloads directory in the macOS/Linux Terminal and then runs the PowBot installer JAR file. It's a common troubleshooting step for running the installer. ```bash cd ~/Downloads java -jar powbot-install.jar ``` -------------------------------- ### Verify Java Installation Source: https://powbot.org/guides/installation This command checks if Java is installed and displays its version. It's a crucial step to ensure the PowBot installer can run, as it requires Java 11 or higher. ```bash java -version ``` -------------------------------- ### Run Installer with Explicit Memory Allocation Source: https://powbot.org/guides/installation This command runs the PowBot installer while explicitly allocating 2GB of memory to the Java Virtual Machine. This can help resolve 'Could not create the Java Virtual Machine' errors caused by insufficient memory. ```bash java -Xmx2G -jar powbot-install.jar ``` -------------------------------- ### Draw GameObject Model and Hull Source: https://powbot.org/guides/rendering Provides examples for drawing a game object's model and its quick hull. It also shows how to draw the object at its full size by disabling downscaling. ```java GameObject object = Objects.stream().name("Chest").nearest().first(); GameObject objectNotShrunk = Objects.stream().name("Chest").nearest().first().downscale(false); ... ... ... @Subscribe public void onRender(RenderEvent r){ Rendering.setColor(Color.getCYAN()); //by default the models are shrunk to help with click accuracy object.model().draw(object.localX(), object.localY(), g); // draws the model Rendering.drawPolygon(object.model().quickHull(object.localX(), object.localY())); // draws the hull of the model // as per defined by the objectNotShrunk setting downscale to false, you can also then draw the same thing full size object.model().draw(object.localX(), object.localY(), g); Rendering.drawPolygon(object.model().quickHull(object.localX(), object.localY())); } ``` -------------------------------- ### Subscribe to RenderEvent Source: https://powbot.org/guides/rendering Demonstrates how to subscribe to the RenderEvent to enable drawing on the screen. This is the initial step before any drawing can occur. ```java @Subscribe public void onRender(RenderEvent r){ } ``` -------------------------------- ### Connect to BlueStacks via ADB Source: https://powbot.org/guides/bluestacks Connects to a BlueStacks instance using ADB (Android Debug Bridge). This command is typically run after navigating to PowBot's ADB tools directory. Ensure ADB is enabled in BlueStacks settings and you have the correct ADB address. ```bash # Navigate to PowBot's ADB tools (created after first installer run) cd ~/.powbot/android/platform-tools/ # Connect to BlueStacks (use your noted address) ./adb connect 127.0.0.1:5565 ``` -------------------------------- ### Create a basic Paint Builder instance Source: https://powbot.org/guides/paint-builder Demonstrates the simplest way to instantiate and build a PaintBuilder. This serves as the starting point for all PaintBuilder configurations. ```java PaintBuilder.newBuilder().build(); ``` -------------------------------- ### Interact with Static Widget Component - Java Source: https://powbot.org/guides/widget-interacting This example shows how to interact with a static widget component, such as clicking it. It includes checking visibility, performing the click action, and waiting for a specific game state (inventory tab) to become active. Direct interaction with static widgets is fast but may require updates if component IDs change. ```java public int spellBookWidget = 218; public int highAlchComponent = 38; if(Widgets.widget(spellBookWidget).component(highAlchComponent).visible()){ Widgets.widget(spellBookWidget).component(highAlchComponent).click(); Condition.wait(()->Game.tab()==Game.Tab.INVENTORY, 150, 10); } ``` -------------------------------- ### Draw Text and Set Color Source: https://powbot.org/guides/rendering Shows how to set the drawing color and render a string on the screen using the Rendering API within the RenderEvent. ```java @Subscribe public void onRender(RenderEvent r){ Rendering.setColor(Color.getCYAN()); Rendering.drawString("Hello!", 50, 50); } ``` -------------------------------- ### Stream and Interact with Dynamic Components - Java Source: https://powbot.org/guides/widget-interacting This snippet illustrates how to dynamically find and interact with components using streams. It's a more future-proof approach compared to static widgets, as it relies on properties like textures rather than fixed IDs. The example finds a component by widget and texture, checks if it's viewable, and clicks the first matching component. ```java public int spellBookWidget = 218; public int varrockSpellTexture = 27; if(Components.stream().widget(spellBookWidget).texture(varrockSpellTexture).viewable().isNotEmpty()){ Components.stream().widget(spellBookWidget).texture(varrockSpellTexture).viewable().first().click(); } ``` -------------------------------- ### Reset PowBot Installation on Windows Source: https://powbot.org/guides/installation This command removes the PowBot data directory on Windows. It's used for troubleshooting persistent issues by performing a clean reinstallation. ```batch rmdir /s %USERPROFILE%\.powbot ``` -------------------------------- ### Check ADB Connection Source: https://powbot.org/guides/installation This command verifies if your Android device or emulator is connected and recognized by ADB (Android Debug Bridge). It's essential for the installer to detect and interact with your device. ```bash adb devices ``` -------------------------------- ### Draw Player Tile and Matrix Source: https://powbot.org/guides/rendering Illustrates drawing the local player's tile and its associated matrix. This requires obtaining the local player and accessing their tile information. ```java Tile tile = Players.local().tile(); ... ... ... @Subscribe public void onRender(RenderEvent r){ Rendering.setColor(Color.getCYAN()); tile.matrix().draw(g); // matrix has it's own draw method Rendering.drawPolygon(tile.matrix().bounds()); // alternatively, you can draw the polygon (this requires the scale to be set above) } ``` -------------------------------- ### Reset PowBot Installation on macOS/Linux Source: https://powbot.org/guides/installation This command recursively removes the PowBot data directory on macOS and Linux. It's used for troubleshooting persistent issues by performing a clean reinstallation. ```bash rm -rf ~/.powbot ``` -------------------------------- ### Add the built paint to the game Source: https://powbot.org/guides/paint-builder Provides an example of how to integrate the configured `Paint` object into the game's active display after building it using the `PaintBuilder`. ```java @Override public void onStart() { Paint paint = PaintBuilder.newBuilder() .x(40) .y(45) .trackSkill(Skill.Fishing) .build() addPaint(paint); } ``` -------------------------------- ### Draw Tiles within an Area Source: https://powbot.org/guides/rendering Demonstrates how to draw all tiles within a defined Area. This involves iterating through the tiles in the area and drawing each one. Be cautious as this can impact FPS. ```java // This may well cause some drop in fps depending on how many tiles you have in your area. Area drawArea = new Area(new Tile(0,0,0), new Tile(9,9,0)); ... ... ... @Subscribe public void onRender(RenderEvent r) { for(Tile tile:drawArea.get_tiles()){ tile.matrix().draw(g); } } ``` -------------------------------- ### Stream NPCs and get the first match (Java) Source: https://powbot.org/guides/null-safety This snippet demonstrates how to stream NPCs by name and proximity, retrieving the first matching NPC. Instead of returning null, PowBot returns an Npc.Nil object if no match is found. ```java Npc goblin = Npcs.stream().name("Goblin").within(10).nearest().first() ``` -------------------------------- ### Get Item at Slot (Java) Source: https://powbot.org/guides/equipment-api Retrieves an item from a specific equipment slot using `Equipment.itemAt(Slot)`. It returns an `Item` object. If no item is present at the specified slot, it returns a `Nil` instance of the `Item` object. The example demonstrates checking if an item exists and printing its name if found. ```Java Item item = Equipment.itemAt(Equipment.Slot.HEAD); if (item != Item.Nil) { System.out.println("Item found was " + item.name()); } ``` -------------------------------- ### Select Item from Inventory - PowBot Java Source: https://powbot.org/guides/inventory-interactions This code illustrates how to select an item from the inventory. It begins by verifying that the inventory tab is open. Then, it streams the inventory to locate the desired item (e.g., 'Knife') and executes the 'Use' interaction, which typically selects the item for further use. ```Java String itemName = "Knife"; if (Game.tab(INVENTORY)) { Item knife = Inventory.stream().name(itemName).first(); kife.interact("Use"); } ``` -------------------------------- ### Remove macOS Quarantine Attribute Source: https://powbot.org/guides/installation This command removes the quarantine attribute from the PowBot installer JAR file on macOS. This can resolve 'Permission denied' errors that occur due to macOS security checks on downloaded files. ```bash xattr -d com.apple.quarantine powbot-install.jar ``` -------------------------------- ### Combat API - Get Combat Style Source: https://powbot.org/guides/combat Retrieves the current combat style of the player. ```APIDOC ## Get Current Combat Style ### Description Retrieves the player's current combat style. ### Method `Combat.style()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java Combat.Style currentStyle = Combat.style(); System.out.println("Current combat style: " + currentStyle); ``` ### Response #### Success Response (Combat.Style) Returns the current combat style as a `Combat.Style` enum value (e.g., ACCURATE, AGGRESSIVE, CONTROLLED, DEFENSIVE). #### Response Example ```json "ACCURATE" ``` ``` -------------------------------- ### PowBot: Configure Jagex Account with 2FA Seed Source: https://powbot.org/guides/jagex-account This snippet demonstrates how to configure an account within the PowBot client to use a Jagex account and its associated Two-Factor Authentication (2FA) Seed. Ensure the 'Jagex account' option is selected and the provided TOTP/2FA seed is correctly entered in the corresponding field for successful login. ```plaintext In the account selector, be sure to paste in the TOTP/2FA seed in the corresponding field, also make sure 'Jagex account' is ticked and save. ``` -------------------------------- ### Combine Items in Inventory - PowBot Java Source: https://powbot.org/guides/inventory-interactions This code demonstrates combining two items from the inventory, such as a 'Knife' and 'Oak Logs'. It first checks if the inventory is open, then finds both items. It prioritizes selecting the 'Knife' if nothing is selected, and if the 'Knife' is already selected, it uses it on the 'Oak Logs'. ```Java String itemName = "Knife"; String itemName2 = "Oak Logs"; if (Game.tab(INVENTORY)) { Item knife = Inventory.stream().name(itemName).first(); Item log = Inventory.stream().name(itemName2).first(); if (Inventory.selectedItem().id() == -1) { kife.interact("Use"); } else if (Inventory.selectedItem().id() == knife.id()) { log.interact("Use"); } } ``` -------------------------------- ### Handle Nil NPC instances (Java) Source: https://powbot.org/guides/null-safety This code shows how to safely check if an NPC instance is Npc.Nil. If no goblin is found, it prints a message and returns, preventing potential NullPointerExceptions when interacting with the NPC object. ```java Npc goblin = Npcs.stream().name("Goblin").within(10).nearest().first() if (goblin == Npc.Nil) { System.out.println("We couldn't find a goblin") return } ``` -------------------------------- ### Binary Bit Masking Example Source: https://powbot.org/guides/varpbits Illustrates bit masking using the '&' operator to extract specific bits from a binary number. A mask with '1's in desired positions and '0's elsewhere is applied to isolate target bits. ```plaintext 0b101101 & 0b000111 ``` -------------------------------- ### Get OSRS Store Name Source: https://powbot.org/guides/store-api Retrieves and prints the name of the OSRS store. This function requires the store to be open. ```java if (Store.opened()) { String storeName = Store.shopName(); System.out.println("Store name is " + storeName); } ``` -------------------------------- ### Use Item on GameObject (Java) Source: https://powbot.org/guides/items This example shows how to use an item from the inventory on a specific in-game object. It retrieves both the item and the target GameObject by their names and then calls the 'useOn' method to perform the interaction. This is essential for actions like cooking on a range or using tools on environmental objects. ```java Item lobster = Inventory.stream().name("Raw lobster").first(); GameObject range = Objects.stream().name("Range").first(); if(lobster.valid() && range.valid()){ lobster.useOn(range); } ``` -------------------------------- ### Create TilePath and Define Target Location Source: https://powbot.org/guides/walking This snippet shows how to create a `TilePath` object from a predefined tile array and identify the final destination tile. It also includes an example of finding a nearby `GameObject` using the target location, which can be used for conditional interactions. ```Java Tile[] path = { new Tile(3478, 9835, 0), new Tile(3481, 9829, 0), new Tile(3484, 9825, 0), new Tile(3485, 9823, 0), new Tile(3486, 9820, 0), new Tile(3487, 9818, 0), new Tile(3489, 9816, 0), new Tile(3492, 9814, 0), new Tile(3494, 9813, 0), new Tile(3496, 9811, 0), new Tile(3497, 9809, 0), new Tile(3498, 9807, 0), new Tile(3500, 9805, 0) }; TilePath tilepath = new TilePath(path); Tile targetLocation = path[path.length-1]; GameObject cave = Objects.stream(15).name("Probably called cave").within(targetLocation, 4).first(); ``` -------------------------------- ### Eat Item from Inventory (Java) Source: https://powbot.org/guides/items This example illustrates how to find a specific food item by name in the inventory and then interact with it to 'Eat'. It first retrieves the item using a name stream and then checks if the item is valid before executing the 'Eat' action. This pattern is useful for consuming items in-game. ```java String foodName = "Lobster"; Item lobster = Inventory.stream().name(foodName).first(); if(lobster.valid()){ lobster.interact("Eat"); } ``` -------------------------------- ### Combat API - Get Special Percentage Source: https://powbot.org/guides/combat Retrieves the current percentage of the player's special attack energy. ```APIDOC ## Get Special Percentage ### Description Retrieves the current percentage of the player's special attack energy. ### Method `Combat.specialPercentage()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java int specialPercentage = Combat.specialPercentage(); System.out.println("Special attack energy percentage: " + specialPercentage + "%"); ``` ### Response #### Success Response (int) Returns the current special attack energy percentage (0-100). #### Response Example ```json 75 ``` ``` -------------------------------- ### Combat API - Get Health Percentage Source: https://powbot.org/guides/combat Retrieves the player's current health as a percentage. ```APIDOC ## Get Health Percentage ### Description Retrieves the player's current health percentage. ### Method `Combat.healthPercent()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java int healthPercent = Combat.healthPercent(); System.out.println("Player health percent: "+ healthPercent); ``` ### Response #### Success Response (int) Returns the player's current health percentage (0-100). #### Response Example ```json 85 ``` ``` -------------------------------- ### Mine Nearest Iron Ore Object Source: https://powbot.org/guides/object-interactions Streams for the nearest iron ore object within 2 tiles, interacts with it to 'Mine', and waits until the ore is depleted. ```java GameObject rock = Objects.stream().within(2).id(ironOre).nearest().first(); if (rock.inViewport()) { rock.interact("Mine", "Rocks"); Condition.wait(() -> Objects.stream().at(rock.tile()).id(main.oreIDs).isEmpty(), 150, 50); } ``` -------------------------------- ### Binary Bit Shifting Example Source: https://powbot.org/guides/varpbits Demonstrates right bit shifting on a binary number to remove trailing zeros. This operation is crucial for isolating specific parts of a binary value. The operator used is '>>'. ```plaintext 0b1011010000 >> 1 // becomes 0b101101000 0b1011010000 >> 2 // becomes 0b10110100 0b1011010000 >> 3 // becomes 0b1011010 0b1011010000 >> 4 // becomes 0b101101 ``` -------------------------------- ### Registering Event Subscribers in Kotlin Source: https://powbot.org/guides/events This example shows how to register a custom task class that subscribes to events with the PowBot event bus. It includes creating an instance of a task, adding it to a list, and registering it using `Events.register(obj)`. This is useful for organizing event handling logic in separate classes. ```kotlin class SomeTask: Task { var returned = 0 @com.google.common.eventbus.Subscribe fun onInventoryChange(change: InventoryChangeEvent) { if (change.quantityChange > 0 && change.itemName == "Book of arcane knowledge") { returned++ } } } class MyScript: AbstractScript() { val tasks = mutableListOf() override fun onStart() { val someTask = SomeTask() tasks.add(someTask) Events.register(someTask) } } ``` -------------------------------- ### Accessing Quest Progress with Varpbits (Java) Source: https://powbot.org/guides/varpbits This Java code snippet shows how to retrieve the current step of a quest using varpbit values. It demonstrates obtaining the varpbit index associated with a specific quest (SHEEP_SHEARER) and then using Varpbits.varpbit() to get the raw, unmanipulated value, which represents the quest's progress. ```java public class QuestProgress { // Assuming Quests.Quest.SHEEP_SHEARER.getVarbit() returns the correct varpbit index for the quest. public int getCurrentQuestStep() { int questVarpbit = Quests.Quest.SHEEP_SHEARER.getVarbit(); // Retrieve the raw varpbit value, which indicates the current step of the quest. return Varpbits.varpbit(questVarpbit); } } ``` -------------------------------- ### Eat Food Item from Inventory - PowBot Java Source: https://powbot.org/guides/inventory-interactions This snippet demonstrates how to eat a specific food item from the inventory. It first checks if the inventory tab is open, then streams the inventory to find the specified food item (e.g., 'Lobster'), and finally interacts with the item to 'Eat'. Ensure the inventory tab is accessible and the item exists. ```Java String foodName = "Lobster"; if (Game.tab(INVENTORY)) { Item lobster = Inventory.stream().name(foodName).first(); lobster.interact("Eat"); } ``` -------------------------------- ### Combat API - Get Wilderness Level Source: https://powbot.org/guides/combat The wildernessLevel method returns the wilderness level of the player. It returns -1 if the player is not currently in the wilderness. ```APIDOC ## Retrieve Wilderness Level ### Description Retrieves the current wilderness level of the player. ### Method `Combat.wildernessLevel()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java int wildernessLevel = Combat.wildernessLevel(); if(wildernessLevel != -1){ System.out.println("The player is in the Wilderness at level " + wildernessLevel); } else { System.out.println("The player is not in the Wilderness."); } ``` ### Response #### Success Response (int) Returns the wilderness level as an integer. Returns -1 if the player is not in the wilderness. #### Response Example ```json 5 ``` ``` -------------------------------- ### Create a Polygonal Area Object Source: https://powbot.org/guides/locations Provides an example of creating a complex 'Area' object that is polygonal in shape. This is achieved by passing multiple 'Tile' objects to the 'Area' constructor, defining the vertices of the polygon. ```java public Area MINE_AREA = new Area( new Tile(1766, 3872, 0), new Tile(1774, 3868, 0), new Tile(1779, 3862, 0), new Tile(1779, 3853, 0), new Tile(1779, 3843, 0), new Tile(1778, 3838, 0), new Tile(1770, 3833, 0), new Tile(1749, 3841, 0), new Tile(1743, 3848, 0), new Tile(1743, 3857, 0), new Tile(1746, 3864, 0), new Tile(1753, 3870, 0), new Tile(1760, 3871, 0)); ``` -------------------------------- ### Conditional Wait for Tree Cutting in PowBot (Part 1) Source: https://powbot.org/guides/using-waits Illustrates the initial step in cutting a tree by interacting with it and then using a conditional wait to ensure the player has started the 'Chop down' animation and is no longer in motion. This prevents spamming the tree before the action has begun. ```java GameObject tree = Objects.stream().within(10).name(main.treeName).nearest().first(); if (tree.inViewport()) { tree.interact("Chop down", main.treeName); Condition.wait(() -> Players.local().animation() != -1 && !Players.local().inMotion(), 100, 20); } ``` -------------------------------- ### Use Inventory Item on Game Object - PowBot Java Source: https://powbot.org/guides/inventory-interactions This snippet shows how to use an inventory item (e.g., 'Raw lobster') on a game object (e.g., 'Range'). It verifies the inventory is open, finds the item and the object, and then uses the item on the object. The logic handles selecting the item first if nothing is selected, similar to combining items. ```Java String itemName = "Raw lobster"; String objectName = "Range"; if (Game.tab(INVENTORY)) { Item lobster = Inventory.stream().name(itemName).first(); GameObject range = Objects.stream().name(objectName).first(); if (Inventory.selectedItem().id() == -1) { lobster.interact("Use"); } else if (Inventory.selectedItem().id() == knife.id()) { range.interact("Use"); } } ``` -------------------------------- ### Get Current Experience Points - Java Source: https://powbot.org/guides/skills-api Obtains the current experience points for a given OSRS skill. The function accepts a Skill enum and returns the experience as a long. ```java long currentExp = Skills.experience(Skill.MAGIC); ``` -------------------------------- ### Get Special Attack Percentage in Combat API Source: https://powbot.org/guides/combat The specialPercentage method returns the current special attack energy as a percentage. This informs players about their readiness to use special abilities. ```Java int specialPercentage = Combat.specialPercentage(); System.out.println("Special attack energy percentage: " + specialPercentage + "%"); ``` -------------------------------- ### Get Experience Required for Next Level - Java Source: https://powbot.org/guides/skills-api Calculates the amount of experience points needed to reach the next level for a specified OSRS skill. It takes a Skill enum as input and returns the required experience as a long. ```java long expForNextLevel = Skills.experienceAtNextLevel(Skill.MAGIC); System.out.println("Experience required for next level in Magic: " + expForNextLevel + " XP"); ``` -------------------------------- ### Get Player Health Percentage in Combat API Source: https://powbot.org/guides/combat The healthPercent method returns the player's current health as a percentage. This is crucial for survival logic and ability usage. ```Java int healthPercent = Combat.healthPercent(); System.out.println("Player health percent: "+ healthPercent); ``` -------------------------------- ### Get All Grand Exchange Slots - Java Source: https://powbot.org/guides/ge-api Retrieves a list of all active Grand Exchange slots. The `allSlots()` function returns an `ArrayList` of `GeSlot` objects, which can then be iterated to check the status of each offer. ```Java ArrayList slots = GrandExchange.allSlots(); slots.forEach(slot -> { if (slot.isAvailable()) { System.out.println("Slot is available"); } }); ``` -------------------------------- ### Get and Set Bank Tab (Java) Source: https://powbot.org/guides/bank-api Retrieve the currently open bank tab or set a specific tab by its index. Returns an integer representing the tab index. The `currentTab(int)` function returns a boolean indicating success. ```Java int currentOpenTab = Bank.currentTab(); if (Bank.currentTab(4)) { } ``` -------------------------------- ### Get Current Combat Style in Combat API Source: https://powbot.org/guides/combat Retrieves the player's current combat style. The Style enum includes options like ACCURATE, AGGRESSIVE, CONTROLLED, and DEFENSIVE. This helps in understanding the player's combat stance. ```Java Combat.Style currentStyle = Combat.style(); System.out.println("Current combat style: " + currentStyle); ``` -------------------------------- ### Configure Gradle Build for PowBot Project Source: https://powbot.org/guides/dev-setup This configuration adds essential repositories and dependencies required for PowBot development, including the client SDK, loader, Guava, and Jackson libraries. Ensure you refresh Gradle after applying these changes. The version numbers can be updated as needed, with '+' attempting to fetch the latest. ```kotlin plugins { id 'java' // Alternative id("java") id "org.jetbrains.kotlin.jvm" version "1.5.21" // Alternative id("org.jetbrains.kotlin.jvm") version "1.5.21" } group 'org.name' // Change to a different name version '1.0-SNAPSHOT' repositories { mavenCentral() google() maven { url = uri("https://repo.powbot.org/releases") } } // If failing, alternatively use "" dependencies { implementation('org.powbot:client-sdk:3.0.0-SNAPSHOT') // Can replace with `implementation('org.powbot:client-sdk:3+')` where + tries to pull the latest version implementation('org.powbot:client-sdk-loader:3.0.0-SNAPSHOT') // Can replace with `implementation('org.powbot:client-sdk-loader:3+')` where + tries to pull the latest version implementation('com.google.guava:guava:31.1-jre') // needed for @Subscribe annotations / event bus implementation('com.fasterxml.jackson.core:jackson-core:2.13.0') } ``` -------------------------------- ### Set Interaction Type Per Interaction (Java) Source: https://powbot.org/guides/interaction-types This code snippet demonstrates how to set a specific interaction type for a single interaction with an entity. It uses the `interactionType` method followed by the interaction command. This override is temporary for the specific interaction. ```java goblin.interactionType(ModelInteractionType.HullAccurate).interact("Attack") ``` -------------------------------- ### Check and Display Selected Item - PowBot Java Source: https://powbot.org/guides/inventory-interactions This snippet shows how to check if an item is currently selected in the inventory and display its name. It retrieves the selected item using `Inventory.selectedItem()` and checks its ID. If the ID is -1, nothing is selected; otherwise, it prints the name of the selected item. ```Java Item selectedItem = Inventory.selectedItem(); if (Inventory.selectedItem().id() == -1) { system.out.println("Nothing selected"); } else { system.out.println("Item selected: " + selectedItem.name()); } ``` -------------------------------- ### Get Static Widget Value - Java Source: https://powbot.org/guides/widget-interacting This snippet demonstrates how to define and access the text value of a static widget. It's useful for reading information displayed on screen, such as item counts. Note that static widget component IDs may change with game updates, requiring script maintenance. ```java public Component SACK_COUNT = Widgets.widget(382).component(3).component(2); // Later in a task: Integer.parseInt(main.c.SACK_COUNT.text())>10; ``` -------------------------------- ### PowBot API: Simple Tile Movement Source: https://powbot.org/guides/walking Demonstrates the basic Movement.step() method for navigating to a specific tile. This method is ideal for short distances or when precise tile targeting is needed, as it mimics in-game tapping behavior when close to the destination. ```Java Movement.step(); ``` ```Java Tile furnace = new Tile(3108, 3498, 0); Movement.step(furnace); ``` -------------------------------- ### PowBot API: Advanced Web Walking Builder Source: https://powbot.org/guides/walking Explains the advanced customization options for web walking using the Movement.builder() method. This allows fine-grained control over pathfinding, including run energy thresholds, auto-run behavior, and teleport usage. ```Java Tile location = new Tile(3185, 3437, 0); Movement.builder(location).setRunMin(45).setRunMax(75).setAutoRun(false).setUseTeleports(false).move(); ``` -------------------------------- ### PowBot API: Automatic Web Walking to Bank Source: https://powbot.org/guides/walking Demonstrates the Movement.moveToBank() method, which automatically finds and navigates to the nearest or most cost-efficient bank. This simplifies bank runs in scripts. ```Java Movement.moveToBank(); ``` -------------------------------- ### Combat API - Get Max Health Source: https://powbot.org/guides/combat Retrieves the player's maximum health level. ```APIDOC ## Get Max Health ### Description Retrieves the player's maximum health level. ### Method `Combat.maxHealth()` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```java int maxHealth = Combat.maxHealth(); System.out.println("Player max health: " + maxHealth); ``` ### Response #### Success Response (int) Returns the player's maximum health level. #### Response Example ```json 99 ``` ``` -------------------------------- ### Open Equipment Tab (Java) Source: https://powbot.org/guides/equipment-api This function attempts to open the equipment tab if it is not already open. It uses `Equipment.opened()` to check the current state and `Equipment.open()` to initiate opening. If opening is successful, `Condition.wait` is used to ensure the tab is indeed open within a specified timeout. Returns true if successful, false otherwise. ```Java if (!Equipment.opened()) { if (Equipment.open()) { Condition.wait(() -> Equipment.opened(), 300, 10) } } ``` -------------------------------- ### Create Offer (Buy/Sell) - Java Source: https://powbot.org/guides/ge-api Creates a new offer on the Grand Exchange to buy or sell items. The `createOffer` function takes the item, quantity, price, and a boolean flag (`true` for buy, `false` for sell) as parameters. ```Java int quantity = 15; int price= 999; Boolean shouldBuy = false; GrandExchangeItem geItem = GrandExchangeItem.Companion.fromName("Bronze arrow"); GrandExchange.createOffer(geItem, quantity, price, shouldBuy); ``` -------------------------------- ### Execute Path Traversal and Dynamic Interaction Source: https://powbot.org/guides/walking This code illustrates the execution of path traversal using the `traverse()` method on a `TilePath` object. It includes a loop to iterate through path tiles and a conditional check to interact with a `GameObject` (e.g., a cave) once it becomes visible, providing a more dynamic and human-like interaction compared to static web walking. ```Java Tile[] path = { new Tile(3478, 9835, 0), new Tile(3481, 9829, 0), new Tile(3484, 9825, 0), new Tile(3485, 9823, 0), new Tile(3486, 9820, 0), new Tile(3487, 9818, 0), new Tile(3489, 9816, 0), new Tile(3492, 9814, 0), new Tile(3494, 9813, 0), new Tile(3496, 9811, 0), new Tile(3497, 9809, 0), new Tile(3498, 9807, 0), new Tile(3500, 9805, 0) }; TilePath tilepath = new TilePath(path); // Example loop for traversal and interaction (implementation details omitted for brevity) // for (int i = 0; i < path.length; i++) { // tilepath.traverse(i); // if (cave != null && cave.isVisible()) { // cave.interact("Interact"); // Example interaction // break; // } // } ``` -------------------------------- ### Creating Offers Source: https://powbot.org/guides/ge-api Create buy or sell offers on the Grand Exchange. This function handles both buying and selling by specifying the `shouldBuy` parameter. ```APIDOC ## POST /grandexchange/createOffer ### Description Creates a new buy or sell offer on the Grand Exchange for a specified item. ### Method POST ### Endpoint `/grandexchange/createOffer` ### Parameters #### Request Body - **item** (GrandExchangeItem) - Required - The item to create an offer for. - **quantity** (int) - Required - The number of items to buy or sell. - **price** (int) - Required - The price per item. - **shouldBuy** (boolean) - Required - `true` to create a buy offer, `false` to create a sell offer. ### Request Example ```json { "item": { "name": "Bronze arrow" }, "quantity": 15, "price": 999, "shouldBuy": false } ``` ### Response #### Success Response (200) (Details of successful offer creation are typically handled via slot updates or confirmations, not a direct response body from this function.) #### Response Example (No specific response body defined for success in the provided text.) ``` -------------------------------- ### PowBot API: Managing Run Energy Source: https://powbot.org/guides/walking Shows how to control the 'run' feature in PowBot using Movement.energyLevel() and Movement.running(). This allows scripts to conserve run energy when not needed or enable it for faster traversal when conditions are met. ```Java if(Movement.energyLevel()>20 && !Movement.running()){ Movement.running(true); } ``` -------------------------------- ### Track a skill with custom display options Source: https://powbot.org/guides/paint-builder Explains how to customize the displayed information for skill tracking by using `TrackSkillOption`. Options include experience, level, level progress bar, and time to next level. ```java PaintBuilder.newBuilder() .trackSkill(Skill.Fishing, "This is a custom label", TrackSkillOption.Exp) .build() ``` -------------------------------- ### Track inventory item with custom display options Source: https://powbot.org/guides/paint-builder Shows how to customize the displayed details for inventory item tracking using `TrackInventoryOption`. Available options relate to quantity changes and price. ```java TrackInventoryOption.QuantityChange TrackInventoryOption.valueOf() TrackInventoryOption.values() TrackInventoryOption.Price ``` -------------------------------- ### List Items in OSRS Store Source: https://powbot.org/guides/store-api Retrieves and lists the names of all items available in the OSRS store. This function requires the store to be open. ```java if (Store.opened()) { for (Item item : Store.items()) { System.out.println(item.name()); } } ``` -------------------------------- ### PowBot API: Automatic Web Walking to Location Source: https://powbot.org/guides/walking Illustrates the Movement.moveTo() method for effortless navigation to any specified tile. This is PowBot's web walking feature, which automatically calculates the most efficient path. ```Java Tile bank = new Tile(3185, 3437, 0); Movement.moveTo(bank); ``` -------------------------------- ### Define Iron Ore IDs for Mining Source: https://powbot.org/guides/object-interactions Declares an array of integer IDs representing different states of iron ore. This is used to filter for mineable ore objects. ```java public static final int[] ironOre = {11364, 11365}; ``` -------------------------------- ### Define and Cast OSRS Magic Spells Source: https://powbot.org/guides/magic-api This snippet shows how to reference spells from different spellbooks and cast them using the .cast() method. It also demonstrates how to specify options for spells with multiple functionalities, like Camelot Teleport. ```Java Magic.spell.X; ArceuusSpell.spell.X; LunarSpell.spell.X; AncientSpell.spell.X; Magic.Spell.HIGH_ALCHEMY.cast(); Magic.Spell.CAMELOT_TELEPORT.cast("Cast"); // this confirms what option you want to select Magic.Spell.CAMELOT_TELEPORT.cast("Seers'"); // this confirms what option you want to select ``` -------------------------------- ### Get Player Max HP in Combat API Source: https://powbot.org/guides/combat The maxHealth method returns the maximum health points the player can have. This is useful for calculating health thresholds and displaying full health information. ```Java int maxHealth = Combat.maxHealth(); System.out.println("Player max health: " + maxHealth); ``` -------------------------------- ### Get Time Since Experience Gained - Java Source: https://powbot.org/guides/skills-api Calculates the time elapsed in milliseconds since experience was last gained for a specific OSRS skill. It requires a Skill enum as input and returns the time as a long. ```java long timeSinceLastExp = Skills.timeSinceExpGained(Skill.MAGIC); System.out.println("Time since last experience in Magic: " + timeSinceLastExp + " ms"); ``` -------------------------------- ### Open Bank (Java) Source: https://powbot.org/guides/bank-api Opens the bank interface. This function should be called after verifying that the bank is in the viewport using `Bank.inViewport()`. It utilizes `Condition.wait` for reliable execution. ```Java if (Bank.inViewport()) { Condition.wait(() -> Bank.open(), 50, 10); } ``` -------------------------------- ### Get Current Skill Level (Non-Boosted) - Kotlin Source: https://powbot.org/guides/skills-api Retrieves the 'real' level of a specified OSRS skill, excluding any boosted or depleted values. This function takes a Skill enum as input and returns the base level as an integer. ```kotlin val prayerLevel = Skills.realLevel(Skill.prayer) // returns 70 ``` -------------------------------- ### Get Current Skill Level (Boosted) - Kotlin Source: https://powbot.org/guides/skills-api Retrieves the current level of a specified OSRS skill, including any boosted or depleted levels. This function takes a Skill enum as input and returns the current level as an integer. ```kotlin val prayerLevel = Skills.level(Skill.Prayer) // returns 30 ``` -------------------------------- ### Open Grand Exchange Interface - Java Source: https://powbot.org/guides/ge-api Opens the Grand Exchange interface in the game. The `open()` function returns a boolean indicating success, allowing for conditional logic after attempting to open it. ```Java if (GrandExchange.open()) { //Do something here } ``` -------------------------------- ### Get Current Chat Message (Kotlin) Source: https://powbot.org/guides/chat-api Retrieves the text content of the current chat message from an NPC. This function is useful for parsing NPC dialogue or making decisions based on the message content. It requires an active chat session. ```kotlin if (Chat.chatting()) { String message = Chat.getChatMessage() } ``` -------------------------------- ### Retrieving Item Prices Source: https://powbot.org/guides/ge-api Fetch the current market price of an item using its ID. This can be called from anywhere and is often placed in the `onStart` function for initial loading or at other points for updates. ```APIDOC ## GET /grandexchange/itemPrice ### Description Retrieves the current market price of a specific item. ### Method GET ### Endpoint `/grandexchange/itemPrice` ### Parameters #### Query Parameters - **itemId** (int) - Required - The unique ID of the item to retrieve the price for. ### Request Example (No request body for GET requests of this type) ### Response #### Success Response (200) - **price** (int) - The current market price of the item. #### Response Example ```json { "price": 1500 } ``` ``` -------------------------------- ### Create a Tile Object Source: https://powbot.org/guides/locations Demonstrates the creation of a 'Tile' object, representing a single square on the game map. It requires X, Y, and Z coordinates. The Z-axis is referred to as 'floor'. ```java Tile tile = new Tile(3264, 2123, 0); ``` -------------------------------- ### Open OSRS Store with NPC Name Source: https://powbot.org/guides/store-api Opens the OSRS store by interacting with a specified NPC. It first checks if the store is already open and waits until it is opened if the interaction is successful. ```java if (!Store.opened()) { if (Store.open("Store owner")) { Condition.wait(() -> Store.opened(), 300, 10); } } ``` -------------------------------- ### Buy Items from OSRS Store Source: https://powbot.org/guides/store-api Buys a specified amount of an item from the OSRS store using its ID. It confirms the purchase by waiting for the item count in the inventory to increase. ```java if (Store.opened()) { int previousLobsterCount = Inventory.stream().id(Constants.LobsterId).count(); if (Store.buy(Constants.LobsterId, 2)) { Condition.wait(() -> Inventory.stream().id(Constants.LobsterId).count() > previousLobsterCount, 300, 10) } } ``` -------------------------------- ### Track a specific skill with default options Source: https://powbot.org/guides/paint-builder Illustrates how to use the `trackSkill()` method to automatically display all relevant information for a given skill. The Skill enum is used to specify which skill to track. ```java PaintBuilder.newBuilder() .trackSkill(Skill.Fishing) .build(); ``` -------------------------------- ### Track inventory item changes with default options Source: https://powbot.org/guides/paint-builder Demonstrates tracking changes to a specific inventory item using `trackInventoryItem()`. This method takes the item's ID and a display name. ```java PaintBuilder.newBuilder() .trackInventoryItem(c.MOLTEN_GLASS_ID, "Molten Glass") .build() ``` -------------------------------- ### Set Default Interaction Type Globally (Java) Source: https://powbot.org/guides/interaction-types This code snippet shows how to set a default interaction type for a specific entity type using the `InteractionManager`. This setting will apply to all interactions with that entity type unless overridden individually. It's useful for establishing consistent interaction behavior. ```java InteractionManager.setNpcInteractionType("Goblin", ModelInteractionType.HullAccurate) ``` -------------------------------- ### Toggle Quick Prayer (Java) Source: https://powbot.org/guides/prayer-api The `quickPrayer(boolean)` function allows toggling the activation status of the quick prayer feature. Passing `true` activates quick prayers, while `false` deactivates them. This provides a straightforward way to enable or disable the quick prayer functionality. ```Java Prayer.quickPrayer(true); // Activate quick prayer Prayer.quickPrayer(false); // Disable quick prayer ``` -------------------------------- ### Add a checkbox for user interaction Source: https://powbot.org/guides/paint-builder Shows how to include a checkbox in the paint display using `addCheckbox()`. This allows users to toggle features, and interaction triggers a `PaintCheckboxChangedEvent`. ```java PaintBuilder.newBuilder() .addCheckbox("Draw Tiles", "drawTiles", true) .build() ``` -------------------------------- ### Check Activity Advisor Status with Varpbits (Java) Source: https://powbot.org/guides/varpbits This Java code snippet demonstrates how to check if the activity advisor is turned on or off using varpbit manipulation. It defines the varpbit index, shifts the value to isolate the relevant bits, and masks it to determine the final state. The function returns a boolean indicating whether to turn the advisor off. ```java public class ActivityAdvisor { public int ADVISOR_INDEX = 3190; public boolean shouldTurnOffActivityAdvisor() { // Shift by 3 bits to remove unwanted bits, then mask with 0b00001 to get the specific bit. // If the result is 0, it means the advisor is ON (as per the description's ON value being 0). return (Varpbits.varpbit(ADVISOR_INDEX) >> 3 & 0b00001) == 0; } } ``` -------------------------------- ### Combine Two Items in Inventory (Java) Source: https://powbot.org/guides/items This snippet demonstrates how to combine two different items present in the inventory, such as using a knife on logs. It finds both items by their names and then uses the 'useOn' method to perform the combination action, provided both items are valid and exist. This is useful for crafting or construction activities. ```java Item knife = Inventory.stream().name("Knife").first(); Item log = Inventory.stream().name("Logs").first(); if(knife.valid() && log.valid()){ knife.useOn(log); } ```