Jump to content

Simple feather looter.


Recommended Posts

Posted

So I just started to learn java and scripting, is there someone out there who can make or share simple looting script with all it needs? I mean the api lines and such. I want to begin with simple feather looter. 

 

So i readed a bit and used someones else script to get one feather looter working but i couldnt. Atm i got this but there are still some errors and i dont know how to fix em, doh...   Wish i could get 1 working looting script so i can change it myself and stuff.

 

 

import java.awt.*;

import org.osbot.rs07.script.ScriptManifest;
 
 
@ScriptManifest(author = "FFTL",
info = "First",
name = "main",
version = 1.0,
logo = "")
 
 
{
private State state;
 
 
 
    enum State {
 
        LOOTING;
 
    }
 
 
 
    public void getState() {
 
        GroundItem feather = closestGroundItemForName("Feather");
 
        if (feather != null) {
 
            if (feather.isVisible()) {
 
                state = State.LOOTING;
 
            }
 
        }
 
    }
 
 
 
    private GroundItem closestGroundItemForName(String string) {
 
return null;
}
 
 
 
public int onLoop() throws InterruptedException {
 
        getState();
 
        switch (state) {
 
            case LOOTING:
 
                return lootFeather();
 
        }
 
        return random(20, 50);
 
    }
 
 
 
    private int random(int i, int j) {
 
return 0;
}
 
 
 
public int lootFeather() throws InterruptedException{
 
 
 
        GroundItem feather = closestGroundItemForName("Feather");
 
                                   
 
        feather.interact("Take");
 
 
 
        return 2500;
 
    }
 
 
 
    public void pickUpFeathers() {
 
   
 
        
 
    }
 
}

 


Its giving me errors on:
 

private State state;          -   Syntax error on tokens, delete these tokens

   

enum State {                           -    Multiple markers at this line

                                                          Illegal modifier for the enum State; only public is 
                                                           permitted

   

case LOOTING:                  -       Type mismatch: cannot convert from State to int

Posted

So I just started to learn java and scripting, is there someone out there who can make or share simple looting script with all it needs? I mean the api lines and such. I want to begin with simple feather looter. 

 

So i readed a bit and used someones else script to get one feather looter working but i couldnt. Atm i got this but there are still some errors and i dont know how to fix em, doh...   Wish i could get 1 working looting script so i can change it myself and stuff.

 

 

Its giving me errors on:

 

private State state;          -   Syntax error on tokens, delete these tokens

   

enum State {                           -    Multiple markers at this line

                                                          Illegal modifier for the enum State; only public is 
                                                           permitted

   

case LOOTING:                  -       Type mismatch: cannot convert from State to int

 

Please format your code properly if you are going to post it in the Scripting help section. Otherwise it is a pain to read..

 

I strongly suggest you learn the basics of Java first. You haven't even declared your "class" as a class. There are a lot of issues in this script not due to your lack of understanding of the API, but due to your lack of Java / programming knowledge.

 

Posted (edited)

Does this help you buddy?

@ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "")
public class FFTLFeathers extends Script {
    private State state;

    public enum State {

        LOOTING, WALKING, FILLTHISINMAN

    }

    @Override
    public int onLoop() throws InterruptedException {
        getState();
        switch (state) {
            case LOOTING:
                lootFeather();
                break;
        }
        return 750;
    }

    private void getState() {
        final GroundItem feather = closestGroundItemForName("Feather");

        if (feather != null) {
            if (feather.isVisible()) {
                state = State.LOOTING;
            }
        }
    }

    public void lootFeather() {
        GroundItem feather = closestGroundItemForName("Feather");
        if (feather != null)
            feather.interact("Take");
    }

    private GroundItem closestGroundItemForName(final String name) {
        final GroundItems groundItems = new GroundItems();
        final List<GroundItem> list = groundItems.filter(new NameFilter<>(name));
        for (GroundItem g : list) {
            if (g.isOnScreen() && g.exists()) { //You could implement a null-check here
                return g;
            }
        }
        return null;
    }
}

Edit: not so familiar with the API yet, let me know if there are better ways lol.

 

Edited by KEVzilla
Posted (edited)

Does this help you buddy?

@ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "")
public class FFTLFeathers extends Script {
    private State state;

    public enum State {

        LOOTING, WALKING, FILLTHISINMAN

    }

