Snowydell Posted January 23, 2015 Share Posted January 23, 2015 Ok so here's the part of the code I need help on. private State getState() { if(!myPlayer().isAnimating() && !inventory.isFull()) { return State.FISH; } if(inventory.isFull()) { return State.DROP; } return State.WAIT; } public int onLoop() throws InterruptedException { switch (getState()) { case FISH: NPC fishingspot = npcs.closest("Fishing Spot"); fishingspot.interact("Net"); break; case DROP: if(inventory.isFull()) { inventory.dropAllExcept("Small fishing net"); } break; My first question is if it benefits or does the same thing if I put the if statement in the case. As seen in the drop case or can I just leave it out and it will execute the same way since it already declared it needed to drop. Second question is for some reason my player drops the fish fairly slow then after it's all dropped stands around for 10 seconds then goes back to fishing, any fix for these? Thanks Link to comment Share on other sites More sharing options...
Mysteryy Posted January 23, 2015 Share Posted January 23, 2015 If im understanding you, you are asking if its necessary to have: if(inventory.isFull()) { return State.DROP; } and then again have this: case DROP: if(inventory.isFull()) { inventory.dropAllExcept("Small fishing net"); } break; ? If that is your question, then its not really necessary. What you are doing could be called "Defensive programming". Basically its checking the crap out of everything to make sure that its what you want, which prevents any unwanted results or nulls etc. I am not a fan of state based scripting, I always use task based. Case gets too messy imo, but thats just me. ^_^ 2 Link to comment Share on other sites More sharing options...
Snowydell Posted January 23, 2015 Author Share Posted January 23, 2015 (edited) Yeah that was it, thank you for the answer , what is task based if it's not to hard to explain. Also does anyone know why my character drops fish slow then stands around for 10 seconds doing nothing until it starts to fish again? Edited January 23, 2015 by Snowydell Link to comment Share on other sites More sharing options...
Mysteryy Posted January 23, 2015 Share Posted January 23, 2015 Yeah that was it, thank you for the answer , what is task based if it's not to hard to explain. Also does anyone know why my character drops fish slow then stands around for 10 seconds doing nothing until it starts to fish again? Oh yea, dropAll is a slow action. There isnt a way to fix it that I know of other than writing your own method. 1 Link to comment Share on other sites More sharing options...
Snowydell Posted January 23, 2015 Author Share Posted January 23, 2015 Ah I see, thanks for the answers Link to comment Share on other sites More sharing options...
osbotbot1 Posted January 23, 2015 Share Posted January 23, 2015 shit looks confusing. where can you learn to do stuff like this? 1 Link to comment Share on other sites More sharing options...
Snowydell Posted January 23, 2015 Author Share Posted January 23, 2015 Learn some Java first then go to the tutorial section and use one of the tutorials as a base. You could learn the basics of Java in less than a week. Also, it looks confusing because of the way I copy and pasted it so the format is messed up, hard to read Link to comment Share on other sites More sharing options...
Isolate Posted January 24, 2015 Share Posted January 24, 2015 as for the dropping you could try something like: void dropAllExceptA(String...names) throws InterruptedException { if(Tab.INVENTORY.isOpen(this.bot)){ for(int i = 1; i < 29; i++){ Item item = inventory.getItemInSlot(i); if(item != null && !item.getName().equals(names)){ item.interact("Drop"); sleep((long) random(0, 0)); } } }else{ tabs.open(Tab.INVENTORY); sleep((long) random(0, 0)); } } void dropAllExceptB(String...names) throws InterruptedException { if(Tab.INVENTORY.isOpen(this.bot)){ Item[] items = inventory.getItems(); if(items != null) { for (int i = 0; i < items.length; i++) { Item item = items[i]; if (item != null && !item.getName().equals(names)) { item.interact("Drop"); sleep((long) random(0, 0)); } } } }else{ tabs.open(Tab.INVENTORY); sleep((long) random(0, 0)); } } i dont actually know if there's alot of difference between the methods but you could alter the length of sleeps to make it quicker Yes i wrote 29. 1 Link to comment Share on other sites More sharing options...
Snowydell Posted January 24, 2015 Author Share Posted January 24, 2015 as for the dropping you could try something like: void dropAllExceptA(String...names) throws InterruptedException { if(Tab.INVENTORY.isOpen(this.bot)){ for(int i = 1; i < 29; i++){ Item item = inventory.getItemInSlot(i); if(item != null && !item.getName().equals(names)){ item.interact("Drop"); sleep((long) random(0, 0)); } } }else{ tabs.open(Tab.INVENTORY); sleep((long) random(0, 0)); } } void dropAllExceptB(String...names) throws InterruptedException { if(Tab.INVENTORY.isOpen(this.bot)){ Item[] items = inventory.getItems(); if(items != null) { for (int i = 0; i < items.length; i++) { Item item = items[i]; if (item != null && !item.getName().equals(names)) { item.interact("Drop"); sleep((long) random(0, 0)); } } } }else{ tabs.open(Tab.INVENTORY); sleep((long) random(0, 0)); } } i dont actually know if there's alot of difference between the methods but you could alter the length of sleeps to make it quicker Yes i wrote 29. Hm let me try that thanks Link to comment Share on other sites More sharing options...
Isolate Posted January 24, 2015 Share Posted January 24, 2015 Hm let me try that thanks if you get an error quote me and post it. Link to comment Share on other sites More sharing options...