Jump to content

Script double clicking object - Help


Slakan

Recommended Posts

God day,

Note that i'm currently a complete beginner on scripting, but i have some strange behavior that when we can interact with deposit box it double clicks it every time. I don't know if this is intentional or something i'm doing wrong?

log("Invt full and we are at deposit area!");
                if(depositbox.isVisible() && deposit.contains(myPlayer().getPosition())) {
                    // Depositbox is visable and we are in the area
                    log("Deposit box visable and we are in area!");
                    if(!bank.depositBox.isOpen()) {
                        // Deposit box aint open
                        log("Depositbox aint open");
                        if(depositbox.interact("Deposit")) {
                            log("Clicking deposit box!");
                            // We can interact with the deposit box
                            new ConditionalSleep(5000) {
                                @Override
                                public boolean condition() {
                                    return bank.depositBox.open();
                                }
                            }.sleep();
                        } else {
                            // We cant interact with the deposit box!
                            log("We cant interact with deposit box!");
                        }
                    } else {
                        // Depositbox is open.
                        log("Depositbox is open!");
                    }
                } else {
                    // Deposit box not visable or we are not in area.
                    log("Depositbox or area not there.");
                }

 

Edited by Slakan
Link to comment
Share on other sites

The reason this is happening is due to this:

new ConditionalSleep(5000) {
	@Override
	public boolean condition() {
		return bank.depositBox.open();
  }
}.sleep();

The line: return bank.depositBox.open(); is a function that tries to open the deposit box and returns true if it executes the action, so basically you are clicking to open the depositBox and then your conditional sleep is opening it again. What you want to do here instead is use the isOpen() function:

new ConditionalSleep(5000) {
	@Override
	public boolean condition() {
		return bank.depositBox.isOpen();
	}
}.sleep();

 

  • Like 2
Link to comment
Share on other sites

17 hours ago, Delision said:

The reason this is happening is due to this:

new ConditionalSleep(5000) {
	@Override
	public boolean condition() {
		return bank.depositBox.open();
  }
}.sleep();

The line: return bank.depositBox.open(); is a function that tries to open the deposit box and returns true if it executes the action, so basically you are clicking to open the depositBox and then your conditional sleep is opening it again. What you want to do here instead is use the isOpen() function:

new ConditionalSleep(5000) {
	@Override
	public boolean condition() {
		return bank.depositBox.isOpen();
	}
}.sleep();

 

Thank you! You are absolute correct there, i didn't see the mistake i did, but i should have used isOpen() as you say. 

 

Much appreciated for the help!

  • Like 1
Link to comment
Share on other sites

11 hours ago, Slakan said:

Thank you! You are absolute correct there, i didn't see the mistake i did, but i should have used isOpen() as you say. 

 

Much appreciated for the help!

Also you could replace 

deposit.contains(myPlayer().getPosition())

with just deposit.contains(myPlayer()) or deposit.contains(myPosition())

Edited by minewarriors
Link to comment
Share on other sites

17 hours ago, minewarriors said:

Also you could replace 

deposit.contains(myPlayer().getPosition())

with just deposit.contains(myPlayer()) or deposit.contains(myPosition())

What is the benefit of the different versions? - If i understand my original one i access myPlayer() to get the position of my entity.

The deposit.contains(myPlayer()) would just check if my entity is within the spesific area and deposit.contains(myPosition()) would actually check the position of my entity?

Link to comment
Share on other sites

20 minutes ago, Slakan said:

What is the benefit of the different versions? - If i understand my original one i access myPlayer() to get the position of my entity.

The deposit.contains(myPlayer()) would just check if my entity is within the spesific area and deposit.contains(myPosition()) would actually check the position of my entity?

all the 3 things do the same.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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