Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Drinking Prayer Potion

Featured Replies

Could someone give/write me the code/snippet for drinking prayer potion at 25 prayer points? I'm new to scripting. Thanks in advance!

	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

  • Author
	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

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 by Apaec

	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

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.

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.

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.

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

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.

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.

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.

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.

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.

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.

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.