Jump to content

First Script: Gathering an item off the ground.


AntiCitizen

Recommended Posts

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

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