I'm getting an unexpected result with getAttribute, maybe you can have a look at it: I have several siblings who have an the same attribute value-- pos="c". I am trying to write an if statement to identify this attribute:
Code:
println(playerRef.getAttribute("pos"));
if (playerRef.getAttribute("pos")=="c") {
println("*");
}
This code generates a bunch of 'c's, but no asterisks. It looks as though the statement should be true, but it always comes up false.
I tried the following code, to see if I could figure out where the problem was occuring:
Code:
println(playerRef.getAttribute("pos"));
if (playerRef.getAttribute("pos") == playerRef.getParent().getChild(0).getAttribute("pos")) {
println("*");
}
Basically, comparing the attribute against the first child's attribute. This generates the following output:
Code:
c
*
c
c
c
c
Even though all the attributes are the same, it treats only the first one as a match. Any suggestions you have on why this isn't working for me would be greatly appreciated. Keep up the great work.