Jump to content

Drinking Prayer Potion


shokh

Recommended Posts

	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 by Apaec
  • Like 1
Link to comment
Share on other sites

	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

	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

 

facep.gif

 

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 by Swizzbeat
Link to comment
Share on other sites

What in the hell

 

facep.gif

 

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.

  • Like 4
Link to comment
Share on other sites

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

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.

  • Like 3
Link to comment
Share on other sites

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 :facep:) and interact.

Edited by Swizzbeat
Link to comment
Share on other sites

What in the hell

 

facep.gif

 

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

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

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

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...