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.

Tutorial: Simple interaction with objects and npcs

Featured Replies

objects.closest("Bank chest").interact("Use");   

This method looks for an object called "Bank chest" and attempts to interact with it using "Use". If you attempt to interaction with the "Bank chest" using "Attack", the method will not work because "Bank chest" does not have the action "Attack". 

npcs.closest("Guard").interact("Attack");

Lets say you are killing guards, as the method shows above. What happens when you kill all the guards and this method is called? You will get an error called a "Null Pointer Exception", meaning that the method was called but it didn't work because the object reference (in this case the Guard) is null (meaning it doesn't exist). Here is how we would solve that problem:

 

        NPC guard = npcs.closest("Guard");
        if(guard != null){
            guard.interact("Attack");
        }

Here we create the NPC reference called "guard" and we define it using the npcs.closest() method. Now if npcs.closest("Guard") can't find any guards, "guard" will be defined as null. This information is used in the next line where we check if "guard" is null, meaning if no guards exist. If there is at least one guard that exists (not null or != null), we will interact with the guard using "Attack".

 

 

 

  • 1 month later...

Hey man, im working on making a simple miner, with this should I use NPC's or objects, nd if I do the objects.get method what should it be put into like

 

if(!myPlayer().isAnimating()){
            if(inventory.isFull()){
                inventory.dropAll(ore_id);
            }
            Entity rocks = objects.closest(rock_id);
            if(rocks != null){
                rocks.interact("Mine");
                sleep(random(25, 30));
            }
        }

 

I dont think that would be correc tho, because when I compile and export it has an error loading the class file it says, I came from rsbot so I know the background of coding, I just need help with this api

Hey man, im working on making a simple miner, with this should I use NPC's or objects, nd if I do the objects.get method what should it be put into like

if(!myPlayer().isAnimating()){
            if(inventory.isFull()){
                inventory.dropAll(ore_id);
            }
            Entity rocks = objects.closest(rock_id);
            if(rocks != null){
                rocks.interact("Mine");
                sleep(random(25, 30));
            }
        }

I dont think that would be correc tho, because when I compile and export it has an error loading the class file it says, I came from rsbot so I know the background of coding, I just need help with this api

 

NPC = Non player character. This means anything alive basically - enemies, guards, monsters, town criers, leprechauns, bankers etc etc

Entity = the rest - rocks, trees, bank booths, cabbages, so on. Also, export as a jar.

  • Author

Hey man, im working on making a simple miner, with this should I use NPC's or objects, nd if I do the objects.get method what should it be put into like

if(!myPlayer().isAnimating()){
            if(inventory.isFull()){
                inventory.dropAll(ore_id);
            }
            Entity rocks = objects.closest(rock_id);
            if(rocks != null){
                rocks.interact("Mine");
                sleep(random(25, 30));
            }
        }

I dont think that would be correc tho, because when I compile and export it has an error loading the class file it says, I came from rsbot so I know the background of coding, I just need help with this api

 

Try using RS2Object instead of Entity. Entity is an interface.

Guest
This topic is now closed to further replies.

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.