Jammer Posted November 15, 2016 Share Posted November 15, 2016 I finished my script but when I try to run it, it simply won't run. In eclipse everything looks fine, but I guess there is some problem with the code that I can't understand. package miner; import org.osbot.rs07.api.map.Area;import org.osbot.rs07.api.map.Position;import org.osbot.rs07.api.model.Entity;import org.osbot.rs07.api.ui.Skill;import org.osbot.rs07.script.Script;import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Mex", info = "mi", logo = "mx", name = "Miner", version = 0) public class miner extends Script { Entity iron = objects.closest(7488, 7455); Entity tin = objects.closest(7486, 7485); Entity bankbooth = objects.closest(7409, 7478); final Area BANK_AREA = new Area(3250, 3423, 3257, 3420); final Area MINING_AREA = new Area(3282, 3371, 3290, 3361); Position player = myPlayer().getPosition(); public void onStart() { log("Script started");} private enum State { MINEIRON, BANK, WALKBANK, WALKMINE, MINETIN, WAIT } private State getState() { if (MINING_AREA.contains(player) && skills.getStatic(Skill.MINING) >= 15) return State.MINEIRON; if (MINING_AREA.contains(player) && skills.getStatic(Skill.MINING) < 15) return State.MINETIN; if (getInventory().isFull()&& !BANK_AREA.contains(player)) return State.WALKBANK; if (!getInventory().isFull() && !MINING_AREA.contains(player)) return State.WALKMINE; if (BANK_AREA.contains(player)&& getInventory().isFull()) return State.BANK; return State.WAIT; } @@Override public int onLoop() throws InterruptedException { switch (getState()) { case MINETIN: if (tin != null && !myPlayer().isAnimating() && !myPlayer().isMoving()) { tin.interact("Mine"); sleep(random(300, 600)); } break; case MINEIRON: if (iron != null && !myPlayer().isAnimating() && !myPlayer().isMoving()) { iron.interact("Mine"); sleep(random(300, 600)); } break; case BANK: if (getBank().isOpen()) { bank.depositAllExcept("Bronze pickaxe", "Iron pickaxe", "Black pickaxe", "Mithril pickaxe", "Adamant pickaxe", "Rune pickaxe"); } else { if (bankbooth != null) { if (bankbooth.isVisible()) { bankbooth.interact("Bank"); sleep(random(1500, 2500)); } } } break; case WALKBANK: walking.walk(BANK_AREA); break; case WALKMINE: walking.walk(MINING_AREA); break; } return 0; } public void onExit() {log("Thanks for using this script"); } } Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted November 15, 2016 Share Posted November 15, 2016 (edited) Its because you've defined entities before the script has started Entity iron = objects.closest(7488, 7455); Entity tin = objects.closest(7486, 7485); define these somewhere else, like in your mine tin & iron cases. EDIT, didnt notice the bank booth object. Feel free to ignore this as its your script, but you don't actually need to define a bank booth entity. If a bank is in range, all you have to write is: bank.open(); or getBank().open(); You can use these instead of your "bankbooth.interact();" stuff. And for checking if bank is null can be done like so: if(getBank() != null) { // do stuff } Hope you don't mind me commenting on stuff about your script, feel free to ignore me. Do you want more advice or? Edited November 15, 2016 by PlagueDoctor 2 Quote Link to comment Share on other sites More sharing options...
Jammer Posted November 15, 2016 Author Share Posted November 15, 2016 Thanks for the advice, I will do some changes. Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted November 15, 2016 Share Posted November 15, 2016 (edited) Also as a last piece of advice, look up conditional sleeps. Rather than having a random sleep time say, after you interact with the iron, you could use a conditional sleep so it sleeps until your player is interacting with the rock. In combination with this you would also want to include somewhere in the script that if your player is already interacting, the script shouldn't do anything.. I'll let you sort that out yourself if you decide to. The conditional sleep can be written like so.. iron.interact(); new ConditionalSleep(10000) { // 10000 is the time it sleeps before it tries to interact again if you're still not. @[member='Override'] public boolean condition() throws InterruptedException { return myPlayer().getInteracting(); // The condition you want to check, this line means.. my player is interacting. } }.sleep(); Edited November 15, 2016 by PlagueDoctor Quote Link to comment Share on other sites More sharing options...
Jammer Posted November 15, 2016 Author Share Posted November 15, 2016 It works perfect now, I will look in to the conditional sleep when i get home, thanks again! Quote Link to comment Share on other sites More sharing options...