Which you probably have seen there are some warnings that appear and say that some functions are outdated and won’t work in 2.5. I have been working on a game which replaces meshes with python. (I use an edit object actuator and the setMesh function) It has been working fine until I started using 2.49, when all the warnings started to appear. However after I changed the scripts (seemingly) the way they said, it can’t swap meshes through python anymore. I don’t know why. If anyone know how to do this in 2.49 I’d be happy to hear.
I just tried my Meshfoot script, which was written in version 2.48a with version 2.49 and it still works fine. The main function of Meshfoot is to swap meshes and re-link them during a frame change event. This is not game engine related, however.
Feel free to browse the code here:
http://blenderartists.org/forum/showthread.php?t=154134&highlight=meshfoot
Sorry, I looked at it but I couldn’t find anything that helped me with this in the script. As you said, it’s not a game engine script.
Here is an example of the different steps that I take in my file:
cont = GameLogic.getCurrentController()
own = cont.getOwner()
#Get the actuator that replaces the mesh
act = cont.getActuator("Act")
#Get the property with the mesh name
prop = own.prop
#Set the actuators mesh setting
act.setMesh(prop)
#Activate the actuator
GameLogic.addActiveActuator(act, 1)
With this code I get a couple of warnings:
Method getOwner() is deprecated, please use the owner property instead
Method getActuator(string) is deprecated, please use the actuators[string] property instead.
Method val = ob.attr is deprecated, please use val = ob['attr'] instead.
Method setMesh() is deprecated use the mesh property instead
Method GameLogic.addActiveActuator(act, bool) is deprecated, please use controller.activate(act) instead.
Here is how I solve them:
cont = GameLogic.getCurrentController() # Same as before...
#Get the owner
own = cont.owner # Works (The script that sets the property that I read in this script uses it)
#Get the actuator that replaces the mesh
act = cont.actuators["Act"]
#Get the property with the mesh name
prop = own["prop"] # The "own['prop'] = val" works, so I assume this does too
#Set the actuators mesh setting
act.mesh = prop # I've tried some different ways, but this doesn't give an error message and no warning, but this is where I believe something is wrong.
#Activate the actuator
cont.activate("act")
Anyone who knows how this should be done in 2.49?