Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problem with NPC object?

Featured Replies

Hello

 

This is probably just a dumb error on my part, but for some reason, this NPC object isn't working correctly. Here's my code:

package nodes;

import core.Node;
import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;


/**
 * Created by ___ on 3/28/2016.
 */
public class Finding extends Node {

    NPC npc;
    NPC previous_npc;

    public Finding(Script script) {
        super(script);
    }

    public String status() {
        return "Finding new NPC to chat with...";
    }

    /**
     * This method checks to make sure the conditions are true, if they are, it will start
     * the Finding node. (Located in the execute() method.
     * @return if the conditions are met or not.
     * @throws InterruptedException
     */
    public boolean validate() throws InterruptedException {
        if (!script.getDialogues().inDialogue()) return true;
        return false;
    }

    public boolean execute() throws InterruptedException {
        npc = npcs.closest(new Filter<NPC>() { 
            @Override
            public boolean match(NPC npc){
                return npc != previous_npc && npc.hasAction("Talk-to");
            }
        });
        if(npc != null){
            npc.interact("Talk-to");
        }
        return true;
    }
}

I get an error on this line:

npc = npcs.closest(new Filter<NPC>() { 

With "npcs" saying: Cannot resolve symbol: 'npcs'.

 

I'm not sure why it isn't working, it has worked for me all other times.

Any help would be appreciated.

 

Thanks.

Edited by tivo444

  • Author

script.getNpcs().closest(..)

 

Wow. Thanks! I can't believe I missed that.

Also you're better off having your execute() as a void as having as a boolean doesnt make too much sense. (at least i think that way and its better)

also in your validate()

 

instead of doing if statements you could do this:

public boolean validate() throws InterruptedException {
return !script.getDialogues().inDialogue();
}

or even

public boolean validate() throws InterruptedException {
return condition1 && condition2 || condition3;
}

 

Also you're better off having your execute() as a void as having as a boolean doesnt make too much sense. (at least i think that way and its better)

also in your validate()

 

instead of doing if statements you could do this:

public boolean validate() throws InterruptedException {
return !script.getDialogues().inDialogue();
}

or even

public boolean validate() throws InterruptedException {
return condition1 && condition2 || condition3;
}

S2??? GIVE THIS MAN S3 OR RIOT! :boge:

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.