Changing Actions with python??

I’ve got a player class which I am using to manage playing actions, player movement etc… I have assigned an action actuator to a variable in the class with:

self.action_reload = self.own.actuators["reload"]

I am looking to change the action of that actuator, with something like:

self.action_reload.action = "RifleReload"

but I get an error message in the console saying (image at bottom for full error):

ValueError: actuator.action = val: Action Actuator, action not found!

The python api here made me think I was along the right lines. But clearly not. I was under the impression that you could change actions for an action actuator within python like this. The only thing I can think of is that I have not loaded the new action into any actuator, so many it doesnt get loaded or something. But the error doesnt seem to suggest this.

Any help would be great. I’ve of hit a block with this problem.

Thanks


I just tested this out with the default blend file, and it appears to work. Are you sure that you have an action of the name “RifleReload”? I only got that error if I tried setting the action variable to an action that didn’t exist.

Yep, silly me, I got caught out by not pressing the infamous ‘F’ button to save the action datablock. I must have closed/opened the file and the action had disappeared. Thank god for auto-save. I have been caught out by this sooooo many times I thought I had ‘grown out of it’. Oh well. Thanks for the reply and making me see my silly ways.