shokh Posted October 24, 2014 Share Posted October 24, 2014 Could someone give/write me the code/snippet for drinking prayer potion at 25 prayer points? I'm new to scripting. Thanks in advance! Link to comment Share on other sites More sharing options...
Apaec Posted October 24, 2014 Share Posted October 24, 2014 (edited) public void potionHandler(String potionName, String potionInteraction) { for (int i = 1; i <= 4; i++) { if (this.inventory.contains(potionName + "(" + i + ")")) { this.inventory.interact( this.inventory.getSlot(potionName + "(" + i + ")"), potionInteraction); break; } } } Implementation: if (this.myPlayer().getSkills().getDynamic(Skill.PRAYER) <= 25) { potionHandler("Prayer potion", "Drink"); } Untested I wrote it for you now but it should work any more questions just let me know gl Could someone give/write me the code/snippet for drinking prayer potion at 25 prayer points? I'm new to scripting. Thanks in advance! Edited October 24, 2014 by Apaec 1 Link to comment Share on other sites More sharing options...
shokh Posted October 24, 2014 Author Share Posted October 24, 2014 public void potionHandler(String potionName, String potionInteraction) { for (int i = 1; i <= 4; i++) { if (this.inventory.contains(potionName + "(" + i + ")")) { this.inventory.interact( this.inventory.getSlot(potionName + "(" + i + ")"), potionInteraction); break; } } } Implementation: if (this.myPlayer().getSkills().getDynamic(Skill.PRAYER) <= 25) { potionHandler("Prayer potion", "Drink"); } Untested I wrote it for you now but it should work any more questions just let me know gl Do you have IRC? I'm trying to write a very simple script Link to comment Share on other sites More sharing options...
Apaec Posted October 24, 2014 Share Posted October 24, 2014 (edited) Do you have IRC? I'm trying to write a very simple script IRC? Edit: Feel free to PM me the code & i'll help out all i can! Edited October 24, 2014 by Apaec Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 24, 2014 Share Posted October 24, 2014 (edited) public void potionHandler(String potionName, String potionInteraction) { for (int i = 1; i <= 4; i++) { if (this.inventory.contains(potionName + "(" + i + ")")) { this.inventory.interact( this.inventory.getSlot(potionName + "(" + i + ")"), potionInteraction); break; } } } What in the hell Why make things so needlessly complex when you can just iterate over the inventory, check if the item name contains prayer potion, and if it does drink it? Should also return a boolean based on if the interaction (if there was any) was successful or not. Edited October 24, 2014 by Swizzbeat Link to comment Share on other sites More sharing options...
Ericthecmh Posted October 24, 2014 Share Posted October 24, 2014 What in the hell Why make things so needlessly complex when you can just iterate over the inventory, check if the item name contains prayer potion, and if it does drink it? Should also return a boolean based on if the interaction (if there was any) was successful or not. What about super prayer potions? I wouldn't want it to drink those. Everyone has their own way of coding. Don't criticize just because it doesn't match with what you'd do. 4 Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 24, 2014 Share Posted October 24, 2014 What about super prayer potions? I wouldn't want it to drink those. Everyone has their own way of coding. Don't criticize just because it doesn't match with what you'd do. Erm I'm pretty sure I can criticize whatever/whoever I want, as can anyone else. We both know that a single inventory check is the optimal way to go, versus (worst case scenario) four inventory iterations. Just like everyone has their own way of coding, they also have their own helping style. Link to comment Share on other sites More sharing options...
Botre Posted October 24, 2014 Share Posted October 24, 2014 Erm I'm pretty sure I can criticize whatever/whoever I want, as can anyone else. We both know that a single inventory check is the optimal way to go, versus (worst case scenario) four inventory iterations. Just like everyone has their own way of coding, they also have their own helping style. You're fucking annoying and should work on your social skills instead of making useless posts. There, it's out. That was my helping style ladies and gentlemen, if I get a warning point then so be it, totally worth it. 3 Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 24, 2014 Share Posted October 24, 2014 (edited) You're fucking annoying and should work on your social skills instead of making useless posts. There, it's out. That was my helping style ladies and gentlemen, if I get a warning point then so be it, totally worth it. Social skills? This is the internet young buck. @OP my actual response still stands. Iterate over the inventory items until you find something with "prayer potion" or whatever in it (and add a check to make sure it doesn't contain "super" if you don't want supers ) and interact. Edited October 24, 2014 by Swizzbeat Link to comment Share on other sites More sharing options...
Botre Posted October 24, 2014 Share Posted October 24, 2014 Social skills? This is the internet young buck. It was a serious piece of advice, no hard feelings, arrogance can be a powerful trigger sometimes. We all somehow love you even though we really shouldn't. I can't stay mad at you. Meh. You're right though, but I wish you were able to be right more nicely. Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 24, 2014 Share Posted October 24, 2014 It was a serious piece of advice, no hard feelings, arrogance can be a powerful trigger sometimes. We all somehow love you even though we really shouldn't. I can't stay mad at you. Meh. You're right though, but I wish you were able to be right more nicely. Tough love my friend, tough love. Link to comment Share on other sites More sharing options...
Trigoon Posted October 25, 2014 Share Posted October 25, 2014 What in the hell Why make things so needlessly complex when you can just iterate over the inventory, check if the item name contains prayer potion, and if it does drink it? Should also return a boolean based on if the interaction (if there was any) was successful or not. his implementation drinks lower dose potions first which is a logical way to go about it while yours would drink the first potion regardless of dose. i think that most players drink potions the way his method handles it, but correct me if i am wrong since i do not play runescape. Link to comment Share on other sites More sharing options...
Swizzbeat Posted October 25, 2014 Share Posted October 25, 2014 his implementation drinks lower dose potions first which is a logical way to go about it while yours would drink the first potion regardless of dose. i think that most players drink potions the way his method handles it, but correct me if i am wrong since i do not play runescape. If the bot continually drinks the first potion it finds that WILL be the lowest dose (assuming there's no interaction from the player or movement of inventory items). Even so it's extremely easy to just parse the dose and keep the slot with the lowest dose in memory. Link to comment Share on other sites More sharing options...
Trigoon Posted October 25, 2014 Share Posted October 25, 2014 If the bot continually drinks the first potion it finds that WILL be the lowest dose (assuming there's no interaction from the player or movement of inventory items). Even so it's extremely easy to just parse the dose and keep the slot with the lowest dose in memory. assuming something is going to be or not be true is typically not a good idea when dealing with a changing environment like runescape. Link to comment Share on other sites More sharing options...
Joseph Posted October 25, 2014 Share Posted October 25, 2014 There a method that allows us to put an array of string or ids in the constructor. Which mean the first available item found first will be interacted with the string of action. Look into the inventory class it's there. Best suggestion create the array from lowest to biggest because if you say you do it my way but biggest to lowest. The method looks through out the whole inventory. Look for the first available with the same name. So if you do potion number 4 it drinks all 4's before heading to the 3's. Link to comment Share on other sites More sharing options...