Jump to content

GE Script Question


Recommended Posts

Posted

Hello everyone!
 

I am currently having issues using values that were determined in a previous case.

 

So what's happening is I have two cases, Case A and Case B.

 

In Case A I've declared the following

long BuyPriceNew = grandExchange.getAmountSpent(Box.BOX_1);

Which Logs the amount spent in the GE box into the Long "BuyPriceNew"

 

However when I go into Case B and try to call upon BuyPriceNew I get the following error.

 

 
The local variable BuyPriceNew may not have been initialized. Note that a problem regarding missing 'default:' on 'switch' has been suppressed, which is perhaps related to this problem main.java /XMerch/src line 136 Java Problem

What am I doing wrong? 
 

 

Posted

You have to initialise your variable before the switch statement with an actual value.

long buyPriceNew = 0;

switch (...) {
case A:
    buyPriceNew = grandExchange.getAmountSpent(Box.BOX_1);
    return;
case B:
    ... // the variable is initialised here so you can use it
}

Use null as a default value for all types except for numerical ones.

  • Like 1
Posted

Thanks man!

 

A second question...I want my script to perform a profit check function first and then move on to repeating the merch function until a certain time. My issue is that I cannot even get it to move from the ProfitCheck Case to the Merch Case

 

Here is my Code

    	NPC clerk = npcs.closest("Grand Exchange Clerk");
    	if (clerk !=null && grandExchange.isOpen() == false)
    		return State.ExchangeBanker;
    		int OpenedIt = 1;
    		int CheckedIt = 0;
    	if (OpenedIt <= 2 && CheckedIt == 0)
    		return State.ProfitCheck;
    		OpenedIt += 1;
    		CheckedIt += 1;
    	if(CheckedIt >= 0)
    		return State.MerchTime;
    	return State.Wait;
    	}

Here you see that I'm simply trying to get the script to recognize that if the previous case was completed it can move onto the next case, but for some reason it keeps hanging on the profit check case.

Posted

Thanks man!

 

A second question...I want my script to perform a profit check function first and then move on to repeating the merch function until a certain time. My issue is that I cannot even get it to move from the ProfitCheck Case to the Merch Case

 

Here is my Code

    	NPC clerk = npcs.closest("Grand Exchange Clerk");
    	if (clerk !=null && grandExchange.isOpen() == false)
    		return State.ExchangeBanker;
    		int OpenedIt = 1;
    		int CheckedIt = 0;
    	if (OpenedIt <= 2 && CheckedIt == 0)
    		return State.ProfitCheck;
    		OpenedIt += 1;
    		CheckedIt += 1;
    	if(CheckedIt >= 0)
    		return State.MerchTime;
    	return State.Wait;
    	}

Here you see that I'm simply trying to get the script to recognize that if the previous case was completed it can move onto the next case, but for some reason it keeps hanging on the profit check case.

 

The code where you increment OpenedIt and CheckedIt is unreachable

 

also camelCase pls

 

also you probably want to learn Java before writing a massive merch script

Posted

Thanks man!

 

A second question...I want my script to perform a profit check function first and then move on to repeating the merch function until a certain time. My issue is that I cannot even get it to move from the ProfitCheck Case to the Merch Case

 

Here is my Code

    	NPC clerk = npcs.closest("Grand Exchange Clerk");
    	if (clerk !=null && grandExchange.isOpen() == false)
    		return State.ExchangeBanker;
    		int OpenedIt = 1;
    		int CheckedIt = 0;
    	if (OpenedIt <= 2 && CheckedIt == 0)
    		return State.ProfitCheck;
    		OpenedIt += 1;
    		CheckedIt += 1;
    	if(CheckedIt >= 0)
    		return State.MerchTime;
    	return State.Wait;
    	}

Here you see that I'm simply trying to get the script to recognize that if the previous case was completed it can move onto the next case, but for some reason it keeps hanging on the profit check case.

 

No code after a return statement will be executed. 

  • Like 1

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