Jump to content

Temp fix to toggling run on\off


Recommended Posts

Posted (edited)


/**

* The <code>openTab(Setting)</code> will automatically check to make sure

* that the desired tab is already present. If not, it will open it.

*

* Thereafter, we can check to see if we interact with the "run" toggle

* button by returning whether we interacted with it via

* <code>selectInterfaceOption(int, int)</code>

*

* @return

* <tt>We interacted with the "run" toggle button</tt>

* @throws InterruptedException

* Interaction was interrupted

*/

public boolean toggleRun() throws InterruptedException {

return openTab(Tab.SETTINGS) && selectInterfaceOption(261, 34);

}

Edited by liverare
Posted

 

private void toogleRun() throws InterruptedException {			if (client.getRunEnergy()>=50 && !this.isRunning())	{		        selectInterfaceOption(548, 34, "Options");		        sleep(random(1200, 1800));		        selectInterfaceOption(261, 34, "Toggle Run");		        sleep(random(1200, 1800));			}		}
mine
Add some failsafes to that.

 

what you mean failsafe, it always get it on the first try lol

Posted


private void setRun() throws InterruptedException {

if (currentTab() != Tab.SETTINGS){

openTab(Tab.SETTINGS);

sleep(random(300,500));

}

if (currentTab() == Tab.SETTINGS){

if (client.getInterface(261)!= null){

client.getInterface(261).getChild(34).interact("Toggle Run");

sleep(random(300,500));

}

if (client.getConfig(173) == 0){

return;

}

}

}

Posted (edited)
private void setRun() throws InterruptedException {
        if (currentTab() != Tab.SETTINGS){
            openTab(Tab.SETTINGS);
            sleep(random(300,500));
        }
        if (currentTab() == Tab.SETTINGS){
            if (client.getInterface(261)!= null){
                client.getInterface(261).getChild(34).interact("Toggle Run");
                        sleep(random(300,500));
                    }
                


            if (client.getConfig(173) == 0){
                return;
            }
        }
    }

 

Up yo' game, bitch ********a. smile.png Let's safe it like a motherfucker:

	/**
	 * @param on
	 *            The state the run will be set to
	 * @return
	 * 		<tt>Run is toggled off/on to our desire</tt>
	 * @throws InterruptedException
	 * 		Interactions were interrupted
	 */
	public boolean setRun(boolean on) throws InterruptedException {

		// Find out the current state of "run"
		int i = client.getConfig(173);

		// Declare a new RS2Interface variable for later
		RS2Interface j = null;

		// Check to see if the state is on and that's our desired outcome, or
		// vice versa
		if ((on && i == 1) || (!on && i == 0))
			return true; // Successful state--even if no interactions were
							// needed. Return true.

		// Check to see if we "can't" open Setting's tab
		else if (!openTab(Tab.SETTINGS)) {

			// We can't, so that's a problem.
			throw new RuntimeException("Unable to open the Setting's tab!");

			// Define the interface variable and check to see if it doesn't
			// exist or it does, but isn't valid.
		} else if ((j = client.getInterface(261)) == null || !j.isValid()) {

			// The interface is either null or invalid, so that's a problem
			throw new RuntimeException(
					"We're in Settings, but the interface isn't valid!?");

			/*
			 * Final selector state, assume:
			 * 	1. Our desired Run state isn't selected
			 * 	2. We're in the Setting's tab
			 * 	3. The "j" RS2Interface variable exists and is valid
			 */
		} else {

			// Assume that there's no client change, so the child "34" is valid and interact.

			/*
                         * EDITED CODE (thanks Xavier):
                         * This function WILL ONLY RETURN FALSE if we did NOT interact
                         * with the 'run' toggle-button. This condition will determine
                         * whether another recursive check is exhibited.
                         * 
			 * Recurse through this entire method again. The next recursion
			 * should end right at the first selector that checks the desired
			 * state to the actual state.
			 * 
			 * Use the same parameter as before
			 */
			return j.getChild(34).interact() && setRun(on);
		}
	}

Without comments, yo':

	/**
	 * @param on
	 *            The state the run will be set to
	 * @return
	 * 		<tt>Run is toggled off/on to our desire</tt>
	 * @throws InterruptedException
	 * 		Interactions were interrupted
	 */
	public boolean setRun(boolean on) throws InterruptedException {
		int i = client.getConfig(173);
		RS2Interface j = null;
		if ((on && i == 1) || (!on && i == 0))
			return true;
		else if (!openTab(Tab.SETTINGS)) {
			throw new RuntimeException("Unable to open the Setting's tab!");
		} else if ((j = client.getInterface(261)) == null || !j.isValid()) {
			throw new RuntimeException(
					"We're in Settings, but the interface isn't valid!?");
		} else {
			return j.getChild(34).interact() && setRun(on);
		}
	}

Xavier caught a flaw in my first code-post, so I've updated them. The problem being: The old bool method wouldn't have returned false at any point, but rather; return true or throw exceptions.

 

Good catch, Xavier. Hat's off to you, good sir.

 

 

Edited by liverare
  • Like 1
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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