Jump to content

First Script: Gathering an item off the ground.


Recommended Posts

Posted

Hey guys I'm working on my first script and have no experience with programming, but am willing to learn!

I want to create a script that picks up items in the area and banks them at the nearest bank. An example being a script that picks up fish dropped at a fishing spot and banks them. Would using a machine state type function work? Such as WAIT, GATHER, BANK? Or is there another method that would work better. I'm working on how the script would identify and pick up the fish but I'm not sure I understand that process correctly. Also in the script how would I specify the item to be picked up? Does that work off of item ID or name? Are there any tricks to better searching through the API? Below is what I have right now, which I'm certain is wrong. Any help would be awesome!

Thanks!


 

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 
import java.awt.*;
 
@ScriptManifest(author = "AntiCitizen", info = "Grabs fish, banks it in Edgeville.", name = "Fish Snatcher", version = 0, logo = "")
public class main extends Script {
 
    @Override
    public void onStart() {
        log("Start by the fishing spot in Barbarian Village!");
    }
    
   private enum State {
       BANK, GATHER, WAIT
   };
   
   private State getState{} {
       getAll = objects.closest{"Raw salmon, Raw trout");
   }
                           
 
   
  
 

   






 

  • Like 1
Posted (edited)

you need a onLoop and you would need to create a switch-case for your getState()

@Override
    public int onLoop() throws InterruptedException {
        
        switch(getState()){
            case STEAL:
              
                break;
            case DROP:
            
                break;
            case WALK_STALL:
                
                break;
            case POCKET:
                
                break;

        }
        return random(250, 600);

   }

this:

    State getState() {
        if(condition 1) return State.POCKET;


    }

And look through the Inventory and GroundItems API they are helpful tongue.png

 

Example:

        GroundItem g = getGroundItems().closest("");

/**
    remember to null check

**/
Edited by TheObserver

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...