Jump to content

Problem with NPC object?


tivo444

Recommended Posts

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

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;
}
Link to comment
Share on other sites

 

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:

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