luminlumin Posted October 14, 2017 Share Posted October 14, 2017 5 hours ago, liverare said: Whoever keeps telling new scripters to use states - stop it. You've made this new guy's script so fucking unreadable and overly complicated that I would be aghast if he can even get it to work. States are horrible! Stop using them! Here's what I can do without states; compare for yourself: String status = "Ready" Position cowTile = new Position(3259, 3269, 0); NPC banker; NPC cow; @Override public void onLoop() throws InterruptedException { if (shouldGoToBank()) { goToBank(); } else if (shouldWithdrawFood()) { withdrawFood(); } else if (shouldGoToCows()) { goToCows(); } else if (shouldKillCows()) { killCows(); } } private boolean shouldGoBank() { return inventory.isEmpty(); } private void goToBank() { status = "Going to the bank"; getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } private boolean shouldWithdrawFood() { return Banks.LUMBRIDGE_UPPER.contains(myPosition()); } private void withdrawFood() { status = "Withdrawing food"; banker = npcs.closest("Banker"); if (banker != null && banker.interact("Bank")) { // now sleep until the bank interface opens // hint: https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html } } private boolean shouldGoToCows() { return inventory.isFull(); } private void goToCows() { status = "Going to the cows"; getWalking().walk(cowTile); } private boolean shouldKillCows() { return inventory.contains("Salmon"); } private void killCows() { status = "Killing cows"; cow = npcs.closest("Cow"); // better filtering needed - you might attack a cow someone else is already attacking, or you might be fighting a cow and attempt to attack another cow in non-multi zone if (cow != null && cow.interact("Attack")) { // now sleep until you've killed the cow or are running low on health // hint: https://osbot.org/api/org/osbot/rs07/utility/ConditionalSleep.html } } Relax my dude, no need to be mad. People just made his script whatever it was intended to be, whether he used states or not. The point was to fix the code. By the way private boolean shouldGoBank() { return inventory.isEmpty(); } tl;dr Why not just private boolean shouldBank = inventory.isEmpty(); Quote Link to comment Share on other sites More sharing options...
liverare Posted October 14, 2017 Share Posted October 14, 2017 2 minutes ago, luminlumin said: Relax my dude, no need to be mad. People just made his script whatever it was intended to be, whether he used states or not. The point was to fix the code. By the way private boolean shouldGoBank() { return inventory.isEmpty(); } tl;dr Why not just private boolean shouldBank = inventory.isEmpty(); Because that is a variable. If you set a variable, it'll never be updated unless you set it again. That's why we have functions. Quote Link to comment Share on other sites More sharing options...