Jump to content

Interacting with npc / objects


Rick

Recommended Posts

Hi,

i was messing around a bit in eclipse ( first time starting to work with java and osbot API ).
And i found out in debug mode that the Plough is actually an NPC? so i thought that this code would work in order to ''push'' the plough , but when i start my script it doesn't do anything sadly .

This is what i have used for the code:

import org.osbot.rs07.api.model.NPC; // figure this is what i need right?
import org.osbot.rs07.api.model.InteractableObject;

    public int onLoop() throws InterruptedException {
        NPC Plough = npcs.closest("Plough");
        if(Plough != null){
            Plough.interact("Push");

like i said , i'm a complete noob and just trying to figure out what code to use for what action etc.

 

Please let me know what to do  or give me some tips if you have some spare time :) 

Edited by Rick
Link to comment
Share on other sites

1 hour ago, Rick said:

Hi,

i was messing around a bit in eclipse ( first time starting to work with java and osbot API ).
And i found out in debug mode that the Plough is actually an NPC? so i thought that this code would work in order to ''push'' the plough , but when i start my script it doesn't do anything sadly .

This is what i have used for the code:

import org.osbot.rs07.api.model.NPC; // figure this is what i need right?
import org.osbot.rs07.api.model.InteractableObject;

    public int onLoop() throws InterruptedException {
        NPC Plough = npcs.closest("Plough");
        if(Plough != null){
            Plough.interact("Push");

like i said , i'm a complete noob and just trying to figure out what code to use for what action etc.

 

Please let me know what to do  or give me some tips if you have some spare time :) 

<col=00ffff>Plough</col>  i think, instead of just Plough. 

  • Like 2
Link to comment
Share on other sites

Could look for the npc by using a filter on containing the action push instead of messing around with the name or if name contains Plough or both of the above 

1 hour ago, camaro 09 said:

May be a spelling mistake, put an 'else' condition and log something in it.

else {

  log("Null object");

}

It will help with debugging

I mean you can also put in try catch then or just no null check i think goal is more successfully getting the npc instead of knowing if its null which we can already assume due to his code not working 

Link to comment
Share on other sites

51 minutes ago, TheMcPker said:

Could look for the npc by using a filter on containing the action push instead of messing around with the name or if name contains Plough or both of the above 

I mean you can also put in try catch then or just no null check i think goal is more successfully getting the npc instead of knowing if its null which we can already assume due to his code not working 

And how do you know the action he's choosing in the interaction is correct or not?

Link to comment
Share on other sites

1 hour ago, Gunman said:

@Rick When making my Hosid Fav script I ran into this issue too. I believe what @FuryShark Said was correct but I just used.
 


getNpcs().closestThatContains("Plough");

 

Thanks! Also others aswell im on mobile ill continue tomorrow.

inoticed the plough had soen extra code but i didnt think it would matter 😜

also thanks for the snipped regarding closesthatcontains, i dont know shit yet so im saving alot of snippeds in my workspace whichi can use later on and mess around with.

To be continued tomorrow 😉 

Edited by Rick
  • Heart 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...