imancity Posted May 10, 2016 Share Posted May 10, 2016 So I tried following the Tea Thiever tutorial and make my own simple Kebab Buyer to learn a little, and this is what I have so far. I compiled and tried it and nothing happens. The logger shows some error I could post if need be, but I closed out of it. The bot does absolutely nothing. FYI, I am completely new to scripting/programming so I may have made some completely newby mistakes and didn't realize at all. Here's the code: */ import org.osbot.rs07.api.Walking; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(name = "Kebab Buyer", author = "Faris", version = 1.0, info = "first script", logo = "") public class KebabBuyer extends Script { @Override public void onStart() { log("Let's buy some Kebabs!"); //Code here will execute before the loop is started } private enum State { BUY, BANK, WAIT }; private State getState() { if (inventory.contains("Coins")) return State.BUY; else stop(); if (inventory.isFull()) return State.BANK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case BUY: getWalking().walk(new Position(3274, 3180, 0)); npcs.closest("Karim").interact("Talk-to"); if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); } case BANK: getWalking().walk(new Position(3270, 3168, 0)); if (!getBank().isOpen()){ getBank().open(); } else { bank.depositAll("Kebab"); getBank().close();} case WAIT: return random(100,400); //The amount of time in milliseconds before the loop starts over } //@Override //public void onExit() { log("Thanks for using my script!"); //Code here will execute after the script ends //@Override //public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) return random(200,300); } } Quote Link to comment Share on other sites More sharing options...
GaetanoH Posted May 10, 2016 Share Posted May 10, 2016 Post the error please! Will help us out alot Quote Link to comment Share on other sites More sharing options...
Woody Posted May 10, 2016 Share Posted May 10, 2016 (edited) private enum State { BUY, BANK, WAIT }; <-- remove the semi colon */ <-- remove this import org.osbot.rs07.api.Walking; Edited May 10, 2016 by Woody Quote Link to comment Share on other sites More sharing options...
Vilius Posted May 10, 2016 Share Posted May 10, 2016 (edited) @Override public int onLoop() throws InterruptedException { switch (getState()) { case BUY: getWalking().walk(new Position(3274, 3180, 0)); npcs.closest("Karim").interact("Talk-to"); if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); } case BANK: getWalking().walk(new Position(3270, 3168, 0)); if (!getBank().isOpen()){ getBank().open(); } else { bank.depositAll("Kebab"); getBank().close();} case WAIT: return random(100,400); //The amount of time in milliseconds before the loop starts over } //@Override //public void onExit() { log("Thanks for using my script!"); //Code here will execute after the script ends //@Override //public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) return random(200,300); } } There is yar problem, you have your paint and on exit in the loop :b Fixed version: @Override public int onLoop() throws InterruptedException { switch (getState()) { case BUY: getWalking().walk(new Position(3274, 3180, 0)); npcs.closest("Karim").interact("Talk-to"); if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); } break; case BANK: getWalking().walk(new Position(3270, 3168, 0)); if (!getBank().isOpen()){ getBank().open(); } else { bank.depositAll("Kebab"); getBank().close(); } break; case WAIT: return random(100,400); //The amount of time in milliseconds before the loop starts over break; } return random(200,300); } //@Override //public void onExit() { log("Thanks for using my script!"); //Code here will execute after the script ends //} //@Override //public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) //} } And do what woody said :b Edited May 10, 2016 by Vilius Quote Link to comment Share on other sites More sharing options...
Woody Posted May 10, 2016 Share Posted May 10, 2016 (edited) Also, when using an IDE, it will tell you where the errors are. If you are going to be careless when writing scripts, don't bother learning how to write scripts. Everything has to be exact, otherwise you will get these kind of errors. @Override public int onLoop() throws InterruptedException { switch (getState()) { case BUY: getWalking().walk(new Position(3274, 3180, 0)); npcs.closest("Karim").interact("Talk-to"); if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); } case BANK: getWalking().walk(new Position(3270, 3168, 0)); if (!getBank().isOpen()){ getBank().open(); } else { bank.depositAll("Kebab"); getBank().close();} case WAIT: return random(100,400); //The amount of time in milliseconds before the loop starts over } //@Override //public void onExit() { log("Thanks for using my script!"); //Code here will execute after the script ends //@Override //public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) return random(200,300); } } There is yar problem, you have your paint and on exit in the loop :bFixed version: @Override public int onLoop() throws InterruptedException { switch (getState()) { case BUY: getWalking().walk(new Position(3274, 3180, 0)); npcs.closest("Karim").interact("Talk-to"); if (dialogues.isPendingContinuation()) { dialogues.clickContinue(); } else if (dialogues.isPendingOption()) { dialogues.selectOption("Yes please."); } case BANK: getWalking().walk(new Position(3270, 3168, 0)); if (!getBank().isOpen()){ getBank().open(); } else { bank.depositAll("Kebab"); getBank().close();} case WAIT: return random(100,400); //The amount of time in milliseconds before the loop starts over } return random(200,300); } //@Override //public void onExit() { log("Thanks for using my script!"); //Code here will execute after the script ends //} //@Override //public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) //} } Your editing will still give him errors. I bet that you can't find the problem in your editing! Edited May 10, 2016 by Woody Quote Link to comment Share on other sites More sharing options...
Vilius Posted May 10, 2016 Share Posted May 10, 2016 Also, when using and IDE it will tell you where the errors are. If you are going to be careless when writing scripts, don't bother at all to write any scripts. Everything has to be exact, otherwise you will get these kind of errors. Your editing will still give him errors. I bet that you can't find the problem in your editing! I did find it actually, wanted to edit my post and saw that you have posted it. No need to flame me like always Quote Link to comment Share on other sites More sharing options...
Woody Posted May 10, 2016 Share Posted May 10, 2016 I did find it actually, wanted to edit my post and saw that you have posted it. No need to flame me like always It's still there. No flame, only giving you the motivation to find it. 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 10, 2016 Author Share Posted May 10, 2016 Also, when using an IDE, it will tell you where the errors are. If you are going to be careless when writing scripts, don't bother learning how to write scripts. Everything has to be exact, otherwise you will get these kind of errors. Your editing will still give him errors. I bet that you can't find the problem in your editing! I've never written code, let alone scripts, but I will for sure pay attention and be careful. Just trying to run my first one and then I'll study and see what does what. I learn best through trial and error. Thanks for the help everyone! I'll run it and see what happens, will post errors here. Quote Link to comment Share on other sites More sharing options...
Woody Posted May 10, 2016 Share Posted May 10, 2016 I've never written code, let alone scripts, but I will for sure pay attention and be careful. Just trying to run my first one and then I'll study and see what does what. I learn best through trial and error. Thanks for the help everyone! I'll run it and see what happens, will post errors here. Don't forget to learn the theoretical part before going forward to trial and error! 1 Quote Link to comment Share on other sites More sharing options...
Vilius Posted May 10, 2016 Share Posted May 10, 2016 (edited) It's still there. No flame, only giving you the motivation to find it. Found it, he didn't have break; the cases fall on each other Cookie pls? Edited May 10, 2016 by Vilius Quote Link to comment Share on other sites More sharing options...
imancity Posted May 10, 2016 Author Share Posted May 10, 2016 private enum State { BUY, BANK, WAIT }; <-- remove the semi colon */ <-- remove this import org.osbot.rs07.api.Walking; For the second part where you want me to remove the */, it makes my whole bunch of code green. Doesn't seem right. Quote Link to comment Share on other sites More sharing options...
Vilius Posted May 10, 2016 Share Posted May 10, 2016 (edited) For the second part where you want me to remove the */, it makes my whole bunch of code green. Doesn't seem right. You have to remove the comments start too! /* and */ plus what is in between them for it to not make it green. And it seems like you didn't post the full code if you have /* that loose somewhere in your code. Edited May 10, 2016 by Vilius 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted May 10, 2016 Share Posted May 10, 2016 (edited) I've never written code, let alone scripts, but I will for sure pay attention and be careful. Just trying to run my first one and then I'll study and see what does what. I learn best through trial and error. Thanks for the help everyone! I'll run it and see what happens, will post errors here. I recommend you learn Java first, at least the basics. Follow some tutorials, write some programs, then come back to scripting. Things like syntax errors should be something that you can solve by yourself There are too many posts in the scripting help section where the OP has a problem that would be solved if he/she just spent some time learning Java. Edited May 10, 2016 by Explv 1 Quote Link to comment Share on other sites More sharing options...
imancity Posted May 10, 2016 Author Share Posted May 10, 2016 I recommend you learn Java first, at least the basics. Follow some tutorials, write some programs, then come back to scripting. Things like syntax errors should be something that you can solve by yourself There are too many posts in the scripting help section where the OP has a problem that would be solved if he/she just spent some time learning Java. Will do. My roommate is in grad school for Computer Science so I was just having him do this with me, and I wanted to give it a shot myself. I'll def learn some Java to make this easier on me. Quote Link to comment Share on other sites More sharing options...
Woody Posted May 10, 2016 Share Posted May 10, 2016 Found it, he didn't have break; the cases fall on each other Cookie pls? You forgot to delete that. Don't worry, you will learn, newbie! Quote Link to comment Share on other sites More sharing options...