Snippets
Look here for useful bits of code to use with scripts.
590 topics in this forum
-
Just a collection of utility classes within org.fanny.utils Hopefully this helps somebody get started, these make writing scripts super easy - see this example script: Example Script (FannyGoldDigger) - Uses the generic utils methods and very short to write Spoiler FannyGoldDigger.java Code: package org.fanny.scripts.GoldDigger; import org.fanny.utils.*; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.script.Script; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Message; import java.awt.*; import java.util.Arrays; @ScriptManifest( name = "Fann…
-
- 2 replies
- 1.4k views
- 1 follower
-
-
I've seen a couple threads with people having trouble with the trade api so I wrote this up to hopefully help with that. This features initiating trades, offering items, declining the trade and accepting all the way through the trade or accepting just one screen. If you want anything added to it or find any bugs let me know, and I will try and implement/fix it quickly. The constructor takes the MethodProvider as a parameter. The trade() method takes a Player or a string of the players name as a parameter. The offerItem() method takes an Item or a string with the name of the item as a parameter, and the amount to offer. The offerAll() method also t…
-
-
- 22 replies
- 7.5k views
-
-
I was bored, so I made this, hope some can enjoy it. It just gives you the option to have any text in a box appearing and disappearing while scrolling along. Feel free to optimize or edit and use it. 1. Copy this class to your project Spoiler package org.wackylib.paint; import java.awt.Color; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; public class ScrollingTextBar { private String text = "place holder"; private int textXPosition; private int borderXPosition; private int yPosition; private int width; private int height; private int scrollSpeed; …
-
-
- 2 replies
- 745 views
-
-
Painter classes that allows a user to select any entities through the paint. 1. Copy this class into your project, Adjust the package if needed. package Paint; import org.osbot.rs07.api.EntityAPI; import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.canvas.paint.Painter; import org.osbot.rs07.input.mouse.BotMouseListener; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Area; import java.util.ArrayList; import java.util.HashSet; import java.util.List…
-
- 4 replies
- 821 views
-
-
I am wanting to sell an item and collect the coins, and then eventually buy some things after (buying part isnt in code just need to figure out sell first) and I am unsure what I'm doing wrong. I've tried to do my due diligence on this by researching, but there isn't many posts about the GE which tells me this is probably something super simple lol. Any help is appreciated. // Interact with a Grand Exchange Clerk to sell the lobsters NPC clerk = getNpcs().closest("Grand Exchange Clerk"); if (clerk.isVisible()) { if(!getGrandExchange().isOpen()) { clerk.interact("Exchange"); log("interacted with …
-
- 3 replies
- 1.5k views
-
-
For this simple cooking script. When the bot clicks uses the salmon on the fire and then the cook all screen comes up, it will click the cook all widget, but sometimes it will try and use another fish on the fire after its already started cooking? why is that? I tried everything but still does this. any help or suggestions? Here is the script. I ended up putting random sleep delays as it helps it not do it as often, but still does. public void cookALL() throws InterruptedException { script.currentState = Status.Cooking; RS2Object fire = script.getObjects().closest("Fire"); if (fire != null && !script.myPlayer().isAnimating()) { …
-
- 4 replies
- 1.3k views
-
-
Just now figured out that using vertices count is the way to go. The birds that appear add to your vertices count, bumping it up by 42. Set your starting vertices count in onStart. Then you can check if stunned by comparing it against your current vertex count. Something like... // When player is stunned their vertices count goes up by ~42. // Get baseline vertices when idle to determine when stunned. MidStunUtil.approxVerticesCountStunned = myPlayer().getModel().getVerticesCount() + 42; public static boolean isPlayerStunned() { return approxVerticesCountStunned - globalMethodProvider.myPlayer().getModel().getVerticesCount() <= 5; } …
-
- 3 replies
- 1k views
-
-
Non-SDN scripts are troublesome with resources. You have to download the resources externally. That's why I made some code which can be used to download any image from the oldschool runescape wiki or any other website for that matter. public static CompletableFuture<BufferedImage> getImage(File imageFolder, String fileName, String url) { File imageFile = new File(imageFolder, fileName); //AccessController.doPrivileged gives the new thread permission to read the image from the data directory return CompletableFuture.supplyAsync(() -> AccessController.doPrivileged((PrivilegedAction<BufferedImage>) () -> { try { …
-
- 1 reply
- 1.7k views
- 1 follower
-
-
Copy and paste this and put it AFTER your onLoop: Spoiler @Override public void onPaint(Graphics2D g) { // Get the mouse position on the screen Point mouseScreenPosition = getMouse().getPosition(); // Draw the cursor body drawCustomCursor(g, mouseScreenPosition);} Then copy and paste this and also put it AFTER your onLoop Spoiler public void drawCustomCursor(Graphics2D g, Point mouseScreenPosition) { int cursorSize = 20; // Adjust cursor size …
-
- 0 replies
- 689 views
-
-
V2: Now splits up the rows into equal sections based on the corresponding row in String[][] data. private void drawGrid(Graphics2D g, String[][] data, int cellWidth, int cellHeight) { g.setFont(font); g.setColor(GRID_BG); //Background Color of Grid int maxNumCols = 0; for (String[] row : data) { maxNumCols = Math.max(maxNumCols, row.length); } if (gridCanvas == null) gridCanvas = new Rectangle(cellWidth * maxNumCols, cellHeight * data.length); g.fill(gridCanvas); g.setColor(Color.WHITE); // Color of Text and Grid lines g.draw(gridCanvas); // draw the horizontal lines for (int i = 0; i <= data.length; i+…
-
- 2 replies
- 1.2k views
-
-
-
I've created this area array of 95 % of the banks in RS. I've been using it, and it works flawlessly. I've ordered the custom banks in an alphabetical order starting from A to Z. This is useful when you are using an AIO script and want to use the closest bank to you. I usually use getWalking.webWalk(banking); webWalk will then calculate the real distance to the closest bank to you. Real distance = Actual walkable tiles to reach your destination. I haven't included some of the banks that are underground, such as Burthorpe. I might update this thread with them later. Feel free to use it //Closest Bank public static Area[] banking = { …
-
-
- 16 replies
- 5.2k views
-
Recently Browsing 0
- No registered users viewing this page.