July 29, 20178 yr 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 } }
July 29, 20178 yr NPC spot = npcs.closest("Fishing spot"); put this below this public final int onLoop() throws InterruptedException {
July 29, 20178 yr Author 27 minutes ago, Get Rekt said: NPC spot = npcs.closest("Fishing spot"); put this below this public final int onLoop() throws InterruptedException { Nice it works! Can you explain to me I need to put that line of code there though?
July 29, 20178 yr 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.
Create an account or sign in to comment