Jump to content

Apaec

Scripter III
  • Posts

    11136
  • Joined

  • Last visited

  • Days Won

    88
  • Feedback

    100%

Everything posted by Apaec

  1. I wrote this object loader class to make a personal aio woodcutting script. I thought i'd share it with you guys Hope something can be learnt from this ObjectLoader class: import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; import javax.swing.DefaultListModel; import javax.swing.JScrollPane; import javax.swing.JButton; import javax.swing.JList; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.util.ArrayList; import javax.swing.JLabel; import javax.swing.SwingConstants; import javax.swing.JSpinner; import javax.swing.SpinnerNumberModel; import javax.swing.JTextField; import javax.swing.event.ChangeListener; import javax.swing.event.ChangeEvent; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; public class ObjectLoader extends JFrame { /** * @author Apaec */ private static final long serialVersionUID = 1L; private JPanel contentPane; private String interactionString; private int radius = 10; private final DefaultListModel<String> modelDesired = new DefaultListModel<String>(); private final DefaultListModel<String> modelLoaded = new DefaultListModel<String>(); private ArrayList<RS2Object> objectListDesired = new ArrayList<RS2Object>(); private ArrayList<RS2Object> objectListLoaded = new ArrayList<RS2Object>(); private ArrayList<Position> controlPos = new ArrayList<Position>(); private boolean isVisible = false; public ObjectLoader(final Script script, String defaultSearchString, int defaultRadius) { this.interactionString = defaultSearchString; this.radius = defaultRadius; } public void openLoader(final Script script) { setTitle("Object Loader"); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); setBounds(100, 100, 450, 305); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); setAlwaysOnTop(true); setResizable(false); JLabel lblLoadObjectsWithin = new JLabel("Load objects within radius:"); JLabel lblLoadObjectsWith = new JLabel("Load objects with action:\r\n"); final JSpinner spinner = new JSpinner(); final JTextField txtChopDown = new JTextField(interactionString); JScrollPane scrollPane = new JScrollPane(); final JList<String> desiredtemsList = new JList<String>(modelDesired); JLabel lblDesiredObjects = new JLabel("Desired Objects"); JScrollPane scrollPane_1 = new JScrollPane(); final JList<String> loadedItemsList = new JList<String>(modelLoaded); JLabel lblNewLabel = new JLabel("Loaded Local Objects"); JButton btnNewButton = new JButton("<<"); JButton button = new JButton(">>"); JButton btnRefresh = new JButton("Refresh"); JButton btnSave = new JButton("Save"); lblLoadObjectsWithin.setBounds(10, 11, 193, 14); lblLoadObjectsWith.setBounds(10, 36, 193, 14); txtChopDown.setBounds(213, 33, 215, 20); btnNewButton.setBounds(192, 61, 54, 69); button.setBounds(192, 134, 54, 69); btnRefresh.setBounds(10, 214, 89, 42); btnSave.setBounds(109, 214, 319, 42); spinner.setBounds(213, 8, 215, 20); scrollPane.setBounds(10, 61, 178, 142); scrollPane_1.setBounds(250, 61, 178, 142); txtChopDown.setHorizontalAlignment(SwingConstants.CENTER); txtChopDown.setColumns(10); lblDesiredObjects.setHorizontalAlignment(SwingConstants.CENTER); lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); scrollPane.setViewportView(desiredtemsList); scrollPane.setColumnHeaderView(lblDesiredObjects); scrollPane_1.setViewportView(loadedItemsList); scrollPane_1.setColumnHeaderView(lblNewLabel); spinner.setModel(new SpinnerNumberModel(radius, 1, 30, 1)); contentPane.add(lblLoadObjectsWithin); contentPane.add(spinner); contentPane.add(lblLoadObjectsWith); contentPane.add(txtChopDown); contentPane.add(scrollPane); contentPane.add(scrollPane_1); contentPane.add(btnNewButton); contentPane.add(button); contentPane.add(btnRefresh); contentPane.add(btnSave); setVisible(true); isVisible = true; spinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent arg0) { radius = (int) spinner.getValue(); } }); txtChopDown.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { interactionString = txtChopDown.getText(); } public void insertUpdate(DocumentEvent arg0) { interactionString = txtChopDown.getText(); } public void removeUpdate(DocumentEvent arg0) { interactionString = txtChopDown.getText(); } }); btnNewButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (loadedItemsList.getSelectedIndex() != -1) { modelDesired .addElement(convertObjectToString(objectListLoaded .get(loadedItemsList.getSelectedIndex()))); objectListDesired.add(objectListLoaded.get(loadedItemsList .getSelectedIndex())); objectListLoaded.remove(loadedItemsList.getSelectedIndex()); modelLoaded.removeElementAt(loadedItemsList .getSelectedIndex()); } } }); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (desiredtemsList.getSelectedIndex() != -1) { modelLoaded .addElement(convertObjectToString(objectListDesired .get(desiredtemsList.getSelectedIndex()))); objectListLoaded.add(objectListDesired.get(desiredtemsList .getSelectedIndex())); objectListDesired.remove(desiredtemsList.getSelectedIndex()); modelDesired.removeElementAt(desiredtemsList .getSelectedIndex()); } } }); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { clearListsAndModels(); ArrayList<RS2Object> objectsAll = null; objectsAll = loadNearbyObjectsForActionAsList(script, getRadius(), getInteractionString(), true); if (objectsAll != null) { for (RS2Object o : objectsAll) modelLoaded.addElement(convertObjectToString(o)); objectListLoaded = objectsAll; } } }); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { setVisible(false); isVisible = false; } }); } public String convertObjectToString(RS2Object o) { return o.getName() + " (" + o.getPosition().getX() + "," + o.getPosition().getY() + "," + o.getPosition().getZ() + ")"; } public String getInteractionString() { return interactionString; } public int getRadius() { return radius; } public void clearListsAndModels() { modelLoaded.clear(); modelDesired.clear(); objectListDesired.clear(); objectListLoaded.clear(); controlPos.clear(); } public boolean isOpen() { return isVisible; } public RS2Object[] getAllObjects() { if (objectListLoaded.size() > 0) { RS2Object[] objects = new RS2Object[objectListLoaded.size()]; for (RS2Object o : objectListLoaded) objects[objectListLoaded.indexOf(o)] = o; return objects; } else { return null; } } public RS2Object[] getDesiredObjects() { if (objectListDesired.size() > 0) { RS2Object[] objects = new RS2Object[objectListDesired.size()]; for (RS2Object o : objectListDesired) objects[objectListDesired.indexOf(o)] = o; return objects; } else { return null; } } private ArrayList<RS2Object> loadNearbyObjectsForActionAsList( Script script, int radius, String action, boolean clearLists) { if (clearLists) clearListsAndModels(); ArrayList<RS2Object> objects = new ArrayList<RS2Object>(); for (RS2Object r : script.objects.getAll()) { if (r != null && r.exists() && !r.getName().equals("null") && script.map.distance(r) <= radius && !controlPos.contains(r.getPosition())) { if (action.equals("")) { controlPos.add(r.getPosition()); objects.add(r); } else if (r.hasAction(action)) { controlPos.add(r.getPosition()); objects.add(r); } } } return objects.size() > 0 ? objects : null; } } >>apologies for the poor jframe code, used a gui builder. Did my best to tidy it up somewhat but I understand it's still a little messy. How to use it in an example script: import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(name = "Object loader demo", author = "Apaec", version = 1.0, info = "Demo displayin object loader", logo = "") public class ObjectLoaderDemo extends Script { ObjectLoader loader; RS2Object[] desiredObjects = null; public void onStart() { loader = new ObjectLoader(this, "", 10); if (!loader.isOpen()) loader.openLoader(this); } public int onLoop() throws InterruptedException { while (loader.isOpen()) { sleep(400); desiredObjects = loader.getDesiredObjects(); } // visual debug: if (desiredObjects.length > 0) for (RS2Object o : desiredObjects) if (o != null && o.exists()) log(o.getName()); return 10; } public void onExit() { if (loader.isOpen()) loader.dispose(); } } Where desiredObjects is your array containing the objects configured by the user. Screenshots: Gif: If you're commenting on my code, please be constructive, and I understand it's a bit below-par in places. I know how it is tho when posting snippets x) how it helps apa
  2. Hey! I've given you a 24h trial. In future, please read the rules on the front of this page. I'll let you off this once x))) enjoy apa
  3. i hope my time will come lol congrats tho x)
  4. Rename all your class files (or atleast the one being pointed to by this)... see if that changes anything. apa
  5. From writing my aio smither, I found a few stats: Mithril dart tips - require quest but they are 45k exp/h and you break even. Iron knives are ~22k per hour and you make 100k/h gp profit Gold bars make a loss but with gauntlets you can get about 60k exp/h~ Cannonballs are great profit (150k/h) but only 10k smithing exp/h If you want to bot it, feel free to request a trial by clicking my signature, i'd be willing to let you try the script apa
  6. you could get ~6m for that i'd say. Or maybe 5. Depends on whether it has membs left or not
  7. I'm sure some people have been banned, yes. But if you play it safe and use long breaks and mirror client (if you can!), you should be fine. Also, yes, the script will stop when you're out of natures or items. apa
  8. still have no idea why people play this game... it's a piece of shit x) dota>league
  9. Hey, Bot smart. Use breaks + play a little legit inbetween. Also, mirror client helps alot so if you're not on a tight budget i'd recommend using that! apa
  10. gave you a 6h trial. Enjoy! apa
  11. I used to use gyazo but recently moved to lightshot and didn't regret it
  12. Apaec

    I need halp

    perhaps u run out of memory?
  13. https://www.eclipse.org/downloads/packages/eclipse-standard-432/keplersr2 downloads are on the right, download the one depending on your comp specs
  14. why is there no option for fat people so that i can successfully connect america?
  15. Yep! unfortunately worldhopping is somewhat buggy on the mirror client. I believe the devs know so hopefully it will be fixed soon but i think all scripts are experiencing this. Just gotta sit tight i'm afraid For now either run in injection or disable worldhopping. Apa
  16. sometimes payments take time to process. if it's not ready within 2-3 hours and you didnt use an echeque to pay, then contact @Maldesto and he will sort it out for ya apa
  17. really?! x) you don't seem to have used the script yet according to my sig system x) apa
  18. a killer could never be my hero, no matter who he worked for
  19. or atleast move the position of the debug strings down a bit @alek Really like the new design, and the compactness. Just a thought - perhaps make the text fields Jspinners instead. Spinners are more conventional when inputting numbers i think Other than that, it's awesome!! apa
  20. http://www.itemdb.biz/ you're welcome
×
×
  • Create New...