PTY Botting
-
Posts
5 -
Joined
-
Last visited
-
Feedback
0%
Posts posted by PTY Botting
-
-
I would use Intellij as its alot more modern and frankly better than Eclipse. Although if your attached to eclipse I can find some more things
^ More up to date
-
1 hour ago, jackknife32 said:
Yeah i've tried that...
The script fails if I add something like:
log("test");
If you are using a class that extends methodprovider make sure you exchangecontext with it.
-
So much duplicated code, I think you need to try break it down more.
There are 3 states
- Alching
- Buying
- Exiting
There are X Number of items which you are iterating in order
Rune2h -> Rune Plate -> Rune Legs
Heres is what I would try to do- Create an array which which holds the data for the item I wish to alch(Only name right now, but could hold things such as Times alched etc)
- The initial state would be alching until no items
- buy items (Trigger a flag saying bought items for current item once done)
- alch until done
- Switch the reference to the index of the array(Reset bought flag etc)
- continue until x number of items done
- reset index to 0, repeat.
Using this way of having the current item stored in an array you can reduce duplicated code y taking a parameter into the method
EG
public void alchRpl8() throws InterruptedException { if (getInventory().contains("Rune platebody")) { if (!getPlayers().myPlayer().isAnimating()) { magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY); Sleep.sleepUntil(() -> magic.isSpellSelected(), 5000); getInventory().interact("cast", "Rune platebody"); runepl8 =+ 1; } } }
could become
public void alchItem(String itemName) throws InterruptedException { if (getInventory().contains(itemName)) { if (!getPlayers().myPlayer().isAnimating()) { magic.castSpell(Spells.NormalSpells.HIGH_LEVEL_ALCHEMY); Sleep.sleepUntil(() -> magic.isSpellSelected(), 5000); getInventory().interact("cast", itemName); } } }
That way you don't need a separate method for each item you wish to alch
-
On 3/2/2021 at 7:29 AM, Ricky Dactyl said:
@mitsuki~
not sure if you had this solved yet but I only just realised this section was a thing, here's what I've been using for my bots fresh from tutorial island.
public void setAttackStyle(String trainType) { int style = script.getConfigs().get(43); switch (trainType) { case "DEFENCE": if (style != 3) { while (!script.tabs.isOpen(Tab.ATTACK)) script.getTabs().open(Tab.ATTACK); // postStatus("CHANGING ATTACK STANCE TO DEFENCE"); script.widgets.get(593, 17, 4).interact(new String[0]); } break; case "ATTACK": if (style != 0) { while (!script.tabs.isOpen(Tab.ATTACK)) script.getTabs().open(Tab.ATTACK); // postStatus("CHANGING ATTACK STANCE TO ATTACK"); script.widgets.get(593, 5, 4).interact(new String[0]); } break; case "STRENGTH": if (style != 1) { while (!script.tabs.isOpen(Tab.ATTACK)) script.getTabs().open(Tab.ATTACK); // postStatus("CHANGING ATTACK STANCE TO STRENGTH"); script.widgets.get(593, 9, 4).interact(new String[0]); } break; } }
You could simplify it to something like this (Although didn't test it), another step would be changing the traintype to an enum but yeah.
public void setAttackStyle(String trainType) { int style = script.getConfigs().get(43); switch (trainType) { case "DEFENCE": if (style != 3) { selectAttackStyle(17, 4); } break; case "ATTACK": if (style != 0) { selectAttackStyle(5, 4); } break; case "STRENGTH": if (style != 1) { selectAttackStyle(9, 4); } break; } } private void selectAttackStyle(int childId, int subChildId) { if (!script.getTabs().open(Tab.ATTACK)) { return; } RS2Widget widget = script.widgets.get(593, childId, subChildId); if (widget != null && widget.isVisible()) { widget.interact(); } }
- 2
Script selector can't find my custom script - Help!
in Scripting Help
Posted
Incase someone else looking at this later