Jump to content

Pandemic

Trade With Caution
  • Posts

    1628
  • Joined

  • Last visited

  • Days Won

    4
  • Feedback

    100%

Everything posted by Pandemic

  1. Updated for OSBot 2's API! Hello future script writers and other OSBot members! This will be my first OSBot script writing tutorial, and it's geared toward beginners with at least some understanding of Java (however, I'll still be covering some fundamentals). So, let us begin. Step I: Getting the IDE An IDE (integrated development environment) is software that makes programming much easier on you, the programmer. There are many Java IDE's to choose from (IntelliJ, NetBeans, Eclipse, and many more), but for this tutorial, we'll be using Eclipse. You can download Eclipse here. Simply choose the Eclipse Standard and download the version for your computer (32 or 64 bit). Once downloaded, use a program to decompress the archive, and move the eclipse folder to wherever you'd like (C:\, your desktop, it honestly doesn't matter). To open Eclipse, go into that folder and open the Eclipse application. Congratulations, your one step closer to making OSBot scripts! Step II: Basic Java Fundamentals Java, like C++, PHP, and Javascript, is a high-level programming language, which simply means it's very readable by humans (we use English while programming in these languages) and therefore much simpler to write code. If you're an absolute beginner, with no background in programming at all, this is going to go by extremely fast, and I will likely skip over some important topics. If you fall into this category, you absolutely NEED to read these tutorials by Oracle. I'm not sure about most of you, but I feel that a great way to learn something is to dive right in, and worry about the little things after you've started to understand the bare essentials. With that in mind, let's take a look at a simple HelloWorld class: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World, I'm learning Java!"); } } Now looking at that might be intimidating if you're new to this, but believe me it's very simple! I'll break down some of the common words used above: public: This could be public, private, protected, or default. It simply states the visibility of this class/method/variable. Public items can be seen from outside of your package, private items can't be seen by other classes in your package, protected items can only be seen by the subclasses of your package, and default can only be seen by your package. class: A class is like a blueprint from which objects are created (Oracle). static: This is a keyword that simply means that only one instance of it will ever exist, even if you recreate it infinitely. void: This is the return type of this method. Void methods return nothing, int methods return integers, String methods return strings, and so on. String[]: This is an array. Arrays are just containers that hold a specific number of items (of one type). For example, this method takes an array of strings as a parameter. System.out.println: This is just a method that prints a message to the console and then prints the newline character. ;: Semi-colons are used at the end of any Java statement (note: conditionals and loops do not count as statements), without them, your compiler will give you errors. { }: These curly braces are used to surround/contain the contents of a class/method/etc. This is all of the Java basics I will teach, simply because there are already many resources out there (see above). Step III: Setting up a Java Project Setting up a Java project in Eclipse for making OSBot scripts is simple, just follow these steps: Step 1: Press File>New Java Project and name your project, then press finish Step 2: Add the OSBot .JAR file to your build path Step 3: Add a class to your new project And you're ready to actually start script writing! Step IV: Creating Your Script Now here's where we actually start making your script! For this example, we'll be creating a very simple mining script that will mine and drop everything once the inventory is full (please note: this example is hardly usable for a script, but it shows the basics. With a real mining script, you'll want to replace the object name with the ID(s) of the rocks, so you don't try mining empty veins). Here's the full source: import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "You!", info = "I made this script!", name = "Basic Miner", version = 0, logo = "") public class BasicMiner extends Script { private enum State { MINE, DROP }; private State getState() { if (inventory.isFull()) return State.DROP; return State.MINE; } @Override public void onStart() { log("I can't believe script writing is this easy! I love learning!"); } @Override public int onLoop() throws InterruptedException { switch (getState()) { case MINE: if (!myPlayer().isAnimating()) { RS2Object vein = objects.closest("Rocks"); if (vein != null) { vein.interact("Mine"); } } break; case DROP: inventory.dropAll(); break; } return random(200, 300); } @Override public void onExit() { log("Thanks for using this wonderful script!"); } @Override public void onPaint(Graphics2D g) { } } Now most of that will be confusing, but don't worry, I'm here to help you! I'll break this down for you. import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; These lines import other classes for their use in your script. @ScriptManifest(author = "You!", info = "I made this script!", name = "Basic Miner", version = 0, logo = "") This is the script manifest, which simply tells OSBot your script's author, info, name, and current version (for use in their class loader). public class BasicMiner extends Script { ... } This just defines our class, and extends OSBot's Script class, so we can use all of their fancy API methods. private enum State { MINE, DROP }; private State getState() { if (inventory.isFull()) return State.DROP; return State.MINE; } Here we make an enum (collection of constants) called State which holds two states: mine and drop. Then we have a method that's return type is State (so it returns a State, which we just made). If your inventory is full, this method will return the dropping state, otherwise it will return the mining state. @Override public void onStart() { log("I can't believe script writing is this easy! I love learning!"); } This method is part of OSBot's Script class (which we're extending from). The onStart() method is only called once, and is called at the beginning of the script. This is where you should define some variables that only need defined once (the start time, start experience/level, etc.). @Override public int onLoop() throws InterruptedException { switch (getState()) { case MINE: if (!myPlayer().isAnimating()) { RS2Object vein = objects.closest("Rocks"); if (vein != null) { vein.interact("Mine"); } } break; case DROP: inventory.dropAll(); break; } return random(200, 300); } This is another method from OSBot's Script class (see that @Override?). onLoop() returns an integer, or how many milliseconds to wait before doing onLoop() again. We then use a switch statement to see what we should be doing. If we're to mine, we check if our player is currently animating (mining). If we aren't, we find the closest rock to mine, if that doesn't exist (or is null), we stop right there. But if it isn't null, we interact with the rocks by pressing "Mine". If we're to drop, we simply drop everything in your inventory (you did have your pickaxe equipped, right?). @Override public void onExit() { log("Thanks for using this wonderful script!"); } @Override public void onPaint(Graphics2D g) { } onExit() and onPaint(Graphics g) are two more methods from the Script class. onExit() is called once your script is stopped, and onPaint(Graphics g) is called every time the screen is updated. Step V: Exporting Your Script The final step to this tutorial will be exporting the script we just made so we can actually test it out! Step 1. Right click your project and press Export... Step 2: Choose JAR file Step 3: Choose your OSBot's scripts directory and export it! Well that's all for this tutorial, thanks for reading! You can find Part II here! Also: post suggestions for future tutorials, and I'll definitely consider it!
  2. I hope something happens soon to resolve this.
  3. Swizzbeat I don't mean the name, I mean the actual client's getPassword() method. The system would check for suspicious activity (using client.getPassword(), downloading anything, and other common wrapper methods that could be dangerous).
  4. Exactly my point, why not make this process easier on everyone involved?
  5. I didn't say he isn't doing a great job, I'm just saying it'd be much easier on EVERYONE if he had some help. Those 3 days you waited could be 1 day with ease, and you'd have 2 more days for bug squashing.
  6. I fully understand the importance of manual verification of possible SDN scripts for the safety of the users of OSBot, but I think by practically forcing script writers that spend their time making scripts for this website/bot (which takes a nice chunk of profit out of) to wait incredible lengths of time (myself, 8 days so far for one script) to finally get scripts on the SDN, you're the ones that are pushing away potential scripters. Now I don't know if the issue lies with Alek not doing his job (not saying it is at all), or if it's simply way too much for one person to handle. Regardless, something should change, whether that be add 1-2 more script managers, or create some sort of automated system that marks suspicious scripts to be manually reviewed (using getPassword() methods, etc.). Thanks for reading. tl;dr: Add more script managers = make script writers happier = more money for OSBot
  7. Added a video showing it at experiments with B2P
  8. Added video of it running at Edgeville's Dungeon Druids
  9. LOOKING FOR AN ACCOUNT TO TEST PRAYERS AND SPECIAL ATTACKS! ADD MY SKYPE (IN MY SIGNATURE)! FREE SCRIPT IF YOU HELP!
  10. I'll add support for both then, thanks for your input.
  11. Alright the video has been uploaded, and I hope it shows the potential of this script.
  12. Noted! I'll make another video somewhere else and not speed it up so you can watch in real time. Edit: I'll do it at Edgeville's men picking up herbs so I can show off the banking feature.
  13. A video has been added to the main post, check it out!
  14. Actually the pickup list doesn't require you to know the IDs, just the names !
  15. Thanks for the support, I'll be uploading a video sometime soon showcasing it in a few various locations.
  16. Hello everyone! I've been working on this script for the past couple of nights and would like to share my progress. I know there are a few similar scripts in development, but I hope to make this one better and competition helps you guys get much better scripts! Expected Price: $9.99 one time and $2.99/mo recurring Description My AIO Fighter strives for simplicity and excellence, as well as being equipped with a plethora of features. Currently, the script supports: Choosing any NPC (by name) to fight Choosing if items are to be picked up, and what those items are Choosing to eat, and what you'll be eating Creating a custom path that supports opening gates/doors, and climbing up and down stairs, to allow you to bank, regardless of where you are Media Videos: (NEW!) Experiments w/ B2P Edgeville Dungeon Chaos Druids Part 1 (Setting up the banking route) Edgeville Dungeon Chaos Druids Part 2 (The saved preset running) https://www.youtube.com/watch?v=QSApmho5UzY Edgeville Men & Herbs (showcasing custom banking!) Todo There's currently a lot of work to be done, here's a short list: Add potion support Add prayer protection and prayer flicking Add range support (haven't tried it with range, so I don't know what it's lacking) Thank you for viewing my thread, if you have any suggestions, please feel free to post them here. Also, I'll be looking for a few higher level accounts that I could borrow for testing (higher level, more specialized monsters/banking routes), so PM me if you can help me out. Anyone that helps me out will get the script for free. Thanks!
  17. It's not unfair Nitro, competition in a free market like we have here is great for everyone, especially the end users. The end user gets higher quality scripts because of this competition.
  18. Best of luck to you! I'm actually developing an AIO fighter also right now, haha!
×
×
  • Create New...