Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • AbstractScript - help


    abdulr

    Recommended Posts

    27 minutes ago, abdulr said:

    I assume you code with one main class using switch cases for different tasks?

    I have one script using nodes but it's small, I mostly use enum for States and a switch statement 

    Link to comment
    Share on other sites

    6 minutes ago, Nuclear Nezz said:

    change the AbstractScript script; to MethodContext ctx;

    You'll still have all of the api methods (I assume you're using TaskNode)

    every TaskNode extends MethodContext.

    Personally, I would suggest just making your own Node class, that way you have more control over what you have access to when you need it, then use an AbstractScript for your main script class, and handle the nodes on your own in the onLoop.

     

    i'm a little confused but this is what i'm trying to do, I have coded before in powerbot (not advertising) and this is my code

    *I removed all the code so its simple to read*

    This is my main class

    public class Main extends PollingScript<ClientContext> implements PaintListener{
        
        @Override
        public void poll() {
            for (Task task : taskList) {
                if (task.activate()) {
                    task.execute();
                    break;
                }
            }
        }
    }

     

    This is my task abstract class

    public abstract class Task extends ClientAccessor {
    
        public Task(ClientContext ctx) {
            super(ctx);
        }
    
        public abstract boolean activate();
        public abstract void execute();
    }
    

     

    This is my Random Events Class (anti-ban)

    class RandomEvents extends ClientAccessor {
        
        RandomEvents(ClientContext ctx) {
            super(ctx);
        }
    
        void moveCamera() {
            // move camera
        }
    }
    

     

    One of my tasks (node) was Chop

    public class extends     private re new ; // Random Event Class
        public Chopsuper;
        @Override
        public boolean activate@Override
        public void executeprivate void randomEvents        // moves camera
            if 1re;
            
    

     

    But how do i do that in dream bot, be nice if you could show code, would be better than explaining the steps, thanks

    Link to comment
    Share on other sites

    Last bit come out wrong heres the fix version

    public class Chop extends Task {
    
        private RandomEvents re = new RandomEvents(ctx); // Random Event Class
    
        public Chop(ClientContext ctx) {
            super(ctx);
        }
    
        @Override
        public boolean activate() {}
    
        @Override
        public void execute() {}
    
        private void randomEvents() {
            // moves camera
            if (antiBanEvent == 1) {
                re.moveCamera();
            }
        }
    }
    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.