February 21, 20178 yr Hi, I want onPaint to be different for each task my script is doing so it can switch stats when needed but I don't know how. I tried this: // main class public void onPaint(Graphics2D g) { Fletch fletch = new Fletch(); fletch.exchangeContext(getBot()); fletch.FletcherLoopPaint(Graphics2D g); // Fletch class public void FletcherLoopPaint(Graphics g1) { // paint } I am stuck at the onPaint method arguments (or parameters) . Edited February 21, 20178 yr by The Undefeated
February 21, 20178 yr 4 minutes ago, The Undefeated said: Hi, I want onPaint to be different for each task my script is doing so it can switch stats when needed but I don't know how. I tried this: // main class public void onPaint(Graphics2D g) { Fletch fletch = new Fletch(); fletch.exchangeContext(getBot()); fletch.FletcherLoopPaint(Graphics2D g); // Fletch class public void FletcherLoopPaint(Graphics g1) { // paint } I am stuck at the onPaint method arguments (or parameters) . You could either have a single paint and update the information you want to be displayed when you change tasks, or if you REALLY want a new onPaint method for each task you could make your Task class implement Painter: import org.osbot.rs07.canvas.paint.Painter; import java.awt.*; public class Example implements Painter { @Override public void onPaint(Graphics2D graphics2D) { } } And then when you change the current Task that is executing: getBot().removePainter(previousTask); getBot().addPainter(newTask);
February 21, 20178 yr 2 minutes ago, Explv said: You could either have a single paint and update the information you want to be displayed when you change tasks, or if you REALLY want a new onPaint method for each task you could make your Task class implement Painter: import org.osbot.rs07.canvas.paint.Painter; import java.awt.*; public class Example implements Painter { @Override public void onPaint(Graphics2D graphics2D) { } } And then when you change the current Task that is executing: getBot().removePainter(previousTask); getBot().addPainter(newTask); Adding a bit to it, if you are going to end up creating new paint classes for each of your tasks, you will most likely end up repeating lots of code, thus violating the DRY principle. If you are going to create a new painter for each of your classes you might want to create a manager class for your paints and abstract the code you are going to reuse. Just my two cents
February 21, 20178 yr Author 9 minutes ago, Explv said: You could either have a single paint and update the information you want to be displayed when you change tasks, or if you REALLY want a new onPaint method for each task you could make your Task class implement Painter: import org.osbot.rs07.canvas.paint.Painter; import java.awt.*; public class Example implements Painter { @Override public void onPaint(Graphics2D graphics2D) { } } And then when you change the current Task that is executing: getBot().removePainter(previousTask); getBot().addPainter(newTask); When I implement Painter the class has to be abstract which results in me not being able to call methods from another class using this: Fletch fletch = new Fletch(); fletch.exchangeContext(getBot()); fletch.FletcherLoop(); 5 minutes ago, Vilius said: Adding a bit to it, if you are going to end up creating new paint classes for each of your tasks, you will most likely end up repeating lots of code, thus violating the DRY principle. If you are going to create a new painter for each of your classes you might want to create a manager class for your paints and abstract the code you are going to reuse. Just my two cents My plan was to just keep the basic paint in the main class and only change the stats. Edited February 21, 20178 yr by The Undefeated