Jump to content

t0r3

Members
  • Posts

    65
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

1120 profile views

t0r3's Achievements

Iron Poster

Iron Poster (3/10)

6

Reputation

  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?
×
×
  • Create New...