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