Rick Posted November 28, 2019 Share Posted November 28, 2019 (edited) 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 November 28, 2019 by Rick Quote Link to comment Share on other sites More sharing options...
Camaro Posted November 28, 2019 Share Posted November 28, 2019 May be a spelling mistake, put an 'else' condition and log something in it. else { log("Null object"); } It will help with debugging Quote Link to comment Share on other sites More sharing options...
FuryShark Posted November 28, 2019 Share Posted November 28, 2019 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. 2 Quote Link to comment Share on other sites More sharing options...
TheMcPker Posted November 28, 2019 Share Posted November 28, 2019 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 Quote Link to comment Share on other sites More sharing options...
Gunman Posted November 28, 2019 Share Posted November 28, 2019 @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"); 1 Quote Link to comment Share on other sites More sharing options...
Camaro Posted November 28, 2019 Share Posted November 28, 2019 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? Quote Link to comment Share on other sites More sharing options...
Rick Posted November 28, 2019 Author Share Posted November 28, 2019 (edited) 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 November 28, 2019 by Rick 1 Quote Link to comment Share on other sites More sharing options...