python question

I need help with a python script. I want to know how do you get a property to activate an actuator using script? I tired this but it didnt work. Could someone please help. I will find so much use for this. thanks

cont = GameLogic.getCurrentController()
own = cont.owner

if own[“prop”] == (1):
GameLogic.addActiveActuator(“act”)

Try this:


cont = GameLogic.getCurrentController()
own = cont.owner

my_act = cont.actuators["act"]

if own["prop"] == 1:
    cont.activate(my_act)

check the console. I think you will find an error there because GameLogic.addActiveActuator expects 2 parameters see http://www.blender.org/documentation/249PythonDoc/GE/GameLogic-module.html#addActiveActuator

As this is deprecated use http://www.blender.org/documentation/249PythonDoc/GE/GameTypes.SCA_PythonController-class.html#activate.

I hope it helps

You use the cont.activate function.


c = GameLogic.getCurrentController()
o = c.owner

if o['prop'] == 1:
    c.activate("act")
else:
    c.deactivate("act")

thank you for helping. I used both your scripts to get it done. Now i have controll over what would have been a mess of noodles.