object.get_orientation
This function returns a number between 1 and 6 representing an object's overall rotation. The values seem to indicate which side of an object is facing up, i.e. if you were to imagine a cube enclosing the object, the values would each correspond to one side of the cube.
The different values are available in the orientation enum.
This function returns number. Calling this function without storing its return value in a variable is an error.
Example
global.number[0] = current_object.get_orientation() if global.number[0] != 1 then -- -- object isn't upright -- end
Notes
This function may not work on all object types, or its efficacy may depend on an object's physics. It works on vehicles, but phased-physics objects that have been pre-rotated in Forge seem to always test as being upright.