Objects and Scripts

Can you run .py files (like modules) inside of another .py file?

And::

How can I change another objects properties, like:

GameLogic.Plane001.Text = “Hi there sir!”

It would be an object that is not linked to the .py file through logicbricks.

uhh, yes

import sys
sys.__stdout__.write("hi
")# print hi to the console


cont = GameLogic.getCurrentController()
obj = cont.getOwner() # all logic bricks have this method
obj.Text = "dasies!!! foiled again"

so you can link logic bricks in from other objects to your controller, and mess with those objects using the getOwner() method.

[just so we’re clear, you can’t mess with logicbricks you’re not connected to]

You can import python modules using the import function.

To manipulate properties on another object (must be in the same scene), you can use this code:

Cube = GameLogic.getCurrentScene().getObjectList()["OBCube"]
Cube.Text = "Hi there sir!"

This method doesn’t require objects to be linked via logic bricks. All you can do is alter properties though, so far there is no ability to control sensors and actuators remotely.