Jump to content

My script won't start


kingbutton

Recommended Posts

Hello,

So I've been watching a YouTube video and looking at the tutorials posted on the forums on creating my first script.

I'm trying to run a test like the video, when it first ran it's test, but when I attempt to run my code, nothing happens.

 

and here's the code, it's not exactly like the video, but I don't see the problem with when I try to run it.

 


import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.Graphics2D;

import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.model.NPC;

@ScriptManifest(author = "Kingbutton", name = "Shrimp Catcher", info = "Catches shrimp at Draynor Village", version = 0.1, logo = "")
public final class Main extends Script {

    NPC spot = npcs.closest("Fishing spot");

    @Override
    public void onStart() {
        log("You have activated Shrimp Catcher!");
    }

    @Override
    public final int onLoop() throws InterruptedException {

        if (!inventory.isFull()) {

            // fishes
            if (spot != null) {
                if (spot.isVisible()) {
                    //if() adding this later.
                    spot.interact("Net");
                } else {
                    // else statement
                    camera.toEntity(spot);
                }
            }
        }
        return 50;
    }

    public void onExit() {
        log("Thanks for using Shrimp Catcher!");
    }

    @Override
    public void onPaint(Graphics2D g) {
        // gui

    }

}

Link to comment
Share on other sites

2 hours ago, kingbutton said:

Nice it works! Can you explain to me I need to put that line of code there though?

Cause the first thing OSBot does is do stuff in onStart() method, then loops your logic in onLoop() method. You fetch the fishing spot only when the class is initialized (which will be null).

You want to find your npcs in the onLoop() method.  

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