(Python) read variable from another scene and rotate object.

Hello There! :slight_smile:

I have two very simple scenes here, one scene has only an red arrow pointing left, the other scene has a cube and it(the scene) runs on background.

The left arrow has a simple py script that i made:

import GameLogic as gl

ct = gl.getCurrentController()
ow = ct.owner

rotleft = ct.sensors["leftarrow"]

if rotleft.positive:
    gl.varrl=True
    print gl.varrl
    
else:
    gl.varrl=False
    print gl.varrl

Which ran when the mouse is over it. So, basically, when the mouse is over the arrow, the variable varrl is True. (this part is working very well because it prints on terminal if the var is true or false)

And i want the Cube on the background scene to read the same variable and rotate left when it’s True.

But i don’t know how to do such thing.

Can you help me?

Thank you very much and sorry my english.

Attachments


little update:

The script that runs from Cube:

import GameLogic as gl

ct = gl.getCurrentController()
ow = ct.owner

rotl = ct.actuators["act"]

if gl.varrl==True:
    rotl.dRot=[0,0,-0.01] 


ct.activate(rotl) 

If i comment out the “if” line the cube rotates left.

but when the “if” line is present, the terminal says:

AttributeError: 'module' object has no attribute 'varrl'

i think it’s because the variable isn’t valid in another scene… it’s no fully “global”

Please, guys, gimme a hand here!!:frowning:

Thanks

EDIT: i edited the “rotleft” here to aviod mistakes, it’s “rotl” now.

Nevermind.

The problem is; you need to check the “Activate TRUE level triggering (pulse mode)” button.