Blender python help

Hello ewerybody, i’m trying to make a script for a game but i can not. The script should get the rotation of the object to which it refers. If the rotation is positive, another cube must do an animation.
I already tried to do a script but it doesn’t work ,maybe because I’ve just started with python:o.

The script is:

import bge
cont = bge.logic.getCurrentController()
own = cont.owner
scene = bge.logic.getCurrentScene()
cube = scene.object[“Cube”]
rot = own.worldOrientation

if rot.z > 0:
cube.playAction(“Act1”, 1 , 9, play_mode = 3)

rotation is a matrix

you will need rot.to_euler I think

Use code tabs for put the code, and always open the console to see the errors of the script.

worldOrientation return a 3x3 matrix, you can’t acces to it like a euler(like the worldPosition), try using object.worldOrientation.to_euler() for change the matrix to a euler(it going to return values in radians).

it don’t work. this is the file blend1.blend (472 KB) .Can everyone reply me this file with corrections?

Two errors:

1)In the line 5: the class that manage the scenes not have attributes or functions that are named “object”, maybe you mean “objects”:
Change:

cube = scene.object["Cube"]

With:

cube = scene.objects["Cube"]

2)In the line 6: What is the variable object? maybe you mean “cube”.
Change:

rot = object.worldOrientation.to_euler()

With:

rot = cube.worldOrientation.to_euler()

Note: to see the console, go to window>Toogle system console.
The console is a usefull tool, with it you can see the errors that have a script.

ok thanks you

Do you mean orientation (the direction the object is facing to) or rotation (the change of orientation)?