Jump to content

Why is this instant typer not working?


iLeggy

Recommended Posts

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 by iLeggy
Link to comment
Share on other sites

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 by Eagle Scripts
  • Like 1
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by Jar
Link to comment
Share on other sites

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) {

	}

}

 

Link to comment
Share on other sites

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? :(

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

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. 

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

  • 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...