Jump to content

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


Twin

Recommended Posts

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.

Link to comment
Share on other sites

 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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

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.

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