Slakan Posted September 16, 2021 Posted September 16, 2021 (edited) 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 September 16, 2021 by Slakan
Delision Posted September 16, 2021 Posted September 16, 2021 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(); 2
Slakan Posted September 17, 2021 Author Posted September 17, 2021 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! 1
minewarriors Posted September 17, 2021 Posted September 17, 2021 (edited) 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 September 17, 2021 by minewarriors
Slakan Posted September 18, 2021 Author Posted September 18, 2021 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?
minewarriors Posted September 18, 2021 Posted September 18, 2021 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. 1