Question : Java Client Applet - Passing one boolean to another

Alright, so progress is going great. I am now working on server-side picking up. That way two clients will know when someone has picked up an item off the ground.

Alright, so the tileGen inside has different booleans that tell to either draw or NOT draw the weapon or allow the weapon to be picked up.

Anyway, for now I'm working on the sword...  here is how it works.

When a client who is picking up the Item does this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
  if (drawSword)
{
	if (currentMap == 1)
	{
		if (spawnX == 13 && spawnY == 7)
		{
			drawSword = false;
			draw = "drawSword";
			currentItem = "3";
			try
			{
				addInv(3);
			}
			catch (Exception ere)
			{t
				ere.printStackTrace();
			}
		}
	}
}


If the drawSword is true ... then allow this. If they are on Map 1... keep allowing... if they are on the specific X and Y... then ALLOW for the pickup.. all checks are good. drawSword then turns false which is for the one time pick-up. draw is the string to be passed to the server later on. the currentItem string is the number ID of the item used to get information about it (name, desc, type of weapon, etc.), then it adds the inventory of the person who picked it up. then later on (not shown in the code above) it sets myCommand as "pickup"

Anyway, after that... on line 1023 is where it sends this action to the server:
1:
2:
3:
4:
} else if (myCommand == "pickup") {
				//int theirTile = board[spawnY][spawnX];
                  os.println(me.getUsername() + "|" + currentItem + "|" + draw + "|"+ theirTile + "|pickup");
            }


Their tile was going to be the tile it's under on. But then I figured out I could just set the boolean of the item so it wouldn't be draw again. So technically it doesn't matter if I sent over theirTile  but I left it there for now. The me.getUsername is the person who picked it up. the CurrentItem is the ID of the picked-up item and the draw is the string of the boolean it was picked up.

Then we go back to Line 420 where the run() is at.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
 if ("pickup".equalsIgnoreCase(temp[4]))
{
	c.append("\n"+temp[0] + "|" + temp[1] + "|" + temp[2] + "|" + temp[3] + "|" + temp[4]);
	//int changeX = Integer.parseInt(temp[1]);
	//int changeY = Integer.parseInt(temp[2]);
	//board[changeY][changeX] = 4;
	int theItem = Integer.parseInt(temp[1]);
	c.append("\n"+temp[0] + " picked up a " + getItem(theItem)[0]+".");
	Boolean.parseBoolean(temp[2]) = false; // drawSword = false?
}

the first line is for debugging purposes. then we go to int theItem which parses the string to int which is the item ID. Then the message says "Someone picked up the some item".
Then here is where my problem lies. I'm trying to get the string "drawSword" as the boolean to be false but I get this error:

1:
2:
3:
4:
5:
6:
7:
8:
C:\wamp\www\mystikrpg\tileGen.java:428: unexpected type
required: variable
found   : value
	Boolean.parseBoolean(temp[2]) = false; // drawSword = false?
	                    ^
1 error

Tool completed with exit code 1


So.. close... :P

Any help?

Answer : Java Client Applet - Passing one boolean to another

Yes, the code doesn't make any sense. You can either get the value, or set the value:
1:
2:
3:
4:
5:
boolean which = Boolean.parseBoolean(temp[2]);

// Or

temp[2] = "false";
Random Solutions  
 
programming4us programming4us