Jump to content

Suggest Script Here [Bored and Moody]


Isolate

Recommended Posts

Need a distraction, give me something to code and i'll try do it neat and leave it open source.
Really just need something to take my mind off of things atm.
plz.

 

Done:

Clay Softener (with pre-made jugs of water)

package Distraction;

import org.osbot.rs07.api.filter.Filter;
import org.osbot.rs07.api.ui.Message;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.ui.Tab;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.utility.ConditionalSleep;

import java.util.Arrays;

public class SoftClay extends Script {

    //dese us states.
    private enum State{MIX, IDLE, OPEN_BANK,CLOSE_BANK, WITHDRAW_JUG, WITHDRAW_CLAY, OPEN_INVENTORY, DEPOSIT_ALL}
    
    long sleepUntil = 0;


    @Override
    public int onLoop() throws InterruptedException {
        //Mmk Starting our loop to run some code, but what should we run? lets ask the getState() and see what it returns.
        switch (getState()){
            case MIX:
                //getState has returned MIX to us, so we should now mix!
                mixThings();
                break;
            case IDLE:
                //getState has returned IDLE to us, so we should now wait.
                weJustChillen();
                break;
            case OPEN_BANK:
                //getState has returned OPEN_BANK to us, so we should open the bank for it.
                getBank().open();
                break;
            case CLOSE_BANK:
                //getState has returned CLOSE_BANK to us, so we should close the bank for it.
                getBank().close();
                break;
            case WITHDRAW_CLAY:
                //getState has returned WITHDRAW_CLAY to us, so we should get clay from the bank for it.
                withdraw14Of("Clay");
                break;
            case WITHDRAW_JUG:
                //getState has returned WITHDRAW_JUG to us, so we should get jugs from the bank for it.
                withdraw14Of("Jug of water");
                break;
            case OPEN_INVENTORY:
                //getState has returned OPEN_INVENTORY to us, we best open the inventory.
                tabs.open(Tab.INVENTORY);
                break;
            case DEPOSIT_ALL:
                //getState has returned DEPOSIT_ALL to us, we should deposit all in the bank.
                getBank().depositAll();
                break;

        }
        return random(750, 1000);
    }

