Add property By python

Hello guys ,this looks like an easy 1 but i loooked around but dint find a answer…

How can i create or add a new property to an object?

and how can i rename a property? (if its possible) :rolleyes:

Also, XD how can i change states on python? :stuck_out_tongue_winking_eye:

BTW i also wanted to know somethign alse XD

for exaple how can i say in python…:

if Hitobject == rock:
then do this…

i meant like if ( a ray.mouse over .etc) hits object ROck…
then u do the following…

properties are just like normal variables I though.

so to make a int property, e.g: intProp = 25
bool property: e.g: boolProp = True
float property: e.g: floatProp = 0.56

the names inProp etc can be changed to what even you want

also you can make them global by placing g. before the name for example g.floatProp, you also need to import gameengine as g

(I only know Blender 2.5 so if you use 2.49b things might be different)

What retro world described are just variables. To write or read a property in Blender 2.5 you just access the dictionary of the object with the property name. If your object is “own” and you want to read the property “points” for example you just use “own[‘points’]”.

To change states I guess you have to connect a state actuator and then look up the API of that actuator.

a simple example

Attachments

property.blend (128 KB)