-
Posts
308 -
Joined
-
Last visited
-
Feedback
100%
Everything posted by TheWind
-
Anybody available to help with Gui? (window Builder)
TheWind replied to sonda's topic in Scripting Help
I decided to go ahead and post the entire script. I made a few changes which I believe were what your goal was. Dealing with threads and concurrency can be a tricky topic. I know I still struggle with it sometimes. There are still many things in this script that can be improved, but I believe you are off to a great start! I'm hoping that after looking at how I used a boolean to assign whether or not the checkbox was checked after pressing start you will be able to proceed with doing so for the rest of the ore checkboxes. There are many ways that this could have been done, but I believe that this was the simplest and definitely the best way to learn! Edit: if you have any more questions feel free to ask package OreLooter; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.GroundItem; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JCheckBox; @ScriptManifest(author = "Brian", info = "Orelooter", name = "Orelooter", version = 0, logo = "") public class OreLooter extends Script implements ItemListener { // Should not be static Object lock = new Object(); public gui gui = new gui(); private long copperoreCollected; private long prevInvCount; private long timeBegan; private long timeRan; private long hph; public boolean clayCheckBox = false; @Override public void onStart() throws InterruptedException { gui.run(this); synchronized(lock) { // must make the lock object wait which in essence pauses this class from executing until it is notified lock.wait(); } prevInvCount = getInventory().getAmount(436); timeBegan = System.currentTimeMillis(); log("Is clay checkbox selected: " + clayCheckBox); } private enum State { COLLECT, FULL, WALK, WAIT } private State getState() { Area MINE = new Area(3232, 3143, 3221, 3149); if (inventory.isFull()) return State.FULL; if (!inventory.isFull() && MINE.contains(myPlayer())) return State.COLLECT; if (!MINE.contains(myPlayer()) && !inventory.isFull()) return State.WALK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { // none of these are needed as they are already in your gui class. JCheckBox Clay = new JCheckBox("Clay"); JCheckBox Tin = new JCheckBox("Tin"); JCheckBox Copper = new JCheckBox("Copper"); JCheckBox Iron = new JCheckBox("Iron"); JCheckBox Coal =new JCheckBox("Coal"); if (Coal.isSelected())log("coal is selected"); long invCount = getInventory().getAmount(436); if (invCount > prevInvCount) setCOPPER_ORECollected(getCOPPER_ORECollected() + (invCount - prevInvCount)); prevInvCount = invCount; GroundItem Clayo = groundItems.closest("Clay"); GroundItem Tino = groundItems.closest("Tin ore"); GroundItem Coppero = groundItems.closest("Copper ore"); GroundItem Irono = groundItems.closest("Iron ore"); GroundItem Coalo = groundItems.closest("Coal"); switch (getState()) { case COLLECT: if (clayCheckBox) { if (Clayo != null && getMap().canReach(Clayo)) Clayo.interact("take"); } if (Tino != null && getMap().canReach(Tino) && Tin.isSelected()) { log("Tin selected"); Tino.interact("take"); } if (Copper.isSelected()) { log("Searching for Copper"); if (Coppero != null && getMap().canReach(Coppero)) log("Copper selected"); Coppero.interact("take"); } if (Irono != null && getMap().canReach(Irono) && Iron.isSelected()) { log("Iron selected"); Irono.interact("take"); } if (Coalo != null && getMap().canReach(Coalo) && Coal.isSelected()) { log("Coal selected"); Coalo.interact("take"); } sleep(2000); break; case FULL: walking.webWalk(new Position(3209, 3220, 2)); if (bank.isOpen()) { bank.depositAll(); } else { objects.closest("Bank booth").interact("Bank"); } break; case WALK: Area MINE = new Area(3232, 3143, 3221, 3149); walking.webWalk(MINE); case WAIT: } return (random(400, 1500)); } @Override public void onExit() { log("THANKS APAEC FOR ALL THE HELP"); } @Override public void onPaint(Graphics2D g) { hph = (int) (copperoreCollected / ((System.currentTimeMillis() - timeBegan) / 3600000.0D)); timeRan = System.currentTimeMillis() - this.timeBegan; Graphics2D gr = (Graphics2D) g; gr.setColor(Color.WHITE); gr.setFont(new Font("Arial", Font.BOLD, 12)); g.drawString(formatTime(timeRan), 440, 25); gr.drawString("Time:", 400, 25); gr.drawString("" + copperoreCollected, 440, 40); gr.drawString("Ores:", 400, 40); gr.drawString("Ores/h:", 400, 65); g.drawString("" + hph, 450, 65); gr.setColor(Color.YELLOW); g.drawString("Gold/h", 400, 78); g.drawString("" + hph * 37, 450, 78); g.drawString("Gold:", 400, 52); g.drawString("" + copperoreCollected * 37, 440, 52); g.setColor(Color.WHITE); g.drawRect(390, 10, 100, 75); } public String formatTime(long ms) { long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } public long getCOPPER_ORECollected() { return copperoreCollected; } public void setCOPPER_ORECollected(long COPPER_ORECollected) { copperoreCollected = COPPER_ORECollected; } @Override public void itemStateChanged(ItemEvent arg0) { // TODO Auto-generated method stub } } package OreLooter; import java.awt.Color; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.TitledBorder; import javax.swing.JCheckBox; public class gui { /** * @wbp.parser.entryPoint */ public void run(OreLooter main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); settingsPanel.setBackground(Color.DARK_GRAY); settingsPanel.setForeground(Color.DARK_GRAY); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.getContentPane().add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setBackground(Color.DARK_GRAY); startPanel.setForeground(Color.DARK_GRAY); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.getContentPane().add(startPanel); JLabel treeSelection = new JLabel("Select an Ore:"); treeSelection.setFont(new Font("Tahoma", Font.BOLD, 14)); treeSelection.setForeground(Color.GRAY); treeSelection.setBounds(10, 79, 118, 20); settingsPanel.add(treeSelection); JCheckBox Clay = new JCheckBox("Clay"); Clay.setForeground(Color.LIGHT_GRAY); Clay.setBackground(Color.DARK_GRAY); Clay.setFont(new Font("Georgia", Font.PLAIN, 13)); Clay.setBounds(154, 27, 97, 23); settingsPanel.add(Clay); JCheckBox Tin = new JCheckBox("Tin ore"); Tin.setForeground(Color.LIGHT_GRAY); Tin.setBackground(Color.DARK_GRAY); Tin.setFont(new Font("Georgia", Font.PLAIN, 13)); Tin.setBounds(154, 53, 97, 23); settingsPanel.add(Tin); JCheckBox Copper = new JCheckBox("Copper ore"); Copper.setForeground(Color.LIGHT_GRAY); Copper.setBackground(Color.DARK_GRAY); Copper.setFont(new Font("Georgia", Font.PLAIN, 13)); Copper.setBounds(154, 79, 97, 23); settingsPanel.add(Copper); JCheckBox Iron = new JCheckBox("Iron"); Iron.setForeground(Color.LIGHT_GRAY); Iron.setBackground(Color.DARK_GRAY); Iron.setFont(new Font("Georgia", Font.PLAIN, 13)); Iron.setBounds(154, 105, 97, 23); settingsPanel.add(Iron); JCheckBox Coal = new JCheckBox("Coal"); Coal.setFont(new Font("Georgia", Font.PLAIN, 13)); Coal.setForeground(Color.LIGHT_GRAY); Coal.setBackground(Color.DARK_GRAY); Coal.setBounds(154, 131, 97, 23); settingsPanel.add(Coal); JButton startButton = new JButton("Start"); startButton.addActionListener(e -> { jFrame.setVisible(false); // everything that is a setting should be called before you unlock the main class main.clayCheckBox = Clay.isSelected(); // this is where the boolean for the clayCheckBox is set to true if the clay checkbox is checked synchronized (main.lock) { // this unlocks the main class and lets it run again main.lock.notify(); } }); startButton.setBounds(5, 390, 279, 20); startPanel.add(startButton); JLabel lblNewLabel = new JLabel("Ore Lo0ter"); lblNewLabel.setFont(new Font("Georgia", Font.BOLD | Font.ITALIC, 30)); lblNewLabel.setForeground(Color.LIGHT_GRAY); lblNewLabel.setBounds(10, 11, 197, 110); startPanel.add(lblNewLabel); JLabel lblWalksToLumby = new JLabel("lumby east mine, picks up ore, and banks!"); lblWalksToLumby.setFont(new Font("Tahoma", Font.BOLD, 12)); lblWalksToLumby.setForeground(Color.GRAY); lblWalksToLumby.setBounds(5, 92, 279, 101); startPanel.add(lblWalksToLumby); jFrame.setVisible(true); } } -
Congrats! I would say its still only a matter of time before you get banned.
-
I feel gray names should be allowed to sell accounts. If they are flooding the account selling section with too many threads then maybe there should be another requirement put on top of the 100 post count.
-
Not released yet, but hopefully soon! Thanks! I'll try not to interfere with the sale of your smithing script Thanks my dude! If that's the case I can always tailor it to be something more suitable for the SDN. I would probably put everything else that wouldn't be a part of it in a separate script under the Unofficial scripts section! Edit: Might not make it an AIO, could always just limit it to certain locations and not include some of the members smithing stuff that's something you might pay for.
-
TheWind's AIO Smithing & Smelting Smelting: Supports ALL bars! - Bronze bar, Iron bar, Silver bar, Steel bar, Gold bar, Mithril bar, Adamantite bar, Runite bar - Locations: Falador, Al Kharid, Edgeville Smithing: Supports Most Smithable Items! - Dagger, Axe, Mace, Medium Helm, Bolts, Dart tips, Nails, Arrowtips, Scimitar, Spear, Hasta, Crossbow limbs, Javelin heads, Longsword, Full helm, Throwing knives, Square shield, Warhammer, Battleaxe, Chainbody, Kiteshield, Claws, Two-handed sword, Platelegs, Plateskirt, Platebody - Locations: West Varrock (Will be adding more) General: - Webwalks to the closest bank next to the chosen furnace/anvil location for you lazy folk - Put the ores/bars, and a hammer if your smithing, in your bank before starting - Open to suggestions for improvements/additions Release Info
-
Let us say a prayer for shitty bot makers.......
TheWind replied to dexterr's topic in Spam/Off Topic
yah, probably just auto clicking. Even a bad scripter would check to make sure they are in the nmz instance. -
Anybody available to help with Gui? (window Builder)
TheWind replied to sonda's topic in Scripting Help
I believe NetBeans has a windows builder built into it. I believe there is also a windows builder plugin for eclipse which is really good. If you're looking to make it from scratch (which is usually unnecessary) unless you're just learning the basic the java docs have really good examples of every component. http://docs.oracle.com/javase/tutorial/uiswing/components/button.html In terms of the basic setup, you would have a JFrame which is the main window. A JPanel which is basically like a context that is on the JFrame so you're not putting the components directly onto it. Then you would just add whatever components you need to the JPanel. Forgive me if I may have misinterpreted the question of your thread. -
I think the easiest way to do it would be what @d0zza mentioned and see if they have different ids. If you want to get the examine text you will need to use the onMessage() method which gets called everytime new text is displayed in the chat. I'm not sure if there is any other way to get that text without examining the item and checking what text is output in the chat box.
-
Every 6 hours you get force logged out.
-
Yes, they can see that you're online the entire time you are connected to their servers.
-
First of all, the reason that it is crashing is that the variable "booth" which represents a Bank booth is null if there is no bank booth loaded in the game near you, so when you call bank.open() it will throw a nullpointerexception. Second, you never used your states that you set up in the enum, so on every loop, it buries all bones you have in your inventory and opens the bank to withdraw more. I suggest you follow one of the guides to learn the flow that should be followed. Generally, only one action should be performed per loop of the onloop method. Meaning that each iteration only one interaction should occur in the game that takes place over the course of a tick. In your script, you are doing many. Hope that helps
-
I've sometimes felt the same way and wound up spending a month or two doing very little and even screwed up some of my schooling. I found that spending more time hanging out with friends and trying to participate in sports got me to change my "bad" habits and routines. Being lazy or unmotivated is a state of mind and the only way to change that is to find enjoyment in those activities you have started to slack in or to move on and find something new that interests you. Just go to the gym, not to make up for the missed day, but because you want to! Go out and meet some new people. Staying inside and keeping to yourself is one of the worst things you can do. It is one of the few things that commonly leads to depression.
-
Sell account as is to somebody looking to bot fletching lol
-
yah, sure. just come into chatbox and pm me. I'm in there a lot.
-
title. in chatbox right now. will be there for trade.
-
yes its correct
-
Looks nice! Gratz on release
-
Has the new update been pushed to the sdn yet? if so I'd love a trial
-
Thank you for answering with such detail. As for your answer to the second question, it really raises more questions as opposed to satisfying my curiosity, but I'll leave it with just those two questions for now.
-
I guess that means me :(, but I really do want to learn. I have a few questions: 1) Why did you extend the class API instead of MethodProvider and not use the initializeModule() method? 2) Why even call the method exchangeContext(getBot()) when the class you made would work without it? I guess I'm not really understanding what it does unless it's doing something behind the scenes which may be harder to understand unless you know how the bot itself works...
-
Looks really good so far. The only class that seems a little strange to me is your EasyEntManipulator. I guess its pretty useful for debugging, but a lot of the methods look like they make the same checks multiple times. Other than that I wish you luck in finishing the project!