Jump to content

Simple Path Tool


LoudPacks

Recommended Posts

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • 3 weeks later...
  • 10 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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