bthebrave
-
Posts
8 -
Joined
-
Last visited
-
Feedback
0%
Posts posted by bthebrave
-
-
The getPrice(), getAverageBuyOffer(), and getAverageSellOffer() methods are incorrect. String[] data will always be length 5, not length 3, so those methods will always return 0. For a simple fix, you may be able to change it to data.length==5 or just delete that parameter overall.
Also, it's fairly simple to split each index of the array by the ":" because the second half will be the price you want and the first half will be the description. For example, if you go to the link for iron ore (https://api.rsbuddy.com/grandExchange?a=guidePrice&i=440), you can see that the stream is:
{"overall":54,"buying":54,"buyingQuantity":125855,"selling":53,"sellingQuantity":103603}
Split up in the getData() method, It looks like this
String[] data = {
""overall":54",
""buying":54",
""buyingQuantity":125855",
""selling":53",
""sellingQuantity":103603"
}
If you split by colon, data[0].split(":") returns the array {""overall"", 54}. then, returning the parse of index 1 gives you 54.
Furthermore, the getter methods would return the wrong values, because data[2] is actually the buying quantity, not the selling price. It is important to change the return statement of getAverageSellOffer() to use data[3].
Here are the changes I made:
public static int getPrice(int itemID) { String[] data = getData(itemID); if (data != null && data.length == 5) { return Integer.parseInt(data[0].split(":")[1]); } return 0; } public static int getAverageBuyOffer(int itemID) { String[] data = getData(itemID); if (data != null && data.length == 5) { return Integer.parseInt(data[1].split(":")[1]); } return 0; } public static int getAverageSellOffer(int itemID) { String[] data = getData(itemID); if (data != null && data.length == 5) { return Integer.parseInt(data[3].split(":")[1]); } return 0; }
-
I'm trying to make a simple blast furnace script for myself and friends to use, i.e. no paint & bare bones code. When it talks to the foreman, I just hard-coded a simple 3-second sleep after every command. Is there a method in the API that can tell when the next dialogue has not yet appeared and it's still waiting for the next one? My current code is like so:
dialogues.clickContinue(); sleep(3000); dialogues.selectOption("What?"); sleep(3000); dialogues.clickContinue(); sleep(3000); dialogues.clickContinue(); sleep(3000); dialogues.selectOption("Can I use the furnace to smelt ore?"); sleep(3000);
I would prefer it to be like this:
dialogues.clickContinue(); while(/*is waiting for the next prompt*/){ sleep(250); } dialogues.selectOption("What?"); while(/*is waiting for the next prompt*/){ sleep(250); } dialogues.clickContinue(); while(/*is waiting for the next prompt*/){ sleep(250); } dialogues.clickContinue(); while(/*is waiting for the next prompt*/){ sleep(250); } dialogues.selectOption("Can I use the furnace to smelt ore?"); while(/*is waiting for the next prompt*/){ sleep(250); }
Thanks, BTheBrave
-
For the walker you should make the distance between tiles shorter. I run into this problem often
Wow. I made the changes so the distance between tiles was shorter, and it worked. That gave me so much pain... Mr. Guru, do you have any advice for the GroundItem issue?
-
I'm working on my first script, a wine of zamorak grabber. Whenever the wine spawns, it calls this block of code:
GroundItem wine = groundItems.closest("Wine of zamorak"); if(wine != null){ magic.castSpellOnEntity(Spells.NormalSpells.TELEKINETIC_GRAB, wine); sleep(random(400,600)); }
Whenever a wine spawns, however, it first tries to click underneath the table and then clicks the wine in the second run-through. How can I fix this?
I also have trouble when trying to walk from the bank to the temple. Whenever the program decides that the user is not in the temple and does not have a full inventory, it calls:
Position[] pathToWine = { new Position(2954,3378,0), new Position(2965,3389,0), new Position(2962,3404,0), new Position(2955,3417,0), new Position(2949,3431,0), new Position(2947,3447,0), new Position(2945,3461,0), new Position(2942,3477,0), new Position(2940,3493,0), new Position(2941,3508,0), new Position(2931,3515,0) }; localWalker.walkPath(pathToWine);
The walker, however, only manages to get to one of the positions then clicks at its feet once before stopping. What am I doing wrong?
Thank you,
BTheBrave
NMZ Flicker
in Minigames
Posted · Edited by bthebrave
Update
I suggest you change the code from
if (skills.getDynamic(Skill.HITPOINTS) == 51 && !prayer .isActivated(PrayerButton.RAPID_HEAL) && sipAbsortption == 0)
to
if (skills.getDynamic(Skill.HITPOINTS) >= 51 && !prayer .isActivated(PrayerButton.RAPID_HEAL) && sipAbsortption == 0)
This ensures that if (for whatever, unforeseeable reason), you somehow get to 2+hp, the script will still drink overloads and absorbs
EDIT: I leveled up in hitpoints, and it brought me to 2 hp, but the script kept running because of the change I made