Prolax Posted October 7, 2015 Share 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 Quote Link to comment Share on other sites More sharing options...
Woody Posted October 7, 2015 Share 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 Quote Link to comment Share on other sites More sharing options...
Joseph Posted October 7, 2015 Share 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 Quote Link to comment Share on other sites More sharing options...
Explv Posted October 7, 2015 Share 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 Quote Link to comment Share on other sites More sharing options...
Prolax Posted October 7, 2015 Author Share Posted October 7, 2015 Well, that method looks very good. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted October 7, 2015 Share 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 Quote Link to comment Share on other sites More sharing options...
Prolax Posted October 8, 2015 Author Share 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. Quote Link to comment Share on other sites More sharing options...
fixthissite Posted October 8, 2015 Share 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 "!" Quote Link to comment Share on other sites More sharing options...
Prolax Posted October 8, 2015 Author Share 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. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted October 8, 2015 Share 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 Quote Link to comment Share on other sites More sharing options...