Jump to content

Script won't start?


Salty as fuck

Recommended Posts

Shows up in list, doesn't start and there's nothing in the log. Any ideas? I've gone so far as to entirely remove the GUI and nothing changed.

import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.*;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

@ScriptManifest(author = "Reminiscence", name = "RGemCutter", info = "Cuts basic gems.", version = 1.0, logo = "")
public class GemCutter extends Script {

	int lvlUp = 0;
	int chisel = 1755;
	int sapphire = 1623;
	int emerald = 1621;
	int ruby = 1619;
	int diamond = 1617;

	public boolean usingSapphire, usingEmerald, usingRuby, usingDiamond;

	public int startCRAFTEXP;
	public long startTime;
	long runTime = System.currentTimeMillis() - startTime;
	RS2Widget w = widgets.get(309,2);

	GUI g = new GUI();
	private boolean guiWait = true;

	public void onStart() throws InterruptedException {
		startTime = System.currentTimeMillis();
		players.myPlayer();
		startCRAFTEXP = getSkills().getExperience(Skill.CRAFTING);

		g.setVisible(true);
		while(guiWait)
			try {
				sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}


	}



	@Override
	public int onLoop() throws InterruptedException {	
		if (!inventory.contains(sapphire) || !inventory.contains(emerald) || 
				!inventory.contains(ruby) || !inventory.contains(diamond)) {
			bank();
		}

		if (usingSapphire == true && inventory.contains(sapphire)) {
			cutSapphire();
		}

		if (usingEmerald == true && inventory.contains(emerald)) {
			cutEmerald();
		}

		if (usingRuby == true && inventory.contains(ruby)) {
			cutRuby();
		}

		if (usingDiamond == true && inventory.contains(diamond)) {
			cutDiamond();
		}
		return 0;
	}

	public boolean interactItems(String item1, String item2) throws InterruptedException	{
		if (inventory.getItem(item1).interact())	{
			sleep(700);
			return inventory.getItem(item2).interact(); //
		}
		return false;
	}

	void cutSapphire() throws InterruptedException {
		if (!players.myPlayer().isAnimating() && inventory.contains(sapphire) && inventory.contains(chisel)) {
			interactItems("Chisel", "Uncut sapphire");
			w.interact("Make all");
			sleep (800);
		}
	}

	void cutEmerald() throws InterruptedException {
		if (!players.myPlayer().isAnimating() && inventory.contains(emerald) && inventory.contains(chisel)) {
			interactItems("Chisel", "Uncut emerald");
			w.interact("Make all");
			sleep (800);
		}
	}

	void cutRuby() throws InterruptedException {
		if (!players.myPlayer().isAnimating() && inventory.contains(ruby) && inventory.contains(chisel)) {
			interactItems("Chisel", "Uncut ruby");
			w.interact("Make all");
			sleep (800);
		}
	}

	void cutDiamond() throws InterruptedException { 
		if (!players.myPlayer().isAnimating() && inventory.contains(diamond) && inventory.contains(chisel)) {
			interactItems("Chisel", "Uncut diamond");
			w.interact("Make all");
			sleep (800);
		}
	}

	void bank() throws InterruptedException {
		bank.open();
		sleep(1500);
		bank.depositAllExcept(chisel);
		sleep(1500);

		if (usingSapphire == true) {
			bank.withdraw(sapphire, 27);
			sleep(1500);
			bank.close();
			sleep(1500);
		}

		if (usingEmerald == true) {
			bank.withdraw(emerald, 27);
			sleep(1500);
			bank.close();
			sleep(1500);
		}

		if (usingRuby == true) {
			bank.withdraw(ruby, 27);
			sleep(1500);
			bank.close();
			sleep(1500);
		}

		if (usingDiamond == true) {
			bank.withdraw(diamond, 27);
			sleep(1500);
			bank.close();
			sleep(1500);
		}
	}

	@Override
	public void onPaint(Graphics2D g){

	}

	@Override
	public void onExit() throws InterruptedException {
		stop();
	}

	public class GUI extends JFrame {
		private static final long serialVersionUID = 1L;
		private JPanel contentPane;

		@SuppressWarnings({ "rawtypes", "unchecked" })
		public GUI() {
			setType(Type.UTILITY);
			setResizable(false);
			setAlwaysOnTop(true);
			setTitle("RGemCutter GUI");
			setBackground(Color.DARK_GRAY);
			setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			setBounds(100, 100, 217, 104);
			contentPane = new JPanel();
			contentPane.setBackground(Color.DARK_GRAY);
			contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
			setContentPane(contentPane);
			contentPane.setLayout(null);

			final JComboBox comboBox = new JComboBox();
			comboBox.setForeground(Color.BLACK);
			comboBox.setBackground(Color.DARK_GRAY);
			comboBox.setModel(new DefaultComboBoxModel(new String[] {"Sapphire", "Emerald", "Ruby", "Diamond"}));
			comboBox.setBounds(10, 11, 187, 20);
			contentPane.add(comboBox);

			JButton btnStart = new JButton("Start");
			btnStart.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent arg0) {
					if (comboBox.getSelectedItem().equals("Sapphire")) {
						usingSapphire = true;
					}

					if (comboBox.getSelectedItem().equals("Emerald")) {
						usingEmerald = true;
					}

					if (comboBox.getSelectedItem().equals("Ruby")) {
						usingRuby = true;
					}

					if (comboBox.getSelectedItem().equals("Diamond")) {
						usingDiamond = true;
					}

					guiWait = false;
					dispose();
				}
			});
			btnStart.setBackground(Color.DARK_GRAY);
			btnStart.setForeground(Color.BLACK);
			btnStart.setBounds(10, 42, 187, 23);
			contentPane.add(btnStart);
		}
	}
}
Link to comment
Share on other sites

long runTime = System.currentTimeMillis() - startTime;
RS2Widget w = widgets.get(309,2);

Set these 2 global variables to default ^

long runTime;
RS2Widget w;

Then do the same again, comment out everything in start(); again and see if it prints out now

public void onStart() throws InterruptedException {
		/*startTime = System.currentTimeMillis();
		players.myPlayer();
		startCRAFTEXP = getSkills().getExperience(Skill.CRAFTING);

		g.setVisible(true);
		while(guiWait)
			try {
				sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}*/
log("They see me loggin, they hatin");


	}
Edited by lisabe96
Link to comment
Share on other sites

long runTime = System.currentTimeMillis() - startTime;
RS2Widget w = widgets.get(309,2);

Set these 2 global variables to default ^

long runTime;
RS2Widget w;

Then do the same again, comment out everything in start(); again and see if it prints out now

public void onStart() throws InterruptedException {
		/*startTime = System.currentTimeMillis();
		players.myPlayer();
		startCRAFTEXP = getSkills().getExperience(Skill.CRAFTING);

		g.setVisible(true);
		while(guiWait)
			try {
				sleep(500);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}*/
log("They see me loggin, they hatin");


	}

I had actually just commented out the widget and it started working, lol.

Thanks for the help :3

Link to comment
Share on other sites

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...