October 7, 201510 yr Hi all, Which methods would you advice for the following inventory interactions: - if inventory not contains Peaches && inventory contains bones -> Click on Bones to Peaches tab - if inventory not contains Peaches && inventory not contains bones -> stop script Thanks Prolax
October 7, 201510 yr Item peaches = getInventory().getItem("Peach"); Item bones = .... Same as above If peaches != null Eat Else If bones != null Click bones to peaches Else Stop
October 7, 201510 yr Grab both item null check them. If you have peaches eat them. If not check to see how many bones you have. If current bone > minimum. If you have tab the break it, else stop the script safely
October 7, 201510 yr 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 October 7, 201510 yr by Explv
October 7, 201510 yr if(getInventory().contains("Peach")) { if(getInventory().contains("Bones")) { getInventory().interact("Break", "Bones to peaches"); } else { stop(true); } } Edited October 7, 201510 yr by FrostBug
October 8, 201510 yr Author 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.
October 8, 201510 yr 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 "!"
October 8, 201510 yr Author That statement means "if inventory does NOT contain Peach" - notice the "!" Indeed, if the inventory does not contain peach, it should make bones to peaches.
October 8, 201510 yr 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. You're right, mb
Create an account or sign in to comment