Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Question] Launch Options?

Featured Replies

Hey, so this is my first post here so... :D

But for my question, I know on some scripts like AIO Miner (by krapstaunosi) when you start the script is has "options" for the user to set. It has like mining site locations and ore type. I was wondering what I had to do to get that same effect. Is it just a Swing UI? If so, how can I make my Swing UI interact with my script? Thanks! :)

15 minutes ago, d0wngrade said:

Hey, so this is my first post here so... :D

But for my question, I know on some scripts like AIO Miner (by krapstaunosi) when you start the script is has "options" for the user to set. It has like mining site locations and ore type. I was wondering what I had to do to get that same effect. Is it just a Swing UI? If so, how can I make my Swing UI interact with my script? Thanks! :)

It is a Swing (or AWT) UI. Compiling JavaFX on our SDN is undefined behavior, therefore I wouldn't recommend it since you will run into issues. Simply pass your "Bot" instance to your GUI, then you can call bot.getMethods().whateverhere.

 

  • Author
13 minutes ago, Alek said:

It is a Swing (or AWT) UI. Compiling JavaFX on our SDN is undefined behavior, therefore I wouldn't recommend it since you will run into issues. Simply pass your "Bot" instance to your GUI, then you can call bot.getMethods().whateverhere.

 

Okay cool, thanks. I felt like I was using the wrong one but I think I'm good.

I can access the getMethods() method but I can't figure out how to communicate back to the main loop. This is pretty much what I'm working with:

public class GUI extends JFrame {
  private JPanel panel;
  // other GUI objects
  
  // I passed the Bot object from the main loop (which I assumed you meant)
  public GUI(Bot b) {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    // more GUI stuff
    // b.getMethods()...
  }
}

I guess I could work from there and stay inside the GUI class but that doesn't feel right... So how could I send, for example, a checkbox's isSelected() value back to the onStart() method? Like:

private boolean VARIABLE1;

@Override
public void onStart() {
  GUI g = new GUI(getBot());
  g.setVisible(true);
  while(g.isVisible()) {}              // I've heard about this style of waiting being bad, but this was the only one I tried that just worked.
  VARIABLE1 = g.checkbox.isSelected(); // This is what I was getting at, I don't know if this would even be the best way to go about it.
}

I think that's the best way I can describe it, but I can't figure out how to implement that specific functionality. 

  • Author

Just found this post which is exactly what I was looking for, so I guess there was no point in this post. Sorry! :cry:

 

Well if you have your GUI in a separate class, you could have some variables which are accessible from the script.

So in the script you could do something like:

GUI gui = new GUI(getBot());
while(gui.isVisible()){ sleeo(250); }
hpToEatAt = Integer.parseInt(gui.SomeJTextBox().getString()); //obviously not correct
gui.dispose(); // make sure to dispose

I had to misspell sleep above, getting a strange ipb forum issue.

 

You could also maybe have a field in GUI such as a boolean which starts as false and goes to true when you click "Submit". Then in your script you could have something like while(!gui.shouldStart()) {sleep(250);}; that is if you don't want to use visibility. 

package com.loudpacks.gui;
import org.osbot.rs07.script.Script;

public class Settings extends JFrame {
	
	private JPanel master;
	private Consumer<Boolean> callback;

	public Settings(Script script) {
		master = new JPanel();
		setTitle("Settings");
		setSize(300, 120);
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setLocationRelativeTo(null);
		
		
		JPanel buttonPanel = new JPanel();
		buttonPanel.setLayout(new GridLayout(1, 1, 10, 10));
		buttonPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		JButton buttonStart = new JButton("Start");
		buttonStart.addActionListener(event -> {
			callback.accept(true);
			dispose();
		});
		
		buttonPanel.setMaximumSize(new Dimension(getWidth(), 100));
		buttonPanel.add(buttonStart);
		master.add(buttonPanel);

		master.setLayout(new BoxLayout(master, BoxLayout.Y_AXIS));
		add(master);
		setVisible(true);
	}


	public void setCallback(Consumer<Boolean> callback) {
		this.callback = callback;
	}

}
package com.loudpacks.script;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.ScriptManifest;

import com.loudpacks.api.LoudScript;
import com.loudpacks.gui.Settings;

@ScriptManifest(author = "LoudPacks", info = "", logo = "", name = "LoudCCTracker", version = 1.0)
public class main extends LoudScript {
	
	private long start = 0;
	
	public static InventoryMonitor monitor;
	
	@[member='Override']
	public void onStart() {
		Settings settings = new Settings(this);
		settings.setCallback(b -> {
			start = System.currentTimeMillis();
			//add tasks, etc it will hand here til your settings callback is set to true;
			
		});
	}

	@[member='Override']
	public void onExit() {

	}
	
	@[member='Override']
	public void onPaint(Graphics2D g){
		super.onPaint(g);
	}
	

}

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.