Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/06/22 in all areas

  1. One of the biggest tips I can give is to limit the amount of things you do in a loop to 1. Do 1 interaction and let the loop finish and the next loop check what the next things is to do Don't chain multiple interactions in a row. For example for withdrawing something from the bank. BAD onLoop(){ openbank(); depositInventory() withdrawItem(); closeBank() } GOOD onLoop(){ if(bank.isOpen()){ if(inventory.isEmpty()){ withdrawitem(); }else{ depositInventory(); } }else{ openBank(); } } 1. Don't use any loops (for, while, etc) - all looping should be in the main osbot loop in the main class Loops are powerfull, I use them all the time and you will need them. You just need to know when to break a loop. Just don't use loops to execute anything, because that will cause issues. 2. Use if/then, not case statements I usually prefer to put them in an enum and loop over the enum instead of using a switch 3. Keep all conditions in the main loop Not sure what you mean by this, but you should only be using the onLoop to execute code that interacts with the game. 4. If your use-case is RAM and CPU sensitive, use path walk, not webwalk True, but only if it's possible. If you have a clue scroll solver, you don't want to make 5000 paths ^^ 5. Do not use recursion. Java is not designed for recursion. If you must use recursion clojure should work in theory Ya fuck that. in most of the cases recursion isn't very readable anyway. I don't see a point in using that ^^ 6. The beginning of any action should be evaluated and started from the main osbot loop You should only use the onLoop to execute code that interacts with the game and always use an IF to check if it was executed.
    3 points
  2. I'm not really sure some of these things are correct not gonna lie. Maybe behavior related loops should be here, and for search related loops you could use filters/find to help eliminate looping, but I've never ran into any problems using loops in scripts. Not sure this is the best rule to have since they can definitely find their places in scripts and work Switch/case are generally more efficient that if/then, they do have their place and you should know when to use them and not to overuse them. Probably good for beginner scripters (depending on how you're defining a task), but it's definitely possible to write multipurpose scripts fairly easily once you become more experienced. Maybe some other people can share their thoughts too though, this is just my perspective.
    2 points
  3. hello guys , today ive been working on my first script. Due to @Explv advise i finally finished my java bootcamp and im feeling way more comfortable to code now. Anyways can u guys maybe give some tips on how i maybe can improve my script/code. import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.util.Random; @ScriptManifest(author = "Mob", name = "simple", info = "test", version = 0.1, logo = "") public final class TestingBot extends Script { @Override public final int onLoop() throws InterruptedException { //checking what wc lvl u are to check what to chop int startWcLevel = getSkills().getStatic(Skill.WOODCUTTING); //lvl < 20 and inv not full --> chop if (startWcLevel < 20 && !getInventory().isFull()){ chop(); //lvl > 20 and inv not full --> chopoak }else if (startWcLevel > 20 && !getInventory().isFull()){ chopOak(); }else bank(); return 200; } public void chop() throws InterruptedException { //making area , if position is not in the area --> walk to random pos. in the area Area treeArea = new Area(3181,3235,3205,3256); if (!treeArea.contains(myPosition())){ getWalking().webWalk(treeArea.getRandomPosition()); } //getting closest tree in the area --> if not null and can interact RS2Object tree = getObjects().closest(treeArea,"tree"); if (tree != null && tree.interact("Chop down")) { //sleeps while doing action to click the tree sleep(random(1800,2500)); //new conditional sleep when animating , tree doesnt exist new ConditionalSleep(random(5000,7000)) { @Override public boolean condition() { return !myPlayer().isAnimating() || !tree.exists(); } }.sleep(); } } public void chopOak() throws InterruptedException { Area treeOakArea = new Area(3186,3238,3207,3253); if (!treeOakArea.contains(myPosition())){ getWalking().webWalk(treeOakArea.getRandomPosition()); } RS2Object tree = getObjects().closest(treeOakArea,"Oak"); if (tree != null && tree.interact("Chop down")) { sleep(random(1800,2500)); new ConditionalSleep(random(5000,7000)) { @Override public boolean condition() { return !myPlayer().isAnimating() || !tree.exists(); } }.sleep(); } } public void bank() throws InterruptedException { int randomSleepAfterBank = random(5000,25000); if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())){ getWalking().webWalk(Banks.LUMBRIDGE_UPPER); }else if(!getBank().isOpen()) { getBank().open(); getBank().depositAll("Logs"); getBank().close(); sleep(randomSleepAfterBank); } } }
    1 point
  4. Since this is a constant value it would be better to initialize this as a member of the class instead of inside of the function, since this is re-initializing the area every time the function is called which isn't needed, not a huge deal here since this is a simple script but generally should not be done. Explv also has a really nice sleeping class in his scripting 101 thread that you can use to avoid these big conditional sleep blocks and clean up your code Each of these return booleans which you can check to make sure the action was successful, most functions in the osbot api are also like this
    1 point
  5. hey i found out why it wasn't working. it was because for some reason my attack option was hidden.
    1 point
  6. I believe currently its 1 bot per client. you could ask @Patrick correct. you would add a timeout of 5s or so and make a new line for each java -jar line.
    1 point
  7. Thanks for the trial. I tested this out and it worked flawlessly. Purchased it immediately after and I've gone from 67-86 herb without any issues. Good timing... Its been crazy good money per hour thanks to Nex Gonna bust out 99 asap while you can profit.
    1 point
  8. yes make a batch script: https://www.howtogeek.com/263177/how-to-write-a-batch-script-on-windows/ cli will open multiple clients
    1 point
  9. getBank().open(); getBank().depositAll("Logs"); getBank().close(); You called it
    1 point
  10. I'd transform this code to Node based framework where each node has validate execute methods, this makes the code much cleaner
    1 point
  11. Fucking loops go bbbrrrrrrrrrrrrrrrrrrrrrrrrr bro
    1 point
  12. can i have a trial plz?
    1 point
  13. Sorry for the delay, been busy with the holidays I've written a new version with a built-in break manager, that will replace OSBot's break manager which doesn't seem to be working in this case The new version is live, I've updated the thread with new parameters for CLI startup to include the new settings
    1 point
  14. This is my go-to shop for codes. I submitted a ticket and literally had a response in 1 second. The entire transaction was like 2 minutes tops. good people
    1 point
  15. I have noticed something like this when I open too many clients or if the clients lag too much, best way is to restart client or increase the reaction timer to save some performance. I guess the client doesn't pick up on items after a certain time. I will make some optimisations to reduce the frequency of this just in case. I also noticed this is pronounced when a client has been running for a lot of hours (not a script, but actual client). Either way I'll make all the improvements I can on my side I will give this a try, I don't know how that works so I gotta learn off youtube/wiki first
    1 point
  16. Woot Okay so I see that now the bot is attacking superiors which is good news, but I will add a new code update to let the bot know when it's finished fighting slayer, my apologies. It's super difficult to test superiors because they are rare I'll make sure they work better. Trial re-activated dw about it @Cirus4423 feel free to use whenever. Gl
    1 point
×
×
  • Create New...