Jump to content

Scripting help


Recommended Posts

Posted (edited)
first of all im using IntellJ

Im trying to use my main script to call, to a second script to keep it more clean / less code to go through

I've tried mulitpul ways and i always find myself with errors
my current error will no go away after many attemps

Operator '!' cannot be applied to 'void'
Error is this piece of code where is errors is
 while (!highLevelAlch.onExit()) { 
     highLevelAlch.onLoop();



private void startSecondaryScript() {
        log("Starting Secondary Script...");
        secondaryScriptThread = new Thread(() -> {
            HighLevelAlch highLevelAlch = new HighLevelAlch(getBot());
            highLevelAlch.exchangeContext(getBot());

            try {
                highLevelAlch.onStart();
                while (!highLevelAlch.onExit()) {
                    highLevelAlch.onLoop();
                    Thread.sleep(100); // Adjust the sleep duration as needed
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        secondaryScriptThread.start();
    }

    public void stopSecondaryScript() {
        if (secondaryScriptThread != null && secondaryScriptThread.isAlive()) {
            secondaryScriptThread.interrupt();
        }
    }

    @Override
    public void onExit() {
        log("Exiting Ethereum Bracelet Charging Script");
        try {
            closeBank(); // Close the bank when the script exits
        } catch (InterruptedException e) {
            throw new RuntimeException(e);

        }
    }
}
Edited by DarkScuzz
Posted

I think i figured it out
but please correct me if im wrong

i needed to add

public boolean onExit;
on my second script

and on my main i changed it to this
try {
        highLevelAlch.onStart();
        while (highLevelAlch.onExit) {
            highLevelAlch.onLoop();
            Thread.sleep(100); // Adjust the sleep duration as needed
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
});

seems to be fine, no errors atm.. going to test
watch it breaks xD

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...