Booleans YAY Posted December 28, 2016 Share Posted December 28, 2016 (edited) It's a basic short and simple system. I'm learning the API so please if you have any additional ideas and things to add or guides or anything I can use to better myself and my scripts please PM me or reply here!! Script Features: Camera Movement Picks up full inventory of Bones to bury Hoping to add more! Jar: https://mega.nz/#!1R11TTjJ!WkjkMtG6EU-c-k0StJGnVVLgA4nIUiGP1xP4tTJwBnM Raw: https://paste.ee/p/2ZRLP package main.script; import java.awt.Graphics2D; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Booleans Yay", info = "Bone burying made ez pz", name = "Bone Bury", version = 1, logo = "") public class BoneBury extends Script { @[member='Override'] public void onStart(){} private enum BotState { PICKUP, BURY }; private BotState getState() { return inventory.isFull() ? BotState.BURY : BotState.PICKUP; } @[member='Override'] public int onLoop() throws InterruptedException { switch (getState()) { case PICKUP: if (!myPlayer().isAnimating()) { GroundItem bone = groundItems.closest("Bones"); if (bone != null) { bone.interact("Take"); Thread.sleep(random(1500)); } } break; case BURY: camera.moveYaw(random(360)); while (!inventory.isEmpty()) { Item bones = inventory.getItem("Bones"); if (bones != null) { bones.interact("Bury"); if (myPlayer().isAnimating()) { bones.interact("Bury"); Thread.sleep(random(200)); } } } break; } return random(200, 300); } @[member='Override'] public void onExit(){} @[member='Override'] public void onPaint(Graphics2D g){} } Edited December 28, 2016 by booleans yay 1 Quote Link to comment Share on other sites More sharing options...
Vilius Posted December 28, 2016 Share Posted December 28, 2016 Everything is fine and dandy, but personally the code style of how you put braces is what saddens me the most, also the state framework you have is the cause for some spaghetti code. But instead of using just simple sleeps, try looking into the ConditionalSleep class of OSBot. Just my two cents :xfeels: Quote Link to comment Share on other sites More sharing options...
Booleans YAY Posted December 28, 2016 Author Share Posted December 28, 2016 Thanks, could you tell me the calling to implement it please? Also why is this moved to "Help"? This code is fully functional; just needed input/advice.. Quote Link to comment Share on other sites More sharing options...
Juggles Posted December 28, 2016 Share Posted December 28, 2016 (edited) Will sleep until the inventory is empty or until 5.5 seconds have passed. Look into using this in your scripts as it is a lot better than regular sleeps. Also as Vilius stated, the bracket placement is off and makes it harder to read. new ConditionalSleep(5500) { @ Override public boolean condition() throws InterruptedException { return a.getInventory().isEmpty(); } }.sleep(); Overall, not bad for your first script Edited December 28, 2016 by Juggles 1 Quote Link to comment Share on other sites More sharing options...
Team Cape Posted December 28, 2016 Share Posted December 28, 2016 This isn't bad for a first script. However, a more efficient way of burying would be: while(inventory.contains("Bones")) { inventory.interact("Bury", "Bones"); } Also, look into conditionalsleeps. if (bone != null) { bone.interact("Take"); Thread.sleep(random(1500)); } could be: long boneCount = inventory.getAmount("Bones"); new ConditionalSleep(5000) { @ Override public boolean evaluate() { return inventory.getAmount("Bones") > boneCount; } }.sleep(); This will sleep until you have more bones, or until 5 seconds have passed. Very useful in situations like this. Also, this is java! Please never use that brace formation! Quote Link to comment Share on other sites More sharing options...
Booleans YAY Posted December 28, 2016 Author Share Posted December 28, 2016 Thanks for the usage. I've updated since. And reading other threads for ideas and usages to improve myself further! Hopefully when I'm finished this, it will be available in the SDN or repo for the free scripts. Quote Link to comment Share on other sites More sharing options...