Tom1759 Posted April 21, 2014 Share Posted April 21, 2014 Hey, I'm new to scripting and just wondering how I would make my bot pray at an altar every x seconds. Thanks. (example please) Link to comment Share on other sites More sharing options...
Novak Posted April 21, 2014 Share Posted April 21, 2014 use #interact to interact with the altar, make a timer to interact with it every x seconds Link to comment Share on other sites More sharing options...
Isolate Posted April 21, 2014 Share Posted April 21, 2014 (edited) Hey, I'm new to scripting and just wondering how I would make my bot pray at an altar every x seconds. Thanks. (example please) why every x seconds? why not do it at prayer %? for the interaction: RS2Object ALTER = closestObjectForName("Alter"); if(/*Condition you want to pray at*/){ if(ALTER != null){ alter.interact("Pray-at", true, true); sleep(random(300, 900)): } } i think (sorry if im wrong i am very tired and just woke up XD ) edit: id also add an animation/moving check but i wasnt sure if you'd be standing at time before praying Edited April 21, 2014 by Isolate Link to comment Share on other sites More sharing options...
Guest Apogee Posted April 21, 2014 Share Posted April 21, 2014 (edited) Add that in the script outside of onLoop() : final int[] ALTAR_IDS = { ALTARIDHERE#, #, #, # }; // add the ID's there. onLoop() : Entity altar = closestObject(ALTAR_IDS); // The reason i didn't get by name is due to the fact that he might want multiple altars. if (altar.isVisible()) { if (!client.getMyPlayer().isMoving()) { if (!client.getMyPlayer().isAnimating()) { altar.interact("Pray-at"); //not sure what the actual right click option is sleep(random(1250, 2250)); } } } As the the at x second thing, you REALLY shouldn't use that. You'd have to use a Timer class, (i have one if you want it.) And it wouldn't be as.. accurate. It would be much more efficient if you made the script go to the altar at a certain amount of remaining prayer points. You can go to the API section at the top to find what the check prayer points method is. I personally do not know it. Edited April 21, 2014 by Bitter Link to comment Share on other sites More sharing options...
thepecher Posted April 21, 2014 Share Posted April 21, 2014 Add that in the script outside of onLoop() : final int[] ALTAR_IDS = { ALTARIDHERE#, #, #, # }; // add the ID's there. onLoop() : Entity altar = closestObject(ALTAR_IDS); // The reason i didn't get by name is due to the fact that he might want multiple altars. if (altar.isVisible()) { if (!client.getMyPlayer().isMoving()) { if (!client.getMyPlayer().isAnimating()) { altar.interact("Pray-at"); //not sure what the actual right click option is sleep(random(1250, 2250)); } } } As the the at x second thing, you REALLY shouldn't use that. You'd have to use a Timer class, (i have one if you want it.) And it wouldn't be as.. accurate. It would be much more efficient if you made the script go to the altar at a certain amount of remaining prayer points. You can go to the API section at the top to find what the check prayer points method is. I personally do not know it. Why visiblity check? Interact method will auto rotate camera and thus if you visibility check you may not pray when needed and maybe die if in combat Link to comment Share on other sites More sharing options...
Tom1759 Posted April 22, 2014 Author Share Posted April 22, 2014 (edited) Thanks a lot for your help guys. Edited April 25, 2014 by Tom1759 Link to comment Share on other sites More sharing options...
Tom1759 Posted April 25, 2014 Author Share Posted April 25, 2014 why every x seconds? why not do it at prayer %? for the interaction: RS2Object ALTER = closestObjectForName("Alter"); if(/*Condition you want to pray at*/){ if(ALTER != null){ alter.interact("Pray-at", true, true); sleep(random(300, 900)): } } i think (sorry if im wrong i am very tired and just woke up XD ) edit: id also add an animation/moving check but i wasnt sure if you'd be standing at time before praying How would I do the condition? Like if I wanted it to be if prayer percent is under 50? Link to comment Share on other sites More sharing options...
Precise Posted April 25, 2014 Share Posted April 25, 2014 How would I do the condition? Like if I wanted it to be if prayer percent is under 50? Familiarise yourself with the OSBot API. This may work, you'll have to test. if(sA.client.getSkills().getCurrentLevel(Skill.PRAYER)/sA.client.getSkills().getLevel(Skill.PRAYER)*100 < 50) { // do stuff } Link to comment Share on other sites More sharing options...
Tom1759 Posted April 25, 2014 Author Share Posted April 25, 2014 Familiarise yourself with the OSBot API. This may work, you'll have to test. if(sA.client.getSkills().getCurrentLevel(Skill.PRAYER)/sA.client.getSkills().getLevel(Skill.PRAYER)*100 < 50) { // do stuff } Alright thanks man, and yeah I couldn't find anything with prayer in the API Link to comment Share on other sites More sharing options...