    @Override
    public int onLoop() throws InterruptedException {
        getState();
        switch (state) {
            case LOOTING:
                lootFeather();
                break;
        }
        return 750;
    }

    private void getState() {
        final GroundItem feather = closestGroundItemForName("Feather");

        if (feather != null) {
            if (feather.isVisible()) {
                state = State.LOOTING;
            }
        }
    }

    public void lootFeather() {
        GroundItem feather = closestGroundItemForName("Feather");
        if (feather != null)
            feather.interact("Take");
    }

    private GroundItem closestGroundItemForName(final String name) {
        final GroundItems groundItems = new GroundItems();
        final List<GroundItem> list = groundItems.filter(new NameFilter<>(name));
        for (GroundItem g : list) {
            if (g.isOnScreen() && g.exists()) {
                return g;
            }
        }
        return null;
    }
}

Edit: not so familiar with the API yet, let me know if there are better ways lol.

 

Your code can be simplified / improved to:

import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "")
public class FFTLFeathers extends Script {

    @Override
    public int onLoop() throws InterruptedException {
        
        long featherCount = getInventory().getAmount("Feather");
        GroundItem feather = getGroundItems().closest("Feather");
        if(feather != null){
            
            feather.interact("Take");
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getInventory().getAmount("Feather") > featherCount;
                }
            }.sleep();
        }
        return 750;
    }
}

But that is besides the point. He needs to learn Java xD

Edited by Explv
  • Like 1
Posted

Your code can be simplified / improved to:

import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "")
public class FFTLFeathers extends Script {

    @Override
    public int onLoop() throws InterruptedException {
        
        long featherCount = getInventory().getAmount("Feather");
        GroundItem feather = getGroundItems().closest("Feather");
        if(feather != null){
            
            if(!feather.isVisible()) getCamera().toEntity(feather);
            else{
                feather.interact("Take");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().getAmount("Feather") > featherCount;
                    }
                }.sleep();
            }
        }
        return 750;
    }
}

But that is besides the point. He needs to learn Java xD

 

Yeah, as I said in my reply that I'm not familiar with the API.  And I just rewrote his broken script to work.

Posted

Your code can be simplified / improved to:

import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "")
public class FFTLFeathers extends Script {

    @Override
    public int onLoop() throws InterruptedException {
        
        long featherCount = getInventory().getAmount("Feather");
        GroundItem feather = getGroundItems().closest("Feather");
        if(feather != null){
            
            if(!feather.isVisible()) getCamera().toEntity(feather);
            else{
                feather.interact("Take");
                new ConditionalSleep(5000) {
                    @Override
                    public boolean condition() throws InterruptedException {
                        return getInventory().getAmount("Feather") > featherCount;
                    }
                }.sleep();
            }
        }
        return 750;
    }
}
But that is besides the point. He needs to learn Java xD
I believe default values for turning camera and walking are default for interaction event. You didn't need to check it's visibility
Posted

Does this help you buddy?

@ScriptManifest(author = "FFTL", info = "First", name = "main", version = 1.0, logo = "")
public class FFTLFeathers extends Script {
    private State state;

    public enum State {

        LOOTING, WALKING, FILLTHISINMAN

    }

    @Override
    public int onLoop() throws InterruptedException {
        getState();
        switch (state) {
            case LOOTING:
                lootFeather();
                break;
        }
        return 750;
    }

    private void getState() {
        final GroundItem feather = closestGroundItemForName("Feather");

        if (feather != null) {
            if (feather.isVisible()) {
                state = State.LOOTING;
            }
        }
    }

    public void lootFeather() {
        GroundItem feather = closestGroundItemForName("Feather");
        if (feather != null)
            feather.interact("Take");
    }

    private GroundItem closestGroundItemForName(final String name) {
        final GroundItems groundItems = new GroundItems();
        final List<GroundItem> list = groundItems.filter(new NameFilter<>(name));
        for (GroundItem g : list) {
            if (g.isOnScreen() && g.exists()) { //You could implement a null-check here
                return g;
            }
        }
        return null;
    }
}
Edit: not so familiar with the API yet, let me know if there are better ways lol.
You don't create a GroundItems class like that. You grab it's getter methods from within the method provder.

So script.getGroundItems()

  • Like 1

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