I reckon the python controller should be a python actuator, cause I cant work out how to trigger a script if, say, the up key is pressed and a property is TRUE…how do you trigger a python script using multiple conditions?
you make two sensors, and connect them both to an ‘and’ controller.
OK, but then how do I connect the AND to run the script? The python thingy is a controller not an actuator, so how do I make the result of the ANd run the script i want?
ah, i see your point. ok, this is my new idea. use the and controller connected to a message sensor, and make a new sensor to recieve the message to activate the script.
Hmm, I see. I really think the python controoler should be an actuator
No need to use messaging to make this work… it will only fill up your logic bricks faster and make it more difficult to debug!
Attaching multiple sensors to a script won’t do the trick, because this will mean that if ANY of the sensors are activated, then the script will run. You have to make the script CHECK for itself if the necessary multiple sensors are activated…
Example:
In your case you should only attach a keyboard sensor to your script, no need to add an extra property sensor, the script can check the value of the property by itself…
Name your keyboard sensor “keyup”, and your property “property”…
import GameLogic as g
controller = g.getCurrentController()
me = controller.getOwner()
keyup = controller.getSensor("keyup")
if ((keyup.isPositive()) & (me.property == TRUE)):
#add the code here
… attach that script to a keyboard sensor and your should be fine
But if you want to check if TWO sensors are activated you code should be like this:
import GameLogic as g
controller = g.getCurrentController()
me = controller.getOwner()
keyup = controller.getSensor("keyup")
keyshift = controller.getSensor("keyshift")
if ((keyup.isPositive()) & (keyshift.isPositive())):
#add the code here
i hope this is clear… (the spaces before the “#add the code here” are meant to be replaced by a TAB when you script it in python, or else it will return an error…)
thanks Ill try it out