PTY Botting
Members-
Posts
5 -
Joined
-
Last visited
-
Feedback
0%
Profile Information
-
Gender
Male
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
PTY Botting's Achievements
Newbie (1/10)
2
Reputation
-
Script selector can't find my custom script - Help!
PTY Botting replied to jackknife32's topic in Scripting Help
Incase someone else looking at this later -
BEGINNER: ECLIPSE: error importing OSBOT JAR external libraries
PTY Botting replied to Litcatdad's topic in Scripting Help
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 -
If you are using a class that extends methodprovider make sure you exchangecontext with it.
-
Switching states for incremental alcher script [Help please]
PTY Botting replied to Lol_marcus's topic in Scripting Help
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 -
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(); } }