Hey,
I would like some way to count the number of times the bot clicks. My primary motive for this is that I want to make sure that the conditional sleeps are performing correctly i.e. after clicking on a tree the bot doesn't click again until the tree is dead.
I took a look at BotMouseListener, and got that to work (in a somewhat hacky manner).
Unfortunately, while that seems to be correctly counting my manual clicks on the screen, it is not recording the clicks that the bot itself makes. (AAARRGHRGHRGHR).
I searched through the snippets and such but I wasn't able to find any post addressing this.
Any help would be appreciated.
(If someone wants to tell me the none hacky way of implementing BotMouseListener that would also be great)
ClickCounter File:
package Helpers;
import java.awt.event.MouseEvent;
import static java.awt.event.MouseEvent.MOUSE_CLICKED;
import org.osbot.rs07.input.mouse.BotMouseListener;
import org.osbot.rs07.script.MethodProvider;
public class ClickCounter extends BotMouseListener {
// This allows us to reroute our output to the same log console as our main script.
// The script writes, "ClickCounter.MP = this".
public static MethodProvider MP = null;
public static int clickCount = 0;
@Override
public void checkMouseEvent(MouseEvent mouseEvent) {
MP.log(mouseEvent);
if (mouseEvent.getID() == MOUSE_CLICKED) {
assert(MP != null);
MP.log("MINE: Mouse Clicked!");
clickCount++;
}
}
}
Script File:
package Attempt1;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import Helpers.ClickCounter;
@ScriptManifest(author="RS3141", info="Test1", logo="", name="Example Script 1", version=1)
public class ExampleScript1 extends Script {
@Override
public void onStart() {
// Allow the ClickCounter to log to the output.
ClickCounter.MP = this;
this.bot.addMouseListener(new ClickCounter());
}
@Override
public int onLoop() throws InterruptedException {
// Do stuff
return 500;
}
}