Jump to content

How to fill correct values for int[][]?


Kalispel

Recommended Posts

I've been making a smithing bot and I've struggled with int arrays when it comes to setting the location of the furnace. 

I have this in my main class:

public static int[][] furnacePlace;
private Area furnaceArea = new Area(furnacePlace);

However, in the gui class I'm struggling to get it to take all 4 int values.

if (location.equals("Port Phasmatys")) {
    KaliRings.furnacePlace[][] = { x, y, x ,y}
}

I am getting an error on the x and y values. Am I writing it wrong? or can someone explain the use of int arrays a little better to me please? Thanks. 

Edited by Kalispel
Link to comment
Share on other sites

I suppose you could read this:

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

 

but it should be:

if (location.equals("Port Phasmatys")) {
    KaliRings.furnacePlace[][] = {x,x}, {y,y}
}

To get them out of there:

//This will get the first x and y
Position pos = new Position(KaliRings.furnace[0], KaliRings.furnace[0]);
//this will get the second x and y
Position pos = new Position(KaliRings.furnace[1], KaliRings.furnace[1]);
Edited by Vilius
  • Like 1
Link to comment
Share on other sites

I've been making a smithing bot and I've struggled with int arrays when it comes to setting the location of the furnace. 

I have this in my main class:

public static int[][] furnacePlace;
private Area furnaceArea = new Area(furnacePlace);

However, in the gui class I'm struggling to get it to take all 4 int values.

if (location.equals("Port Phasmatys")) {
    KaliRings.furnacePlace[][] = { x, y, x ,y}
}

I am getting an error on the x and y values. Am I writing it wrong? or can someone explain the use of int arrays a little better to me please? Thanks. 

Well... I guess you got an error in the second part of the code. But anyway in order to construct an Area you need the southwest corner and northeast corner x and y coordinates. I don't really understand why you need to use matrices when you need 2 positions.

The most logical thing to do is get the furnace Position (as a 3D vector meaning x, y and z) and then you can construct an Area relative to that Position (if you really want an Area).

public static Position furnacePosition = new Position(a, b, c);
// you get a, b, c ingame

public static Area getFurnaceArea() {
    x = furnacePosition.getX();
    y = furnacePosition.getY();
    // define a set of rules to create a custom rectangular area
    // I assume in this case that the furnace is on the eastern wall of a room
    // which I believe it is so in Port Phasmantys
    Area furnaceArea = new Area(x - 6, y - 2, x, y + 2);
    // so this Area is supposed to be 6x4 (6 squares in front of furnace including the furnace
    // and 2 on each side)
    return furnaceArea;
}

You don't need int arrays.

Edited by Token
Link to comment
Share on other sites

new Area(0,0,0,0).setPlane(0)

Op btw you are trying to make a 2d array that's why your messing up

Example got from link above

String[][] names = {

{"Mr. ", "Mrs. ", "Ms. "},

{"Smith", "Jones"}

};

// Mr. Smith

System.out.println(names[0][0] + names[1][0]);

// Ms. Jones

System.out.println(names[0][2] + names[1][1]);

Edited by Joseph
  • Like 1
Link to comment
Share on other sites

 

I suppose you could read this:

https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

 

but it should be:

if (location.equals("Port Phasmatys")) {
    KaliRings.furnacePlace[][] = {x,x}, {y,y}
}

To get them out of there:

//This will get the first x and y
Position pos = new Position(KaliRings.furnace[0], KaliRings.furnace[0]);
//this will get the second x and y
Position pos = new Position(KaliRings.furnace[1], KaliRings.furnace[1]);

 

Thanks

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