basic python help

Hello,

I am just getting started learning python scripting in the game engine, and have some ideas for scripts I want to write, but I can’t find any tutorials that help me figure out hoe to write them, although I looked at some beginner tutorials. I would like to know how to make a python controller activate an actuator based on input from sensors, and also how I could have an object track to(exactly like the track to actuator) another object, but change which object it tracks to depending on input from sensors. I would appreciate it very much if someone could help me out.

Um…Your not exactly clear. Post some pictures so I can see what your talking about.

There are some resources on Python scripts here on the forums. Also, I have been making some tutorials about Python scripting in the BGE - perhaps you would be interested in checking them out as well. The link is in my signature. There’s not really too much info on a lot of features / functions available in Blender or the BGE.

Thank you for telling me about your tutorials, they were quite helpful. After reading them I managed to solve the problem myself.

Edit: I’ve got another question now. My script checks if a variable is positive, like this:
if right.isPositive():

and it works just fine that way. But I want to know how to check if the variable is negative, and I couldn’t find anything with a Google search.

Check the resource forum for links to learn Python. Making an “if” statement checking the opposite is basic programming. So learn that first. (My suggestion as usually “byteOfPython.pdf”).

Than check the BGE API. You will need it. Especially some methods are deprecated (like isPositive()). The API tells you what to use instead.

Thanks for replying.

I read through some of “A Byte of Python”, like you suggested, and I understand enough to finish my script now, but I looked at the BGE API and couldn’t find what to use instead of isPositive() (It’s confusing to navigate for me). Could you either tell me, or tell me where to look in the API?

just


isPositive = sensor.positive

sorry the link is incorrect. This one s the index:
http://www.blender.org/documentation/249PythonDoc/GE/

this one explains the isPositive():
http://www.blender.org/documentation/249PythonDoc/GE/GameTypes.SCA_ISensor-class.html#isPositive