iLeggy Posted January 12, 2019 Share Posted January 12, 2019 (edited) I wanted to code an instant typer with webwalking to GE but I wanted to solve the typing speed first. When I try to save it and run it I get an error. Is there anything visibly wrong with the code? I'm still new to to this and used someones help. package main; import java.awt.Graphics2D; import java.awt.event.KeyEvent; import org.osbot.rs07.script.Script; import org.osbotbot.rs07.script.ScriptManifest @ScriptManifest(author = "", info = "", name = "", version = "0", logo = "") public class main extends Script { private void typeStringInstant(String output) { for (int i = 0; i < output.length(); i++) { char c = output.charAt(i); int code = KeyEvent.getExtendedKeyCodeForChar(c); getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c); } getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000'); getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000'); } @Override public void onStart(); log(""); } @Override public int onLoop(); throws InterruptedException { typingStringInstant(""); return random(200,300); } @Override public void onExit(); { log(""); } @Override public void onPaint(Graphics2D g) { } My Discord is: Pod#8714 if anyone would help me one on one that would be spectacular. I've spent hours trying to figure it out myself. Edited January 12, 2019 by iLeggy Quote Link to comment Share on other sites More sharing options...
Hel Posted January 12, 2019 Share Posted January 12, 2019 Remove the semi colon from onLoop() would be a good place to start. Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted January 12, 2019 Share Posted January 12, 2019 (edited) First of all, you're not telling us what error you're receiving so how should we be able to help you? Secondly, as @Slut spotted, you have a semicolon at the declaration of your onLoop method. Your IDE most likely tells you that this is not possible. If you couldn't figure this out yourself this probably means that you don't have a single clue about what you're doing. I'd like to suggest for you to learn Java first before trying to write a script . We're more than willing to help out those in need of assistance but we expect them to at least be able to handle syntax and have at least some knowledge about the language. Edited January 12, 2019 by Eagle Scripts 1 Quote Link to comment Share on other sites More sharing options...
iLeggy Posted January 12, 2019 Author Share Posted January 12, 2019 5 hours ago, Eagle Scripts said: First of all, you're not telling us what error you're receiving so how should we be able to help you? Secondly, as @Slut spotted, you have a semicolon at the declaration of your onLoop method. Your IDE most likely tells you that this is not possible. If you couldn't figure this out yourself this probably means that you don't have a single clue about what you're doing. I'd like to suggest for you to learn Java first before trying to write a script . We're more than willing to help out those in need of assistance but we expect them to at least be able to handle syntax and have at least some knowledge about the language. I've written scripts before. Muling scripts, woodcutting scripts, simple scripts. This is my first time using complicated snippets. My friend learned ALL of Java by coding Minecraft plugins starting with simple ones moving upward. I figure I can do the same. 5 hours ago, Slut said: Remove the semi colon from onLoop() would be a good place to start. Besides the semi-colon, is there any other issues? Quote Link to comment Share on other sites More sharing options...
Jar Posted January 12, 2019 Share Posted January 12, 2019 (edited) 10 minutes ago, iLeggy said: I've written scripts before. Muling scripts, woodcutting scripts, simple scripts. This is my first time using complicated snippets. My friend learned ALL of Java by coding Minecraft plugins starting with simple ones moving upward. I figure I can do the same. Besides the semi-colon, is there any other issues? Replace onExit(); with onExit() Replace public void onStart(); with public void onStart() { and lastly the onLoop(); with onLoop() but the onLoop was already explained by @Slut That's all I can see from skimming over.. guess try executing and telling us the response & whether you got the expected outcome Suggestion - Use IDE such as IntelliJ Read start guide tutorials in the tutorial section. Edited January 12, 2019 by Jar Quote Link to comment Share on other sites More sharing options...
iLeggy Posted January 12, 2019 Author Share Posted January 12, 2019 27 minutes ago, Jar said: Replace onExit(); with onExit() Replace public void onStart(); with public void onStart() { and lastly the onLoop(); with onLoop() but the onLoop was already explained by @Slut That's all I can see from skimming over.. guess try executing and telling us the response & whether you got the expected outcome Suggestion - Use IDE such as IntelliJ Read start guide tutorials in the tutorial section. I am using Eclipse. I think I got it. package main; import java.awt.Graphics2D; import java.awt.event.KeyEvent; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "", info = "", name = "", version = 0, logo = "") public class main extends Script { private void typeStringInstant(String output) { for (int i = 0; i < output.length(); i++) { char c = output.charAt(i); int code = KeyEvent.getExtendedKeyCodeForChar(c); getBot().getKeyEventHandler().generateBotKeyEvent(400, System.currentTimeMillis(), 0, code, c); } getBot().getKeyEventHandler().generateBotKeyEvent(401, System.currentTimeMillis(), 0, 10, '\u0000'); getBot().getKeyEventHandler().generateBotKeyEvent(402, System.currentTimeMillis(), 0, 10, '\u0000'); } @Override public void onStart() { log(""); } @Override public int onLoop() throws InterruptedException { typeStringInstant("Spam goes here..."); return random(200, 300); } @Override public void onExit() { log(""); } @Override public void onPaint(Graphics2D g) { } } Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted January 12, 2019 Share Posted January 12, 2019 1 hour ago, iLeggy said: I've written scripts before. Muling scripts, woodcutting scripts, simple scripts. This is my first time using complicated snippets. My friend learned ALL of Java by coding Minecraft plugins starting with simple ones moving upward. I figure I can do the same. Besides the semi-colon, is there any other issues? Hhm but how can you have written muling scripts while using an IDE but not know that the syntax of `onLoop();` instead of `onLoop() { }` doesn't work? Quote Link to comment Share on other sites More sharing options...
Jar Posted January 12, 2019 Share Posted January 12, 2019 26 minutes ago, Eagle Scripts said: Hhm but how can you have written muling scripts while using an IDE but not know that the syntax of `onLoop();` instead of `onLoop() { }` doesn't work? " This is my first time using complicated snippets. " Which suggests he's been puzzling snippets ( from the snippet section ) together to create his expectation/script ( Which I guess isn't a bad route if you actually read the code and not just copy/paste ).. but it's irrelevant if he has or hasn't scripted before, he's here for help so it's only right to give him some.. Quote Link to comment Share on other sites More sharing options...
Chris Posted January 12, 2019 Share Posted January 12, 2019 50 minutes ago, Eagle Scripts said: Hhm but how can you have written muling scripts while using an IDE but not know that the syntax of `onLoop();` instead of `onLoop() { }` doesn't work? this ^ How did it even compile 2 Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted January 12, 2019 Share Posted January 12, 2019 35 minutes ago, Jar said: " This is my first time using complicated snippets. " Which suggests he's been puzzling snippets ( from the snippet section ) together to create his expectation/script ( Which I guess isn't a bad route if you actually read the code and not just copy/paste ).. but it's irrelevant if he has or hasn't scripted before, he's here for help so it's only right to give him some.. Of course. As I stated, most of us are more than willing to help people out, including me. What you can't expect from me, however, is that I will just spoonfeed everything when I, in fact, know that he won't learn from it. Would you explain how to shift gears to somebody who doesn't know how to get the engine to start but got the engine running because he was able to mimic something without actually understanding what he just mimicked? I wouldn't. 1 Quote Link to comment Share on other sites More sharing options...
iLeggy Posted January 13, 2019 Author Share Posted January 13, 2019 4 hours ago, Eagle Scripts said: Of course. As I stated, most of us are more than willing to help people out, including me. What you can't expect from me, however, is that I will just spoonfeed everything when I, in fact, know that he won't learn from it. Would you explain how to shift gears to somebody who doesn't know how to get the engine to start but got the engine running because he was able to mimic something without actually understanding what he just mimicked? I wouldn't. I never asked for a spoonfeed and yeah, I made mistakes. I was into this over a year ago and it's like I'm re-learning it. - Thought this was the help section but it's just the insult section. Quote Link to comment Share on other sites More sharing options...
Jar Posted January 13, 2019 Share Posted January 13, 2019 3 hours ago, iLeggy said: I never asked for a spoonfeed and yeah, I made mistakes. I was into this over a year ago and it's like I'm re-learning it. - Thought this was the help section but it's just the insult section. Well technically they're right in what they said, Like @Eagle Scripts stated " you have a semicolon at the declaration of your onLoop method. Your IDE most likely tells you that this is not possible. If you couldn't figure this out yourself this probably means that you don't have a single clue about what you're doing. " I would definitely suggest just reading a basic starter tutorial in the tutorial section, you're making below intermediate mistakes.. no disrespect either could just be a typo and you didn't notice, but I think it's more to the fact you didn't notice your error, especially when you're using Eclipse IDE which would have told you that isn't possible. Goodluck :). 8 hours ago, Eagle Scripts said: Of course. As I stated, most of us are more than willing to help people out, including me. What you can't expect from me, however, is that I will just spoonfeed everything when I, in fact, know that he won't learn from it. Would you explain how to shift gears to somebody who doesn't know how to get the engine to start but got the engine running because he was able to mimic something without actually understanding what he just mimicked? I wouldn't. Yeah I completely get where you're coming from, however just felt a little sarcastic in your last response to him.. but you're right in what you're saying. 1 Quote Link to comment Share on other sites More sharing options...
Eagle Scripts Posted January 13, 2019 Share Posted January 13, 2019 Didn’t want to insult anybody, just wanted to state that you should learn the language first before attempting to script, you’ll benefit from it in the long run . 1 Quote Link to comment Share on other sites More sharing options...