Prolax Posted October 7, 2015 Posted October 7, 2015 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
Woody Posted October 7, 2015 Posted October 7, 2015 Item peaches = getInventory().getItem("Peach"); Item bones = .... Same as above If peaches != null Eat Else If bones != null Click bones to peaches Else Stop
Joseph Posted October 7, 2015 Posted October 7, 2015 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
Explv Posted October 7, 2015 Posted October 7, 2015 (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 October 7, 2015 by Explv 1
FrostBug Posted October 7, 2015 Posted October 7, 2015 (edited) if(getInventory().contains("Peach")) { if(getInventory().contains("Bones")) { getInventory().interact("Break", "Bones to peaches"); } else { stop(true); } } Edited October 7, 2015 by FrostBug
Prolax Posted October 8, 2015 Author Posted October 8, 2015 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.
fixthissite Posted October 8, 2015 Posted October 8, 2015 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 "!"
Prolax Posted October 8, 2015 Author Posted October 8, 2015 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.
FrostBug Posted October 8, 2015 Posted October 8, 2015 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