redeems Posted March 13, 2019 Share Posted March 13, 2019 (edited) Google State Machine, it's basically the foundation for most scripts. Your onLoop will only run a function. States can be stored in your main file, or you can create a class. Actually, you could even create a class for each state. The point is, it allows you to break up your code into smaller, more defined sections. here's the logic behind it. Code length does not define proper or improper. Being able to catch and contain errors using a state machine, will not only make your life easier, but will allow you to be much more diverse with your code. A state is essentially a "condition" which defines everything, so by using states, you can be much more diverse in your approach. Edited March 13, 2019 by redeems Quote Link to comment Share on other sites More sharing options...
Dab in a Lab Posted March 13, 2019 Share Posted March 13, 2019 (edited) I'm still getting used to using a function like this, but I think this may work. If you have a bunch of repetitive actions with only minor differences, you can build a function like this and plug in specifiers. In this case your position, the object, and the interaction associated with it. If it doesn't work (haven't tested, and still getting use to using these myself) you can mess around with it. Someone feel free to correct me if theres something wrong/better // How you would use it clickThisShit(Position,Object,"Action") // The one line can replace a block of the repetetive chuncks //Make a function like this in your script private void clickThisShit(Position position, RS2Object object, String action) { if (position.equals(myPosition())) { if (!object.isVisible()) getCamera().toEntity(object); if (object != null && object.isVisible() && object.hasAction(action)) { object.interact(action); new ConditionalSleep(10000, 250){ @Override public boolean condition() throws InterruptedException{ return (!myPlayer().isMoving() && !myPlayer().isAnimating()); } }.sleep(); } } } Edited March 13, 2019 by Dab in a Lab 1 Quote Link to comment Share on other sites More sharing options...
Rumple Posted March 15, 2019 Author Share Posted March 15, 2019 On 3/13/2019 at 12:04 AM, Dab in a Lab said: I'm still getting used to using a function like this, but I think this may work. If you have a bunch of repetitive actions with only minor differences, you can build a function like this and plug in specifiers. In this case your position, the object, and the interaction associated with it. If it doesn't work (haven't tested, and still getting use to using these myself) you can mess around with it. Someone feel free to correct me if theres something wrong/better // How you would use it clickThisShit(Position,Object,"Action") // The one line can replace a block of the repetetive chuncks //Make a function like this in your script private void clickThisShit(Position position, RS2Object object, String action) { if (position.equals(myPosition())) { if (!object.isVisible()) getCamera().toEntity(object); if (object != null && object.isVisible() && object.hasAction(action)) { object.interact(action); new ConditionalSleep(10000, 250){ @Override public boolean condition() throws InterruptedException{ return (!myPlayer().isMoving() && !myPlayer().isAnimating()); } }.sleep(); } } } Thats the thing is that there are 2 objects that dont have "actions" or "names" available only "Object ID" and thus the script will not click on them the way i need in-order to continue or not fall off ledge. This is not a simple agility script. I have made a simple agility script that collects marks. Quote Link to comment Share on other sites More sharing options...
Dab in a Lab Posted March 15, 2019 Share Posted March 15, 2019 (edited) Well I was just showing you how to shorten your code a bit But you could probably grab the object ID when its visible/your next object you need to interact with and do object.interact(); and not put in a string, so it will just click that object regardless of what action is has, or if it even has an action Edited March 15, 2019 by Dab in a Lab Quote Link to comment Share on other sites More sharing options...