python question (objects not linked to the script)

I want to specify an the name of an object in a python script, so I can do something like sword.getSensor(“collision”).getHitObjects(), but can I specify the name of an object not linked to the script? (so my character’s arm will stop swining if the sword hits a wall)

thanks for any help in advance (ps, any links to a current list of game engine python commands/descriptions would be greatly appreciated as well)

Why would you need to do that? Can’t you just add a property to the wall object and then specify that property as a filter for the collision sensor on the sword?

Also, what is your “sword” object set to? It has to be set to “GameLogic.getCurrentController()” to work for the getHitObjects() code you have there. That said, I strongly recommend that you use “cont” for the controller assignment from now on. It makes it easier for the python people in the community to recognize what you are doing.

(ps, any links to a current list of game engine python commands/descriptions would be greatly appreciated as well)
http://www.blender.org/documentation/pydoc_gameengine/PyDoc-Gameengine-2.34/GameLogic-module.html

That’s the one I use. There was also a PDF file flying around, but it wasn’t as usefull.

If you want to get an object in the scene just use the scene function getObjectList.


scene = GameLogic.getCurrentScene()
sword = scene.getObjectList()["OBsword"]

thanks, fireside- I’ll try it as soon as I can

Also, what is your “sword” object set to?

the point of this thread was to find out what to use for the sword-it’s not linked to the script. (I want the arm to stop swinging if the sword hits an object with the property “solid”- there’s more to the setup, I’ll show it when I’m done)

I need something like that in my Jerusalem project too…