How can i access properties via script ?

I saw blend files with script and properties that are not connected to the script as sensors .
Please tell me i wanna know how, Thanks in advanced .

I dont really understand…
In a script, own[‘myprop’] is the way to make the script aware of a property that exists in the object that runs the script.
Then you can do things like this:
own[‘myprop’] -= 100
own[‘myprop’] += 100
own[‘myprop’] = 100 *2
own[‘myprop’] -= 100/2

I’m not sure I understand what you mean. Are you asking how to access object properties via Python? If so, you can do it by getting the object and using the dictionary ‘syntax’ to access the variable:

controller = logic.getCurrentController()
object = controller.owner
object['health'] = 100

EDIT: BlendingBGE beat me to it, hah.

game properties of objects?
first you get the scene scene = logic.getCurrentScene() then you access the object with objectVariable = scene.objects[‘object name’] and then the property with objectVariable[‘property’]

Thank you all :smiley:

Also, in the newer releases of Blender, you will be able to access (2.65 +) KX_GameObject.scene -> the current scene in which the object resides

Might as well ask my question here since it’s sort of related…

I’m trying to learn python, to move my logic bricks into scripts and modules.
Is it possible to create a sensor with a script, after the game has been launched?
Just wondering if you could have 1 always sensor and 1 controller to a script, in which it creates all other sensors, controllers and actuators needed for the other scripts that would make the whole game.

If so, can someone tell me how to make a message sensor? then i think ill be able to figure out the rest.

Looking at
it doesnt seem possible, neither to rename the name of a message sensor, was thinking of using just one message sensor and renaming it for the purpose.
But again, looking at the above link i dont think so.