Jump to content

t0r3

Members
  • Posts

    65
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by t0r3

  1. Thanks! It only has the option to "Make", so just using .interact() worked Why didn't it work though, so wierd haha
  2. I checked it It's the right one. Debugged the mouse position, and the mouse hovers over aswell, - so it finds the correct widget. Idk why it won't click it. Any ideas?
  3. I'm back into scripting a bit, and when I'm trying one of my old scripts I can't get it to interact. I've made a ring smelting script, - this is the part where I interact with the "ringButton"-widget. When it click nothing happens! I don't understand why... RS2Widget ringButton = getWidgets().get(446,7); if (!getInventory().contains("Emerald") && getInventory().contains("Ring mould") && inventoryHasGoldBars() && ringButton != null && ringButton.interact("Make")) { sleep(random(710, 1130)); getMouse().moveOutsideScreen(); log("Smelting Gold rings, sleeps till finishedSmelting"); SleepEasy.sleepUntil(() -> !getInventory().contains("Gold bar") || getDialogues().isPendingContinuation(), 30000); }
  4. @Explv I'm new to java and making GUI's. Have som questions 1) Why do you add the JDialog mainDialog/JComboBox<> treeSelector to the main class instead of the constructor method? The main dialog is accessed in the other methods, - but the ComboBox also? no? So, why declare it in the scope of the class and not just in the constructor instead? private final JDialog mainDialog; private final JComboBox<Tree> treeSelector; 2) Also when I declare all of the JPanels, the JLabel and all the other instances to the class scope, and then reference them in the constructor, the Start button won't show up when I run with main() method ( main(String...args) )? Why is this? :I 3) When I just declare and create the instances inside the scope of the constructor, like you did with the mainPanel etc., everything works fine. Why? What is the difference, and why do you do it like this? Can you elaborate?
  5. Hey I am trying to learn how to make a GUI from expLvl's Tutorial I can't get the JButton to show when i run the main method, why is this? I am fairly new to java, and am in process of learning it. So sry, if it is apparent haha. Any help/tips appreciated Thanks! package gui; import data.TreeInfo; import javax.swing.*; import javax.swing.border.EmptyBorder; import java.awt.*; public class GUIDialog extends JDialog { private final JDialog mainDialog; private final JPanel mainPanel; private final JPanel selectTreeTypePanel; private final JLabel treeTypeLabel; private final JButton startButton; private final JComboBox<TreeInfo> treeTypeComboBox; public GUIDialog() { mainDialog = new JDialog(); mainDialog.setTitle("Tasks Woodcutter"); mainDialog.setModal(true); mainDialog.setModalityType(JDialog.ModalityType.APPLICATION_MODAL); mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS)); mainPanel.setBorder(new EmptyBorder(20, 20, 20, 20)); selectTreeTypePanel = new JPanel(); selectTreeTypePanel.setLayout(new FlowLayout(FlowLayout.LEFT)); treeTypeLabel = new JLabel("Select Tree : "); selectTreeTypePanel.add(treeTypeLabel); treeTypeComboBox = new JComboBox<>(TreeInfo.values()); selectTreeTypePanel.add(treeTypeComboBox); mainPanel.add(selectTreeTypePanel); startButton = new JButton("Start"); startButton.addActionListener(e -> { started = true; close(); }); mainPanel.add(startButton); mainDialog.getContentPane().add(mainPanel); mainDialog.getContentPane().add(selectTreeTypePanel); mainDialog.pack(); mainDialog.setLocationRelativeTo(null); } public void open() { mainDialog.setVisible(true); } public void close() { mainDialog.setVisible(false); mainDialog.dispose(); } public static void main(String... args) { new GUIDialog().open(); } }
  6. Hey If I want to display how many fish I've caught per hour, how do I go about that? When displaying how long the script has been running I format the long type to a String. I tried formatting the long type (how long the script has been running for) to an Integer, - returning an integer. This so that I can divide the fishCount int variable with another int variable.. But it doesn't seem to work I do realize I might have to learn some more java for this though hahah.. Any help appreciated
  7. Hey! Titles says it all How do I pause the script during breaks, so that i.e timer/counter from onPaint doesn't run while taking breaks. Maybe just set conditions for onPaint() or something? Thanks for any help
  8. import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import sleep.SleepEasy; @ScriptManifest(author = "t0r3", name = "EdgeSmelter", info = "Sleep", version = 0.1, logo = "") public class EdgeSmelter extends Script { private Area smeltArea = new Area(3105, 3501, 3110, 3496); private void bronzeBars(){ boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); RS2Widget bronzeBarsButton = getWidgets().get(270,14); RS2Object smelter = getObjects().closest("Furnace"); if (!smeltArea.contains(myPosition())){ log("Walking to Smelter"); getWalking().webWalk(smeltArea); SleepEasy.sleepUntil(() -> smeltArea.contains(myPosition()), 18000); } if (smeltArea.contains(myPosition()) && smelter != null) { boolean bronzeButtonExists = getWidgets().get(270,14) != null; boolean isSmeltScreenVisible = getWidgets().get(270,14).isVisible(); smelter.interact("Smelt"); SleepEasy.sleepUntil(() -> isSmeltScreenVisible, 5000); if (bronzeButtonExists && isSmeltScreenVisible) { bronzeBarsButton.interact("Smelt"); SleepEasy.sleepUntil(() -> !gotCopperAndTinOre, 18000); } } } private void needToBank() throws InterruptedException { if (!Banks.EDGEVILLE.contains(myPosition())){ log("Walking to bank"); getWalking().webWalk(Banks.EDGEVILLE); SleepEasy.sleepUntil(() -> Banks.EDGEVILLE.contains(myPosition()),18000); } if (Banks.EDGEVILLE.contains(myPosition()) && !getBank().open()) { getBank().open(); SleepEasy.sleepUntil(() -> getBank().isOpen(), 10000); if (getBank().isOpen()) { log("Depositing bronze bars"); getBank().depositAll("Bronze bar"); SleepEasy.sleepUntil(() -> getInventory().isEmpty(),500); if (getInventory().isEmpty()) { boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); log("Withdrawing ores"); getBank().withdraw("Copper ore", 14); getBank().withdraw("Tin ore", 14); SleepEasy.sleepUntil(() -> gotCopperAndTinOre, 500); } } } } @Override public int onLoop() throws InterruptedException{ boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); if (!getInventory().contains("Copper ore", "Tin ore") && !Banks.EDGEVILLE.contains(myPosition())) { needToBank(); } if (getInventory().contains("Copper ore", "Tin ore")){ bronzeBars(); } return 600; } } Ok, changed the script to this above, and got this NPE ; Error in script executor! java.lang.NullPointerException at EdgeSmelter.bronzeBars(EdgeSmelter.java:33) at EdgeSmelter.onLoop(EdgeSmelter.java:90) at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(df:126) at java.lang.Thread.run(Unknown Source)
  9. Can't even interact with the logger hahah? Goes completely potato Might just have to write the script from scratch again
  10. ok, changed it to this; which is my whole script (minus SleepEasy class) Still not working import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import sleep.SleepEasy; @ScriptManifest(author = "t0r3", name = "EdgeSmelter", info = "", version = 0.1, logo = "") public class EdgeSmelter extends Script { private Area smeltArea = new Area(3105, 3501, 3110, 3496); private void bronzeBars(){ boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); boolean bronzeButtonExists = getWidgets().get(270,14) != null; boolean isSmeltScreenVisible = getWidgets().get(270,14).isVisible(); boolean inSmeltArea = smeltArea.contains(myPosition()); RS2Widget bronzeBarsButton = getWidgets().get(270,14); RS2Object smelter = getObjects().closest("Furnace"); if (!inSmeltArea){ log("Walking to Smelter"); getWalking().webWalk(smeltArea); SleepEasy.sleepUntil(() -> inSmeltArea, 18000); } if (inSmeltArea && smelter != null) { smelter.interact("Smelt"); SleepEasy.sleepUntil(() -> isSmeltScreenVisible, 5000); if (bronzeButtonExists && isSmeltScreenVisible) { bronzeBarsButton.interact("Smelt"); SleepEasy.sleepUntil(() -> !gotCopperAndTinOre, 18000); } } } private void needToBank() throws InterruptedException { boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); if (!Banks.EDGEVILLE.contains(myPosition())){ log("Walking to bank"); getWalking().webWalk(Banks.EDGEVILLE); SleepEasy.sleepUntil(() -> Banks.EDGEVILLE.contains(myPosition()),18000); } if (Banks.EDGEVILLE.contains(myPosition()) && !getBank().open()) { getBank().open(); SleepEasy.sleepUntil(() -> getBank().isOpen(), 10000); if (getBank().isOpen()) { log("Depositing bronze bars"); getBank().depositAll("Bronze bar"); SleepEasy.sleepUntil(() -> getInventory().isEmpty(),500); if (getInventory().isEmpty()) { log("Withdrawing ores"); getBank().withdraw("Copper ore", 14); getBank().withdraw("Tin ore", 14); SleepEasy.sleepUntil(() -> gotCopperAndTinOre, 500); } } } if (!getBank().contains("Copper ore", "Tin ore")){ log("Stopping script"); stop(false); } } @Override public int onLoop() throws InterruptedException{ boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); if (!gotCopperAndTinOre && !Banks.EDGEVILLE.contains(myPosition())) { needToBank(); } if (gotCopperAndTinOre && gotCopperAndTinOre){ bronzeBars(); } return 600; } }
  11. Happening everytime I start this script i made ; public class EdgeSmelter extends Script { private Area smeltArea = new Area(3105, 3501, 3110, 3496); private void bronzeBars(){ boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); boolean isSmeltScreenVisible = getWidgets().get(270,14).isVisible(); boolean inSmeltArea = smeltArea.contains(myPosition()); RS2Widget bronzeBarsButton = getWidgets().get(270,14); RS2Object smelter = getObjects().closest("Furnace"); if (gotCopperAndTinOre && !inSmeltArea){ log("Walking to Smelter"); getWalking().webWalk(smeltArea); } if (inSmeltArea && smelter != null) { smelter.interact("Smelt"); SleepEasy.sleepUntil(() -> isSmeltScreenVisible, 5000); bronzeBarsButton.interact("Smelt"); SleepEasy.sleepUntil(() -> !gotCopperAndTinOre,18000); } } private void needToBank() throws InterruptedException { boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); if (!Banks.EDGEVILLE.contains(myPosition()) && !gotCopperAndTinOre){ log("Walking to bank"); getWalking().webWalk(Banks.EDGEVILLE); } if (Banks.EDGEVILLE.contains(myPosition()) && !gotCopperAndTinOre) { getBank().open(); SleepEasy.sleepUntil(() -> getBank().isOpen(), 10000); log("Depositing bronze bars"); getBank().depositAll("Bronze bar"); log("Withdrawing ores"); getBank().withdraw("Copper ore" + "Tin ore", 14); } if (!getBank().contains("Copper ore", "Tin ore")){ log("Stopping script"); stop(false); } } @Override public int onLoop() throws InterruptedException{ boolean gotCopperAndTinOre = getInventory().contains("Copper ore", "Tin ore"); if (!gotCopperAndTinOre) { needToBank(); } else { bronzeBars(); } return 600; } } What did I do wrong?
  12. Getting Error in script executor! java.lang.NullPointerException when trying to start a script. What could be wrong?
  13. yeah ? Discovered it would always deposit the current axe before withdrawing it again, each time banking. Changed it to; boolean canGetSteelAxe = (wcLvl > 6 && wcLvl < 21) && getBank().contains(axes) && !getInventory().contains("Steel axe"); so that it will only get the steel axe when it is not in inventory Also moved getBank().depositAll(axes); out of boolean axeInBank into if (canGetSteelAxe && axeInBank) aaand now it works lol, always something wrong Changed it in the OP too.
  14. Yeah, but what if the script starts at lvl 24 and has a steel axe equipped? Then it would not withdraw another axe before reaching lvl 31?
  15. Yeah maybe. No, haven't tested it. But when using the other axes, it already has the desired axe in inventory and is not stuck trying to withdraw/deposit other axes. So guess that it still would work. Could set it to == 41 probably idk u making a progressive script too? hehe EDIT: yes, it got stuck lol. changed it to ; boolean canGetMithrilAxe = (wcLvl >= 21 && wcLvl < 31) && getBank().contains(axes); boolean canGetAdamantAxe = (wcLvl >= 31 && wcLvl < 41) && getBank().contains(axes);
  16. I have this in my banking method Might have to change some stuff tho private void needToBank() throws InterruptedException { boolean axeInInventory = getInventory().contains(axes -> axes.getName().endsWith("axe")); if (!Banks.LUMBRIDGE_UPPER.contains(myPosition())) { getWalking().webWalk(Banks.LUMBRIDGE_UPPER); } if (getInventory().isEmpty() || !axeInInventory){ getBank().open(); SleepEasy.sleepUntil(() -> getBank().isOpen(), 18000); if (getBank().contains(axes)) { getAxes(); } } if (getInventory().isFull()) { getBank().open(); SleepEasy.sleepUntil(() -> getBank().isOpen(), 14000); if (getBank().isOpen() && getInventory().contains(logs -> logs.getName().endsWith("logs"))) { getBank().depositAllExcept(axes); } if (getBank().contains(axes)) { getAxes(); } } }
  17. Yeah that would work I think, but I don't want to do that in the middle of cutting wood. Wanna wait till banking Thanks! Any examples, and in relation what?
  18. hahah No one use black axe ? Got any suggestions though? : )
×
×
  • Create New...