[3.22] Can't read rotation from gamePiece

I’m trying to read the rotation of game pieces with “can rotate”-trait using an imported class.

chatter.show(card.getName()); Object facing = card.getProperty("Rotate_Facing"); if (facing != null) chatter.show(facing.toString()); Object degrees = card.getProperty("Rotate_Degrees"); if (degrees != null) chatter.show(degrees.toString());

Sadly facing and degrees will be null. I’ve attached a simple demo for this problem.
It contains one game piece with “can rotate”-trait and a button to activate the java code.
Open the demo and click on “Demonstrate” in the main menu bar.
Expected result would be a chat containing:

Found pieces: Rotating piece // piece name 0 // piece facing 0 // piece degree

Returned chat is only:

Found pieces: Rotating piece
Facing and Degree are missing since the value returned by getProperty is null.

Thus spake Jonas-:

I’m trying to read the rotation of game pieces with “can rotate”-trait
using an imported class.

Code:
chatter.show(card.getName());
Object facing = card.getProperty(“Rotate_Facing”);
if (facing != null)
chatter.show(facing.toString());
Object degrees = card.getProperty(“Rotate_Degrees”);
if (degrees != null)
chatter.show(degrees.toString());

How are you getting card? I think we need to see the rest of your
custom class in order to help.


J.

The code can be found within the vmod. Here is the part where I react on a button click:

    private void testButtonPressed() {
    	Chatter chatter = GameModule.getGameModule().getChatter();
    	chatter.show("Found pieces:");
    	
    	List<Map> maps = Map.getMapList();
    	for (Map map : maps) {
   			GamePiece[] cards = map.getAllPieces();
   			for (GamePiece card : cards) {
				chatter.show(card.getName());
				Object facing = card.getProperty("Rotate_Facing");
				if (facing != null)
					chatter.show(facing.toString());
				Object degrees = card.getProperty("Rotate_Degrees");
				if (degrees != null)
					chatter.show(degrees.toString());			
    		}
    	}
    }

I am not sure why this fails. Brent, do you see it?

Does ‘Rotate’ match the name of the rotation property you entered in the Description field of the Can Rotate trait?

Description is expected to be a description. So it was left blank.
Changing it to “Rotate” doesn’t change anything :frowning:

First thing First, let’s ignore your custom code and work out exactly what property names you should be using.

Add a Text Label to your counters activated by Ctrl-L and add a label to your counter $Rotate_Facing$ - $Rotate_Degrees$. Rotate your counter and see what you get.

If the description is blank, then $_Facing$ - $_Degrees$ should work.

Once you have worked out the right property names, then go back to the custom code.

Brent.