pinto Posted April 9, 2015 Posted April 9, 2015 (edited) I'm getting two errors on Line 2 of this code. public int onLoop() { public void onMessage(Message message) throws InterruptedException { String txt = message.getMessage().toLowerCase(); if (txt.contains("Overload")) { return inv.interactWithName(Overload, "Drink"); } else return false; } 1 - it's saying void is an invalid variable for OnMessage. What else should it be? 2 - the second message it's saying is returning a syntax error. Saying I need to insert ";" to complete the local variable declaration statement. Edited April 9, 2015 by pinto
Woody Posted April 9, 2015 Posted April 9, 2015 You've only stated what you want to write. What's your question?
pinto Posted April 9, 2015 Author Posted April 9, 2015 You've only stated what you want to write. What's your question? Will the Message listener in the API work for the overload? How do I pull the information from the absorption display in order to know when to sip the absorption pot?
Woody Posted April 9, 2015 Posted April 9, 2015 (edited) Well, if you get a message that the overload effect has run out, then yes, you can use message listener. Alternatively, you can use a timer for overload, if the effect last for 5 minutes like you said. For the absorption, you can use widgets. Read the value of the widget where the amount of absorption displays. Then you can determine whether you should take a sip or not. Edited April 9, 2015 by Woody
Polo Posted April 9, 2015 Posted April 9, 2015 Idk much about coding, but you can do something like if your hp is greater than or equal to 41 then interact with overload, or you can use a timer or find the chatbox text. For absorptions, they tell you in the chatbox how much absorbed hits you have left, so try using the message listener to find the first number of how much you have left. Example would be "You have 242 hits left" make it find "You have 2"
pinto Posted April 9, 2015 Author Posted April 9, 2015 Your making a method in a method, doesn't work. I'm new at this, I don't really know what that means... What should I do then?
Lemons Posted April 9, 2015 Posted April 9, 2015 I'm new at this, I don't really know what that means... What should I do then? First off prob go read up on Java and such. I know its not any fun, but having a basic understanding of progamming will help a ton with making scripts, else everything is seen as just "magic", not cause and effect. Anyways, how you would do this is: public int onLoop() { // We start the onLoop method // This is out main loop } // We close off this method public void onMessage(Message message) throws InterruptedException { // We start onMessage if (message.getMessage().toLowerCase().contains("Overload")) // Check if there is an overload return inv.interactWithName(Overload, "Drink"); // Drink said overload? no Overload variable though, meant to be String? return false; // We return false incase nothing is needed } // We close this method
pinto Posted April 9, 2015 Author Posted April 9, 2015 (edited) First off prob go read up on Java and such. I know its not any fun, but having a basic understanding of progamming will help a ton with making scripts, else everything is seen as just "magic", not cause and effect. Anyways, how you would do this is: public int onLoop() { // We start the onLoop method // This is out main loop } // We close off this method public void onMessage(Message message) throws InterruptedException { // We start onMessage if (message.getMessage().toLowerCase().contains("Overload")) // Check if there is an overload return inv.interactWithName(Overload, "Drink"); // Drink said overload? no Overload variable though, meant to be String? return false; // We return false incase nothing is needed } // We close this method Yeah, i need to do that... It's meant to check if overload is contained in a message. Meaning when the message appears that the overload has run out, this script will execute, find the overload in the inventory, and drink it. Edited April 9, 2015 by pinto
VladBots Posted April 9, 2015 Posted April 9, 2015 First off prob go read up on Java and such. I know its not any fun, but having a basic understanding of progamming will help a ton with making scripts, else everything is seen as just "magic", not cause and effect. Anyways, how you would do this is: public int onLoop() { // We start the onLoop method // This is out main loop } // We close off this method public void onMessage(Message message) throws InterruptedException { // We start onMessage if (message.getMessage().toLowerCase().contains("Overload")) // Check if there is an overload return inv.interactWithName(Overload, "Drink"); // Drink said overload? no Overload variable though, meant to be String? return false; // We return false incase nothing is needed } // We close this method .toLowerCase().contains("Overload") :P 1
Lemons Posted April 9, 2015 Posted April 9, 2015 .toLowerCase().contains("Overload") I didn't really clean the code, just fixed the big issues. Can't spoon feed everything :p 1
Fruity Posted April 9, 2015 Posted April 9, 2015 its "Drink" then overload i think tbh. action then item.
FrostBug Posted April 9, 2015 Posted April 9, 2015 public void onMessage(Message message) throws InterruptedException { // We start onMessage if (message.getMessage().toLowerCase().contains("Overload")) // Check if there is an overload return inv.interactWithName(Overload, "Drink"); // Drink said overload? no Overload variable though, meant to be String? return false; // We return false incase nothing is needed } // We close this method Interesting how you're returning booleans in a void method 6
Joseph Posted April 10, 2015 Posted April 10, 2015 public void onMessage(Message message) throws InterruptedException { // We start onMessage if (message.getMessage().toLowerCase().contains("Overload")) // Check if there is an overload return inv.interactWithName(Overload, "Drink"); // Drink said overload? no Overload variable though, meant to be String? return false; // We return false incase nothing is needed } // We close this method Interesting how you're returning booleans in a void method How do you know that's not a void method