Controllers calling properties?

Can a controller be set to check if a property has a value?

It depends on what you want

  1. Check if a property as a certain value or it’s between certain values:
    Use the expression controller
    Example in the expression controller: “property_name>0 and property_name<10”
    checks if the property is between 0 and 10.

  2. Access a property through a python script:


import GameLogic as gl
o = gl.getcurrentController().getOwner()

then you can access the value using the expression:
o.name_of_property

Thanks. Would I be able to use this script?

Hm, where in this script do I incorporate the property names and values?

Ah, never mind about the name (I found it.) But still wondering about value. =(

One way with Logic Bricks:
Select the standard cube
Add Int property name: prop value: 0
Add Sensor - Keyboard - Space bar -> Expression - prop==0 -> Actuator -Move -DRot -X 0.10
Press P and press Space Bar
The object will only rotate if “prop” property its equal to 0
Change the “prop” value to 1 to verify this
Bye

Sorry for replying so late.

Ah, never mind about the name (I found it.) But still wondering about value. =(

The value is retrieved by

o.name_of_property

for example:


print o.name_of_property

this will print the value of the property

If you don’t know how to make scritps I recommend starting with the following tutorial by Social:
http://www.blendenzo.com/tutBeginningBGEPython.html

That’s ok. Thats! Now I know how to use expreswsions. (Been wondering about those for a while.)
=)