Jump to content

Simple Path Tool


Recommended Posts

Posted (edited)

Lets u quickly grab position data for making paths. (Useful for dungeons, zeah, unmapped locations, etc.)

 

4a5e1c79aa2c6e06fd2123467a93b28d.png

 

EDIT: Added auto position grabbing every 7 tiles. (No more clicking the button)

import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.border.EmptyBorder;

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.script.Script;

public class PathTool {

	private Script script;
	private String newline = "\n";
	private String text;
	private Thread t;
	private Position currentPosition;

	public PathTool(Script script) {
		this.script = script;
	}

	public void open() {
		JFrame frame = new JFrame("Path Maker - " + script.getClient().getUsername());
		JButton button = new JButton("Listen");
		JButton button2 = new JButton("Copy Data");
		JTextArea output = new JTextArea(10, 1);
		JScrollPane scrollPane = new JScrollPane(output);
		output.setEditable(false);
		frame.setLocationRelativeTo(null);
		frame.setSize(300, 350);
		frame.setResizable(false);

		button.addActionListener(event -> {
	text = String.format("new Position(%d, %d, %d), ", script.myPlayer().getX(), script.myPlayer().getY(),
					script.myPlayer().getZ()) + newline;
			output.append(text + newline);
			currentPosition = script.myPlayer().getPosition();
			Thread t1 = new Thread(new Runnable() {
				public void run() {
					while (true) {
		   if (script.myPlayer().getPosition().distance(currentPosition) >= 7) {
							text = String.format("new Position(%d, %d, %d), ", script.myPlayer().getX(),
									script.myPlayer().getY(), script.myPlayer().getZ()) + newline;
							output.append(text + newline);
							currentPosition = script.myPlayer().getPosition();
						}
						try {
							Thread.sleep(500);
						} catch (InterruptedException e) {
							e.printStackTrace();
						}
					}
				}
			});
			t1.start();
		});

		button2.addActionListener(event -> {
			String data = output.getText().replace("\n", "");
			Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(data), null);
			JOptionPane.showMessageDialog(frame, "Data copied to clipboard!");

		});

		JPanel textPanel = new JPanel();
		JPanel buttonPanel = new JPanel();
		JPanel masterPanel = new JPanel();

		textPanel.setLayout(new GridLayout(1, 1, 5, 5));
		textPanel.setBorder(BorderFactory.createTitledBorder("Data"));
		textPanel.add(scrollPane);

		buttonPanel.setLayout(new GridLayout(1, 2, 5, 5));
		buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		buttonPanel.add(button);
		buttonPanel.add(button2);

		masterPanel.setLayout(new BoxLayout(masterPanel, BoxLayout.Y_AXIS));
		masterPanel.add(textPanel);
		masterPanel.add(buttonPanel);

		frame.getContentPane().add(masterPanel);
		frame.setVisible(true);

		frame.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
				t.interrupt();
				frame.dispose();
			}
		});

	}

}

Edited by LoudPacks
Posted

You don't have automatic position grabbing???? you have to stop, press the button and carry on to the next spot... how painful!

 

I could have done that but I just needed a quick path through the cave. How would do that? On a timer? Comparing positions? I figured clicking the button is pretty simple.

Osbot Web included zeah thou

 

I didn't know that. I was in ape atol dungeon.

Posted

I could have done that but I just needed a quick path through the cave. How would do that? On a timer? Comparing positions? I figured clicking the button is pretty simple.

I didn't know that. I was in ape atol dungeon.

Just use distance from the last position added. So if the player is 5 tiles away from the last position added, then add another. Something like that.

  • Like 1
  • 3 weeks later...
  • 10 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...