    //hmm he wants us to mix to items eh...
    private void mixThings() {
        RS2Widget makeWidget = getWidgets().singleFilter(getWidgets().getAll(), new Filter<RS2Widget>() {
            @Override
            public boolean match(RS2Widget rs2Widget) {
                return rs2Widget != null && rs2Widget.isVisible() && "Make All" != null && rs2Widget.getInteractActions() != null && Arrays.asList(rs2Widget.getInteractActions()).contains("Make All");
            }
        });
        //well is there a widget that has the action Make ALL available?
        if(makeWidget != null && makeWidget.isVisible()){
            //Oh yay there is!, lets click it!
            if(makeWidget.interact("Make All")){
                //we assume we succeed now we shall wait 5 seconds
                sleepUntil = (System.currentTimeMillis() +5000);
            }
        }else if(makeWidget == null || (makeWidget != null && !makeWidget.isVisible())){
            //oh man the Make All Widget isn't there :( lets bring it up I guess
            if(getInventory().isItemSelected() && getInventory().getSelectedItemName().equalsIgnoreCase("Jug of water")){
                //looks like we have the jug of water succefully selected :)
                if(getInventory().getItem("Clay").interact("Use")){
                    //now that we've used the jug on some un-softened clay the widget should appear :o 
                    new ConditionalSleep(3000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return makeWidget != null && makeWidget.isVisible();
                        }
                    }.sleep();
                }
            }else if(!getInventory().isItemSelected()){
                // no item selected huh... lets find us a jug of water and use it
                if(getInventory().getItem("Jug of water").interact("Use")){
                    //aight that should be selected any time now...
                    new ConditionalSleep(3000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return getInventory().isItemSelected();
                        }
                    }.sleep();
                }
            }else if(getInventory().isItemSelected() && !getInventory().getSelectedItemName().equalsIgnoreCase("Jug of water")){
                //what is this!? how did we selected not the jug ;-; whatever, instead of anyone noticing we shall just de-select this item >:)
                getInventory().deselectItem();
            }
        }

    }

    //is it 420 yet? ;-; we chillen bois
    private void weJustChillen() {
        //Since we're chillen, might aswell check if we're still mixing...
        if(needBank()){
            //Oh man we have no stuff left! we better stop waiting and bank!
            sleepUntil = 0;
        }else if(!needBank()){
            //ahh man we cruising tonight...
            try {
                sleep(random(250, 500));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    //think it's self explanatory...
    private void withdraw14Of(String name){
        if(getBank().withdraw(name, 14)){
            new ConditionalSleep(5000) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getInventory().contains(name);
                }
            }.sleep();
        }
    }

    //determine which state we are in for our switch in onLoop()
    private State getState(){
        //Do we need to bank for items?
        if(needBank()){
            //Yes we need to bank for items, so is the bank open?
            if(getBank().isOpen()){
                //Oh cool the bank is open, do we have the stuff we need to continue softening clay?
                if(!outOfStuff()){
                    //Lucky us! We have more materials to mix, can we hold the new items?
                    if(getInventory().isEmptyExcept("Clay","Jug of water") && !getInventory().contains("Soft clay")){
                        //Ohboy, we have free space, or are holding some items we already need
                        //Do we need clay?
                        if(needClay()){
                            //We do need clay, lets tell the loop to withdraw clay
                            return State.WITHDRAW_CLAY;
                        }
                        //Do we ned jugs?
                        if(needJugs()){
                            //We do need jugs, lets tell the loop to withdraw jugs
                            return State.WITHDRAW_JUG;
                        }
                    }else if(!getInventory().isEmptyExcept("Clay","Jug of water") || getInventory().contains("Soft clay")){
                        //Ohman, we don't have enough space for the new items, lets tell the loop we need to deposit all
                        return State.DEPOSIT_ALL;
                    }
                }else if(outOfStuff()){
                    //damn we're out of stuff, we should re-stock maybe sometime
                }
            }else if(!getBank().isOpen()){
                //Oh damn the bank isn't open, we should tell the loop to open it for us
                return State.OPEN_BANK;
            }
        }else if(!needBank()){
            //No we don't need to bank for items, so is the bank open?
            if(getBank().isOpen()){
                //Huh it's still open, lets tell the loop we need to close the bank
               return State.CLOSE_BANK;
            }else if(!getBank().isOpen()){
                //Lets get to it! the bank is closed so we're ready to mix, but are we already mixing?
                if(Tab.INVENTORY.isOpen(getBot()) && !isWaiting()){
                    //It appears we're not waiting on mixing to finish and our inventory is already open for us, lets tell the loop to mix :D
                        return State.MIX;
                }else if(!Tab.INVENTORY.isOpen(getBot())){
                    //Ahh darn inventory isn't open, lets open it.
                    return State.OPEN_INVENTORY;
                }
            }
        }
        //Well we ended up here so we must already be mixing clay, lets tell the loop to just wait it out a bit
        return State.IDLE;
    }

    //think it's self explanatory...

    private boolean isWaiting(){
        return System.currentTimeMillis() >= sleepUntil;
    }

    //think it's self explanatory...
    private boolean needBank(){
        return needJugs() || needClay();
    }

    //think it's self explanatory...
    private boolean outOfStuff(){
        return getBank().isOpen() && (!getBank().contains("Jug of water") || !getBank().contains("Clay"));
    }

    //think it's self explanatory...
    private boolean needJugs(){
        return !getInventory().contains("Jug of water");
    }

    //think it's self explanatory...
    private boolean needClay(){
        return !getInventory().contains("Clay");
    }

    @Override
    public void onMessage(Message message) throws InterruptedException {
        if(message != null && message.getType() == Message.MessageType.GAME && message.getMessage().equalsIgnoreCase("You now have some soft workable clay.")){
            //we received the game message that means we mixed two things together, we shall extend our sleep :D
            sleepUntil += 5000;
        }
    }
}

 

Edited by Isolate
Link to comment
Share on other sites

Pmed for a clay softener, gave it a go
Untested, but feels good just to write lines man
Edit: Added top op, osbot keeps blocking me posting code as comment, accusing me of SQL injection

 

37 minutes ago, HeyImJamie said:

Best way to buy things w/ GE so I can copy pasta :doge:

my way of doing this is hackish af 

11 minutes ago, geoffrey456 said:

aio miner 

> if modifiedColours.length == 2 && is named "Rock"
> "Now select your positions"
> done

24 minutes ago, Charlotte said:

GE Flipperino :boge:

 

me and the ge have a love hate relationship, if love in this case was hate.
any interaction i've had with it is very hacky 

Link to comment
Share on other sites

39 minutes ago, THS said:

Ban checker that can boot from CLI.

Logs in and afk's for 20mins waiting for delayed ban.

 

:)

I've only ever been hit directly on login, no idea how jagex would take a massive list of accounts logging in 1 by 1 from 1 ip

52 minutes ago, ez11 said:

necromancy prayer training script

new phone whats this

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