Jump to content

How to take use input decide what cordiantes to use for an area?


Recommended Posts

Posted

So basically, I'm running into an issue with an or statement breaking my script, so I figured i'd try instead of having 2 areas, to get rid of the or statement and make it so only 1 area exist.

 

basically I have at the onStart()

String ironOrCoal = JOptionPane.showInputDialog("What area should we be at? c = coal, iron = i");

and then somewhere along the code i'll have

if(ironOrCoal.contains©)

{

Area MINEAREA = new Area(x,y,b,c);

}

else

Area MINEAREA = new Area(d,e,q,r);

 

 

this isn't the exact code, just an example of what I had. So I thought this should work, but it would tell me all around the code that it didn't know what MINEAREA is, and that it was unused. So on the onStart area I added a private Area MINEAREA; but that did nothing either, still wouldnt let me use it anywhere. So I messed around with it and Still couldn't figure it out.

 

Is it getting deleted once it leaves the if statement? like do I need to make a MINEAREA and have all its cordinates be 0, then in the if statement change it so it equals the cordinates based on user input? So confused with this issue.

Posted
 final Area COAL = blah blah blah;
 final Area IRON = blah blah blah;
       Area mine = null;


     if(COAL.contains(myPlayer()){
         mine = COAL;
      }else if(IRON.contains(myPlayer()){
         mine = IRON;
             }

 

oh im a dumbass Area is a final lol, that might be why. You always help my aass I feel like I owe you.

 

Anyway, so basically this has a final set for area, and a final set for iron, and it stores it into the area mine which has nothing in it?

Posted

oh im a dumbass Area is a final lol, that might be why. You always help my aass I feel like I owe you.

 

Anyway, so basically this has a final set for area, and a final set for iron, and it stores it into the area mine which has nothing in it?

something is only final if you don't intend on changing it.

The Area bits would go where all your other variables go and the if

would go in your on start.

the area your script will use in this case is 'mine' which will be defined by which area you are standing in on start.

if you want it to be more complicated you could if you're not in an area on start it will wait until you're in one of these two before

starting.

Posted

something is only final if you don't intend on changing it.

The Area bits would go where all your other variables go and the if

would go in your on start.

the area your script will use in this case is 'mine' which will be defined by which area you are standing in on start.

if you want it to be more complicated you could if you're not in an area on start it will wait until you're in one of these two before

starting.

 

Sorry went afk for a bit. Eclipse is yelling at me to change final Area to final int, and just underlines with red all the numbers I have after the =.

final Area COAL = 1,2,3,4;
//is that setup right?
Posted

 

Sorry went afk for a bit. Eclipse is yelling at me to change final Area to final int, and just underlines with red all the numbers I have after the =.

final Area COAL = 1,2,3,4;
//is that setup right?

 

 

private final Area IRON = new Area(1,2,3,4);

More people should use polygon areas.

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