jajaXd Posted July 19, 2019 Share Posted July 19, 2019 I can't get the script to eat food. Any help? public int onLoop() throws InterruptedException { if (myPlayer().getHealthPercent() < 35) { eatFood(); sleep(random(500, 1000)); } return 0; } public void eatFood() throws InterruptedException { if (getInventory().contains("Shrimps")) { getInventory().getItem("Shrimps").interact("Eat"); } else { goBank(); sleep(random(1000, 2000)); goMonsterLoc(); } } Quote Link to comment Share on other sites More sharing options...
Ragboys is back Posted July 19, 2019 Share Posted July 19, 2019 why is ur onloop returning 0? Quote Link to comment Share on other sites More sharing options...
jajaXd Posted July 19, 2019 Author Share Posted July 19, 2019 Changing the return value did not solve the issue Quote Link to comment Share on other sites More sharing options...
dreameo Posted July 20, 2019 Share Posted July 20, 2019 Make sure the names of the item, "shrimp" and the interaction, "eat" is exactly how it's written in the game. If that's fine, then just remove everything and put the "eat" code in the on loop and see if that works. If it does, then it should indicate that something else is the issue. 1 Quote Link to comment Share on other sites More sharing options...
Hybris Posted July 20, 2019 Share Posted July 20, 2019 Yea the name of your food is definitely wrong, other than that it should work Quote Link to comment Share on other sites More sharing options...
jajaXd Posted July 20, 2019 Author Share Posted July 20, 2019 (edited) -------------- Edited July 20, 2019 by jajaXd Quote Link to comment Share on other sites More sharing options...
Reminiscence Posted July 29, 2019 Share Posted July 29, 2019 (edited) On 7/19/2019 at 9:54 AM, jajaXd said: I can't get the script to eat food. Any help? public int onLoop() throws InterruptedException { if (myPlayer().getHealthPercent() < 35) { eatFood(); sleep(random(500, 1000)); } return 0; } public void eatFood() throws InterruptedException { if (getInventory().contains("Shrimps")) { getInventory().getItem("Shrimps").interact("Eat"); } else { goBank(); sleep(random(1000, 2000)); goMonsterLoc(); } } your timer seems a bit silly because eating takes 3 ticks. you're more than welcome to do random (1800, 2400), but random doesn't really matter much anyways here's two ways you can go about it, but it's virtually the exact same code just done differently. untested, but it should work you're also better off checking if your player is in an Area instead of checking if the bank booth is null. or you can use map.distance and a null check as for everyone else, it is infact "Shrimps" in-game. it doesn't take much effort to check it out on the wikia for the correct name, instead of telling op he got it wrong Position VarrockWestBank = new Position(3184, 3436, 0); int health; boolean invHas(String item) { return inventory.contains(item); } boolean eat(String name) { return inventory.interact("Eat", name); } boolean objExists(String obj) { return objects.closest(obj) != null; } String booth = "Bank booth", food = "Shrimps"; public int onLoop() throws InterruptedException { health = myPlayer().getHealthPercent(); if (health <= 35 && invHas(food)) { eat(food); sleep(1800); } else if (health <= 50 && !invHas(food) && !objExists(booth)) { walking.webWalk(VarrockWestBank); } return 200; } Position VarrockWestBank = new Position(3184, 3436, 0); public int onLoop() throws InterruptedException { if (myPlayer().getHealthPercent() <= 35 && inventory.contains("Shrimps")) { inventory.interact("Eat", "Shrimps"); sleep(1800); } else if (myPlayer().getHealthPercent() <= 50 && !inventory.contains("Shrimps") && objects.closest("Bank booth") == null) { walking.webWalk(VarrockWestBank); } return 200; } edit: you can also choose to not declare certain positions like I did, and you can simple do - walking.webWalk(Banks.VARROCK_WEST); Edited July 29, 2019 by qmqz Quote Link to comment Share on other sites More sharing options...