Jump to content

Inventory interaction questions


Recommended Posts

Posted (edited)

Something like this maybe?

public class BonesToPeaches{

    private Script script;

    private static final int peachId = XXXX;
    private static final int bonesId = 526;
    private static final int bonesToPeachesTabId = 8015;

    public BonesToPeaches(Script script){
        this.script = script;
    }

    public void convertBonesToPeaches(){
        if ( hasTabRequirements() && hasTab() && !playerIsBusy() ){
            useTab();
        } else if ( !hasScriptRequirements() ) {
            script.stop();
        }
    }

    private boolean playerIsBusy(){
        return script.myPlayer().isAnimating() | script.myPlayer().isMoving();
    }

    private void useTab(){
        script.getInventory().getItem(bonesToPeachesTabId).interact()
    }

    private boolean hasTab(){
        return script.getInventory().contains(bonesToPeachesTabId);
    }

    private boolean hasTabRequirements(){
        return !script.getInventory().contains(peachId) && script.getInventory().contains(bonesId);
    }

    private boolean hasScriptRequirements(){
         return script.getInventory().contains(peachId) && script.getInventory().contains(bonesId) && hasTab();
    }

}
Edited by Explv
  • Like 1
Posted
if(!getInventory().contains("Peach")) {    if(getInventory().contains("Bones")) {        getInventory().interact("Break", "Bones to peaches");    } else {        stop(true);    }}
Thanks for the replies.

first if statement should be not contains Peach, if I'm correct.

That statement means "if inventory does NOT contain Peach" - notice the "!"

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