For furnace, you would want to cond sleep when widget are null or no longer visible.
You want to interact with furnace if you been idle for x seconds
private boolean idleFor(int millis){
if(myPlayer().isAnimating())
{
timeSinceAnimation = System.currentTimeMillis();
}
else
{
timeSinceIdle = System.currentTimeMillis();
}
return timeSinceAnimation + millis < timeSinceIdle;
}
variables are global
using equals method is best suited for strings, it's not good to compare objects otherwise like that.
String s = new String("hello");
String p = new String("hello");
s.equals(p) // true
s == p // false;
public boolean hasItem(String itemName){
return getInventory.contains(itemName);
}
You just create methods to reduce any duplicate code. Example: I can call this method whenver i need to see if i have I have an item in my inventory.
For more practical use, the methods you invoke will have larger pieces of code inside them.
Yea I agree Apa completly. But relative to the code by op, names of items are constant ;), regardless of how he sets up the code.
I get what you mean however.
Easier way to get tree area;
Area yewArea = new Area(3203, 3506, 3225, 3497);
Area oakArea = new Area(3171, 3425, 3159, 3399);
Area areaToChop = getSkills().getDynamic(Skills.WOODCUTTING) >= 60 ? yewArea : oakArea;
Somewhat, you can create your own methods and then call them in the onLoop. When interacting with NPCs or Entitys, you need the references to those objects updated (i.e within the loop). Constants can be global as you have them (Strings, areas), the rest you should do within methods ;)
how he used string is good, if you put it in a method, you would be creating a string object everytime. Note, anything final should be left in uppercase (final string NAME = "")
Yes, however there is a case when you click, and are moving, a feather either disappears or is already taken. Yet the bot continues towards the feather that is no longer there.
I understand alek may have posted explaining but, you still haven't given me a valid reason. Saying that its more 'bot like' doesn't prove anything.
And yes, I keep behavior strictly to what the method does. Same as the interact method in osbot, you must first check to see if an entity is not null and visible before you interact, it's not the responsibility of the interact method to do that. Simply creating a method to check beforehand is what you're looking for.
I never rejected your criticism, i'm asking for clarification.
The purpose of sleep is to avoid instantaneous reaction. Otherwise, explain your reasoning.
The behavior of the method is to interact, not check.
As mentioned, overloading is doable.
Didn't see an interact method between item and entity. Here's an example (can overload to accept String) :
Does not check for item
Does not check for entity
returns true on interaction between item and entity