Jump to content

Inventory interaction questions


Prolax

Recommended Posts

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

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