CowsRKewl Posted June 21, 2016 Share Posted June 21, 2016 Thanks chris Quote Link to comment Share on other sites More sharing options...
Harry Posted July 5, 2016 Share Posted July 5, 2016 This is so good. Enjoy the free bump, I'm sure other people could also use this. 1 Quote Link to comment Share on other sites More sharing options...
Athylus Posted July 8, 2016 Share Posted July 8, 2016 Is it not better to make a instance variable to hold the stall object? And only try to acquire that stall object under certain conditions? Quote Link to comment Share on other sites More sharing options...
Explv Posted July 8, 2016 Share Posted July 8, 2016 (edited) Is it not better to make a instance variable to hold the stall object? And only try to acquire that stall object under certain conditions? I assume you mean a global variable? You could do something like that if you wanted to, by doing so you would only need to find the tea stall once: import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "You", info = "My first script", name = "Tea thiever", version = 0.1, logo = "") public final class TeaThiever extends Script { private Entity teaStall; @Override public final int onLoop() throws InterruptedException { if(teaStall == null) teaStall = getObjects().closest("Tea stall"); else if(getInventory().isFull()) getInventory().dropAll(); else if(teaStall.hasAction("Steal-from")) stealFromStall(); return random(200, 300); } private void stealFromStall() { if(teaStall.interact("Steal-from")) { new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } } Edited July 8, 2016 by Explv Quote Link to comment Share on other sites More sharing options...
Athylus Posted July 8, 2016 Share Posted July 8, 2016 (edited) But you still make a new object of the steal stall every time you go through the loop, which is a lot. Is not better to do something like this (memory wise)? So you create the object once and use that same object. After all, it's not going to change or move. private Entity teaStall; boolean success = false; public final int onLoop() throws InterruptedException { if (success == false) { teaStall = getObjects().closest("Tea stall"); success = true; } if (teastall == null) { success false; } } Edited July 8, 2016 by Athylus Quote Link to comment Share on other sites More sharing options...
Explv Posted July 10, 2016 Share Posted July 10, 2016 But you still make a new object of the steal stall every time you go through the loop, which is a lot. Is not better to do something like this (memory wise)? So you create the object once and use that same object. After all, it's not going to change or move. private Entity teaStall; boolean success = false; public final int onLoop() throws InterruptedException { if (success == false) { teaStall = getObjects().closest("Tea stall"); success = true; } if (teastall == null) { success false; } } The code I commented with only gets the stall object once, and then stores it. The code you have written here is just a longer way of writing: private Entity teaStall; public final int onLoop() throws InterruptedException { if (teastall == null) teaStall = getObjects().closest("Tea stall"); } Which is exactly what my code does. Also I would not concern yourself with memory usage here. Quote Link to comment Share on other sites More sharing options...
Athylus Posted July 12, 2016 Share Posted July 12, 2016 Thank you. Quote Link to comment Share on other sites More sharing options...
piettjan Posted July 21, 2016 Share Posted July 21, 2016 (edited) The getstate() if's should be looking at the current state and not signals from outside, that should happen inside the if's. Also stall != null is unnecessary checked twice Edited July 21, 2016 by piettjan Quote Link to comment Share on other sites More sharing options...
weirdo1234 Posted July 28, 2016 Share Posted July 28, 2016 This is exactly what I was looking for! Thank you! 1 Quote Link to comment Share on other sites More sharing options...
Nebulae Posted July 31, 2016 Share Posted July 31, 2016 (edited) Got me on the path to programming for OSBot, this is nice to have all of these resources in one place to get going (especially for people who know java already, having a basic thing to look at is great !) Thanks for putting the time in. Edited July 31, 2016 by Nebulae 1 Quote Link to comment Share on other sites More sharing options...
hariake Posted August 2, 2016 Share Posted August 2, 2016 (edited) import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "You", info = "My first script", name = "Power Miner", version = 0, logo = "") public class main extends Script { @@OverRideCwalk public void onStart() { log("gonna mine"); } private enum State { MINE, DROP, WAIT }; private State getState() { Entity Rocks = objects.closest("Rocks"); if (!inventory.isEmpty()) return State.DROP; if (Rocks != null) return State.MINE; return State.WAIT; } @@OverRideCwalk public int onLoop() throws InterruptedException { switch (getState()) { case MINE: Entity Rocks = objects.closest("Rocks"); if (Rocks != null) { Rocks.interact("Mine-from"); } break; case DROP: inventory.dropAll(); break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @@OverRideCwalk public void onExit() { log("mining done"); } @@OverRideCwalk public void onPaint(Graphics2D g) { } } only hovers over rocks doesnt actually mine Edited August 2, 2016 by hariake Quote Link to comment Share on other sites More sharing options...
Apaec Posted August 2, 2016 Author Share Posted August 2, 2016 import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "You", info = "My first script", name = "Power Miner", version = 0, logo = "") public class main extends Script { @@OverRideCwalk public void onStart() { log("gonna mine"); } private enum State { MINE, DROP, WAIT }; private State getState() { Entity Rocks = objects.closest("Rocks"); if (!inventory.isEmpty()) return State.DROP; if (Rocks != null) return State.MINE; return State.WAIT; } @@OverRideCwalk public int onLoop() throws InterruptedException { switch (getState()) { case MINE: Entity Rocks = objects.closest("Rocks"); if (Rocks != null) { Rocks.interact("Mine-from"); } break; case DROP: inventory.dropAll(); break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @@OverRideCwalk public void onExit() { log("mining done"); } @@OverRideCwalk public void onPaint(Graphics2D g) { } } only hovers over rocks doesnt actually mine If that happens, you've spelt the interaction wrong. For example, perhaps you spelt 'rocks' wrong, or 'mine-from' incorrectly. And when I say incorrectly I mean based on the ingame object. Hover your mouse over the rock and copy exactly what the option and interaction options are! Quote Link to comment Share on other sites More sharing options...
hariake Posted August 2, 2016 Share Posted August 2, 2016 (edited) If that happens, you've spelt the interaction wrong. For example, perhaps you spelt 'rocks' wrong, or 'mine-from' incorrectly. And when I say incorrectly I mean based on the ingame object. Hover your mouse over the rock and copy exactly what the option and interaction options are! Ive triple checked all spellings, nothing seems wrong. Are you sure there cant be any other causes, script finds the rocks and cycles throgh them all but never clicking on them. Edit: nvm my bad its actually just "mine" not "mine-from" Edited August 2, 2016 by hariake 1 Quote Link to comment Share on other sites More sharing options...
hariake Posted August 2, 2016 Share Posted August 2, 2016 Question, what ever way i do mining. The bot keeps clicking on different ores. How to stop the clicking after bot has started mining and until he has mined the ore? Quote Link to comment Share on other sites More sharing options...
Duhstin Posted August 2, 2016 Share Posted August 2, 2016 Thanks. I script for another botting site, and may start here. 1 Quote Link to comment Share on other sites More sharing options...