Jump to content

Simple feather looter.


FFTL

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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

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

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.

Link to comment
Share on other sites

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

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