ggdre
Members-
Posts
4 -
Joined
-
Last visited
ggdre's Achievements
-
Thanks, this is great. Will give it a try!
-
As in starting an instance of the SkillTracker on each loop? That could work, thank you! It's not that the player doesn't successfully initiate the firemaking animation, rather the firemaking animation doesn't return true for Players.getLocal().isAnimating(). Thanks! Would still love to find a tutorial for the ExperienceListener or other Listeners built into the API, if anyone can help!
-
ggdre started following Using ExperienceListener in Script
-
I'm relatively new to scripting in DreamBot and Java and have been working on a simple Firemaking script, but seem to be getting a lot of false negatives for Players.getLocal().isAnimating(), leading to lots of dropped logs and missed XP. To counteract this I'm trying to implement the ExperienceListener, so that after using the tinderbox on the logs the script sleeps until the player receives and XP drop. However, I can't for the life of me figure out how to properly implement this in my script and know I'm making some silly mistakes but can't find a proper tutorial anywhere at my level. Here is what I have so far: // Start ExperienceListener.java // import org.dreambot.api.script.event.impl.ExperienceEvent; interface ExperienceListener extends java.util.EventListener { public boolean onGained(ExperienceEvent event); } // End ExperienceListener.java // // Start XpDrop.java // import org.dreambot.api.script.event.impl.ExperienceEvent; public class XpDrop implements ExperienceListener { @Override public boolean onGained(ExperienceEvent event) { return true; } } // End XpDrop.java // The part of the script I'm trying to implement this into: public int execute() { // Construct FireMaker to access getLogs method FireMaker fireMaker = new FireMaker(); // Get logs String logs = fireMaker.getLogs(); // Use tinderbox Inventory.interact("Tinderbox"); sleep(Calculations.random(250, 500)); // On logs Inventory.interact(logs); // Construct XpDrop Class XpDrop xpDrop = new XpDrop(); // Sleep until XP drop while (!xpDrop.onGained(ExperienceEvent event)) { // This is where I'm having problems - I don't know what to pass into onGained() sleep(Calculations.random(300,700) } return 300; } Very grateful for any help or links to resources!
-
EDIT: Solved by enabling script paint in menu... someone please delete this to hide my shame I'll start off by saying I'm completely new to programming with DreamBot and Java as a whole. Tried writing my first DB script today (a simple banking woodcutter) but can't for the life of me get onPaint() to paint my strings. I've ready many of the (really great) guides on this forum and still can't get it to work. I know I must be missing something simple - here is my code: private Timer timer; @Override public void onPaint(Graphics graphics) { Graphics2D g = (Graphics2D)graphics; // Have tried both with and without casting to Graphics2D g.setColor(Color.GREEN); g.setFont(new Font("Arial",Font.PLAIN,12)); g.drawString("XP/hour: " + SkillTracker.getGainedExperiencePerHour(Skill.WOODCUTTING),15,15); g.drawString("Total XP: " + SkillTracker.getGainedExperience(Skill.WOODCUTTING),15,35); g.drawString("Running for: " + timer,15,55); super.onPaint(g); // Have also tried with and without with no luck } I'm not calling onPaint() on paint anywhere else, which is my first thought as someone familiar with Python. Please help if you know how!