Reflexd Posted January 26, 2016 Share Posted January 26, 2016 My script wont load at all, I can't figure out whats wrong with it. 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.model.Player; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.api.ui.Message.MessageType; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Reflexd", info = "Info", name = "PortSarimWillows", version = 0.1, logo = "") public class Main extends Script { private String scriptStatus = "none"; private final Player me = myPlayer(); private final Area treeArea = new Area(3055, 3250, 3065, 3257); private final Area bankArea = new Area(3048, 3234, 3041, 3237); private final Position[] pathToBank = new Position[] { new Position(3059, 3253, 0), new Position(3055, 3250, 0), new Position(3050, 3247, 0), new Position(3044, 3247, 0), new Position(3042, 3240, 0), new Position(3043, 3235, 0), new Position(3048, 3235, 0) }; private final Position[] pathToWillows = new Position[] { new Position(3048, 3236, 0), new Position(3042, 3235, 0), new Position(3042, 3242, 0), new Position(3046, 3248, 0), new Position(3053, 3247, 0), new Position(3057, 3251, 0) }; private long startTime, runTime; private int logsChopped; private int currentExp, expGained, startingExp; private int currentLvl, lvlGained, startingLvl; private enum State { CHOP, WALKTOBANK, BANK, WALKTOWILLOWS, WAIT }; private State getState() { if (!me.isAnimating() && !inventory.isFull() && !me.isMoving() && treeArea.contains(me.getPosition().getX(), me.getPosition().getY())) { scriptStatus = "Cutting willows"; return State.CHOP; } if (inventory.isFull() && !bankArea.contains(me.getPosition().getX(), me.getPosition().getY())) { scriptStatus = "Walking to deposit box"; return State.WALKTOBANK; } if (inventory.isFull() && bankArea.contains(me.getPosition().getX(), me.getPosition().getY())) { scriptStatus = "Banking logs"; return State.BANK; } if (!inventory.isFull() && !treeArea.contains(me.getPosition().getX(), me.getPosition().getY())) { scriptStatus = "Walking back to willows"; return State.WALKTOWILLOWS; } return State.WAIT; } @Override public void onStart() { startTime = System.currentTimeMillis(); startingExp = skills.getExperience(Skill.WOODCUTTING); startingLvl = skills.getDynamic(Skill.WOODCUTTING); } @Override public int onLoop() throws InterruptedException { if (!settings.isRunning() && settings.getRunEnergy() > 27) { settings.setRunning(true); } switch (getState()) { case BANK: if (!bank.isOpen()) { RS2Object depositBoxObj = objects.closest("Bank deposit box"); if(depositBoxObj != null) { depositBoxObj.interact("Deposit"); sleep(random(1232, 1567)); } } else if (depositBox.isOpen()) { sleep(random(252, 432)); depositBox.depositAllExcept("Bronze axe", "Iron axe", "Steel axe", "Black axe", "Mithril axe", "Adamant axe", "Rune axe"); depositBox.close(); } break; case CHOP: Entity willowTree = objects.closest("Willow"); if (!willowTree.isVisible()) { camera.toEntity(willowTree); } if (willowTree != null && willowTree.exists() && willowTree.isVisible()) { willowTree.interact("Chop down"); sleep(random(435, 787)); } break; case WAIT: sleep(random(23, 78)); break; case WALKTOBANK: localWalker.walkPath(pathToBank); break; case WALKTOWILLOWS: localWalker.walkPath(pathToWillows); break; } return random(150, 250); } @Override public void onExit() { } public String formatTime(long ms){ long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } @Override public void onMessage(Message c) { if (c.getType() == MessageType.GAME) { String msg = c.getMessage().toLowerCase(); try { if(msg.contains("you get some willow logs.")) { logsChopped++; } } catch (Exception exception) { exception.printStackTrace(); } } } @Override public void onPaint(Graphics2D g) { currentExp = skills.getExperience(Skill.WOODCUTTING); currentLvl = skills.getDynamic(Skill.WOODCUTTING); expGained = currentExp - startingExp; lvlGained = currentLvl - startingLvl; g.drawString("Status: " + scriptStatus, 10, 100); runTime = System.currentTimeMillis() - startTime; g.drawString(formatTime(runTime), 10, 120); g.drawString("Logs chopped: " + logsChopped, 10, 140); g.drawString("Woodcutting exp gained: " + expGained + " | Woodcutting levels gained: " + lvlGained + " (" + currentLvl + ")", 10, 160); } } Any help is appreciated. Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted January 26, 2016 Share Posted January 26, 2016 What do you mean with script won't load? do you get any errors? Quote Link to comment Share on other sites More sharing options...
Reflexd Posted January 26, 2016 Author Share Posted January 26, 2016 (edited) What do you mean with script won't load? do you get any errors? No errors, nothing in the logger. Nothing in onStart is loaded either. When I click the play button and choose my script, it just closes the script selector and thats it. Fixed it. Instead of referencing me everywhere, I replaced it with myPlayer instead. Edited January 26, 2016 by Reflexd 1 Quote Link to comment Share on other sites More sharing options...
lisabe96 Posted January 27, 2016 Share Posted January 27, 2016 (edited) Your fix ^is not really a fix, you just bypassed the issue. Don't initialize this globally, add it to onStart(); private final Player me = myPlayer(); private Player me; @Override public void onStart() { this.me = myPlayer(); } Edited January 27, 2016 by lisabe96 Quote Link to comment Share on other sites More sharing options...
Supreme_ Posted January 27, 2016 Share Posted January 27, 2016 Just like to say that if your script doesn't load and you don't have any errors in the osbot log, it's probably an error occurring in onStart (it doesn't log exception that originate there). You can run OSBot through command prompt/terminal to get the stack trace though Quote Link to comment Share on other sites More sharing options...