Jump to content

GE Script Question


creationx

Recommended Posts

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? 
 

 

Link to comment
Share on other sites

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

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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