Jump to content

Keyboard isn't pressing space instead going to next action.


Recommended Posts

Posted

the keyboard isn't pressing space bar to make all instead it's using the items together, then just goes straight to backing stage.

 

if (getDialogues().isPendingContinuation()) {
    getKeyboard().pressKey(KeyEvent.VK_SPACE);
    int timeout = 1600; //2 tick surpassed + 400ms ping compensate
    int sleepTime = 700; //1 tick surpassed + 100ms ping compensate

    //sleep until isPendingContinuation() == false
    new ConditionalSleep(timeout, sleepTime) {
        @Override
        public boolean condition() throws InterruptedException {
            return !getDialogues().isPendingContinuation();
        }
    }.sleep();

    getKeyboard().releaseKey(KeyEvent.VK_SPACE);
new ConditionalSleep(16000, 19000) {
    @Override
    public boolean condition() {
        return inventory.getItem("The item I'm making").getAmount() == 28;
    }
}.sleep();

 

 

case 3: {
    log("Banking the items");
    if(!getBank().isOpen()){
        getBank().open();
        new ConditionalSleep(2500, 3000){
            @Override
            public boolean condition(){
                return getBank().isOpen();
            }
        }.sleep();
    }
    else {
        bank.depositAll();
        sleep(random(500,2000));
        Stage = 1;
        break;
    }
Posted (edited)

Getting these errors in log, any help? [INFO][Bot #1][03/26 06:20:33 PM]: attempting to bank
[INFO][Bot #1][03/26 06:20:34 PM]: Attempting to make the items
[INFO][Bot #1][03/26 06:20:34 PM]: Banking the items
[ERROR][Bot #1][03/26 06:20:34 PM]: Error in script executor!
java.lang.NullPointerException
    at main.onLoop(main.java:128)
    at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(uk:63)
    at java.lang.Thread.run(Unknown Source)
[INFO][Bot #1][03/26 06:20:34 PM]: attempting to bank
[INFO][Bot #1][03/26 06:20:40 PM]: Bank Closed
[INFO][Bot #1][03/26 06:20:41 PM]: Attempting to make the items
[INFO][Bot #1][03/26 06:20:41 PM]: Dialog before it's shown
[INFO][Bot #1][03/26 06:20:46 PM]: Banking the items
[INFO][Bot #1][03/26 06:20:47 PM]: Attempting to make the items
[INFO][Bot #1][03/26 06:20:47 PM]: Dialog before it's shown

Also it's not getting past this part in the script but some how stage set's it self to 3. 

 

if (getDialogues().isPendingContinuation()) {
    log("Dialog after it's shown");
    getKeyboard().typeKey((char)32);
    log("Dialog after space");

    new ConditionalSleep(16000, 19000) {
        @Override
        public boolean condition() {
            log("Attempting to do conditional sleep");
            return inventory.getItem("The item im making").getAmount() == 28;
        }
    }.sleep();
    Stage = 3;
    break;
}

 

It's still entering stage 3 with this code. 

 

case 2: {
    log("Attempting to make the items");
    if (!inventory.isEmpty()) {
        if(inventory.contains("my item 1") && inventory.contains("my item 2")) {
            randomclicks = random(1,5);
            if(randomclicks < 3) {
                log("Dialog before it's shown");
                getInventory().interact("Use", "my item 2");
                sleep(random(1000, 3500));
                getInventory().interact("Use", "My item 1");
                sleep(random(500,2000));
                if (getDialogues().isPendingContinuation()) {
                    log("Dialog after it's shown");
                    getKeyboard().typeKey((char)32);
                    log("Dialog after space");

                    new ConditionalSleep(16000, 19000) {
                        @Override
                        public boolean condition() {
                            log("Attempting to do conditional");
                            return inventory.getItem("My item end").getAmount() == 28;
                        }
                    }.sleep();
                }
            }
            if(randomclicks >= 3) {
                log("Dialog before it's shown");
                getInventory().interact("Use", "my item 1");
                sleep(random(1000, 3500));
                getInventory().interact("Use", "my item 2");
                sleep(random(500,2000));
                if (getDialogues().isPendingContinuation()) {
                    log("Dialog after it's shown");
                    getKeyboard().typeKey((char)32);
                    log("Dialog after space");

                    new ConditionalSleep(16000, 19000) {
                        @Override
                        public boolean condition() {
                            log("Attempting to do conditional");
                            return inventory.getItem("My item end").getAmount() == 28;
                        }
                    }.sleep();
                }
            }
            else if(inventory.getItem("My item end").getAmount() == 28) {
                Stage = 3;
                break;
            }
        }
    }
}
Edited by Jueix
Posted
7 minutes ago, Gunman said:

@Jueix You had it right using the press and release


getKeyboard().pressKey(32);
getKeyboard().releaseKey(32);

I personally use the number^
But it said there was an NPE at line 128. What's line 128?

it was to bank the items in stage 3.

if(inventory.getItem("My item").getAmount() == 

if I do it this way

9 minutes ago, Gunman said:

@Jueix You had it right using the press and release


getKeyboard().pressKey(32);
getKeyboard().releaseKey(32);

I personally use the number^
But it said there was an NPE at line 128. What's line 128?

if i do it this way it works but interact's with the item and breaks the sleep / making of it.

 

log("Dialog before it's shown");
getInventory().interact("Use", "item 1");
sleep(random(1000, 3500));
getInventory().interact("Use", "item 2");
sleep(random(500,2000));
log("Dialog after it's shown");
sleep(random(500,2500));
getKeyboard().typeKey((char)32);
log("Dialog after space");

new ConditionalSleep(16000, 19000) {
    @Override
    public boolean condition() {
        log("Attempting to do conditional");
        return inventory.getItem("item 3").getAmount() == 28;
    }
}.sleep();
Posted
4 minutes ago, Gunman said:

@Jueix Okay I see why it's going to stage 3. It's because the break; is inside the else if and the code isn't reaching that, so it continues to the next case. Now idk if anything else is broken in case 2 but that's why it's moving to case 3 regardless if it should or not.

it's now not going to this code and checking if he has this amount in inventory before banking. 

 

else if(inventory.getItem("Item 3").getAmount() == 28) {
    Stage = 3;
    log("Attempting to go to stage 3");
}
Posted
20 minutes ago, Gunman said:

@Jueix Does changing the if's like this fix that? Because it shouldn't go into the else if like you have it now if it already was inside the if before it.


if(randomclicks < 3) {
    //stuff
}
else if(randomclicks >= 3) {
  //stuff
}
if(inventory.getItem("My item end").getAmount() == 28) {
  //stuff
}

Nope, but found away to make it work. My question though is if a skill level comes up with a while a sleep is going *My current conditional* Can I break the sleep to interact with the skill level and go back instead of waiting for the sleep to end then interact?

Posted
1 minute ago, Jueix said:

Nope, but found away to make it work. My question though is if a skill level comes up with a while a sleep is going *My current conditional* Can I break the sleep to interact with the skill level and go back instead of waiting for the sleep to end then interact?

Yeah, just use the or operator -> || and add another boolean to check if you leveled up

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...