ok, written now
#animationgrabber.py
class Animation:
def __init__(self, gob, name, fs, fe, ly, pr, bi, pm, lw):
self.gob = gob
self.name = name
self.fs = fs
self.fe = fe
self.ly = ly
self.pr = pr
self.bi = bi
self.pm = pm
self.lw = lw
self.sp = 1.0
def play(self):
self.gob.playAction(self.name, self.fs, self.fe, layer=self.ly, priority=self.pr, blendin=self.bi, play_mode=self.pm, layer_weight=self.lw, speed=self.sp)
def stop(self):
self.gob.stopAction(self.layer)
def is_running(self):
return self.gob.isPlayingAction(self.ly)
@property
def frame(self):
return self.gob.getActionFrame(self.ly)
@frame.setter
def frame(self, fr):
self.gob.setActionFrame(fr, self.ly)
def grab_all_actions(gob):
actions = {}
for a in [ a for a in gob.actuators if hasattr(a, "action") and a.action]:
name, fs, fe, ly, pr, bi, pm, lw = a.action, a.frameStart,a.frameEnd,a.layer,a.priority,a.blendIn,{False:0,True:1}[bool(a.mode)], a.layerWeight
actions[a.name] = Animation(gob, name, fs, fe, ly, pr, bi, pm, lw)
return actions
how work?
put this code in a module (animationgrabber.py)
then from a normal module(or script) write:
own = cont.owner
if not "animations" in own:
own["animations"] = animationgrabber.grab_all_actions(own)
own["animations"]["idle"].play()
PS:
note that the name of the actions is the name of the “brick action” (not necessarly the name of the action)
so in this case must be a brick action named “idle”
PS2:
it support only play_mode <play>, and <loop> (if is not play, is automatically “loop_stop”) (no pingpong,not flipper)
PS3:
also , this code is basically a copy and paste of a code of another user , is not my stuff.
but not remember the name , something as “LinX” from Canada