Thinking out loud -changing bone constraints

step 1

add ragdoll on actor death

Ragdoll = bge.logic.getCurrentScene().addObject('RagdollGroupInstance,own,0)

Armature =  bge.logic.getCurrentScene().addObject(own['ArmCopyOnHiddenLayer',own,0)

for const in Armature.constraints:
    for bones in eval(Ragdoll['RagBones']):

but a issue I am having is eval(Ragdoll[‘Ragbones’])
throws a error,

it contains
the string - [‘MCH-forearm.L’,‘MCH-upper_arm.L’,‘MCH-head’,‘MCH-neck’,‘MCH-chest.001’,‘MCH-chest.002’,‘MCH-hips’,‘MCH-forearm.R’]

how do I turn a string into a list?

ok I have -

import bge
import ast

def main():

    cont = bge.logic.getCurrentController()
    own = cont.owner

    ##add ragdoll on actor death

    Ragdoll = bge.logic.getCurrentScene().addObject('addObb.001',own,0)

    Armature =  bge.logic.getCurrentScene().addObject(own['Armature'],own,0)
    x = Ragdoll['RagBones']
    x2 = Ragdoll['RagBones2']
    list1 = ast.literal_eval(x)
    list1 = [i.strip() for i in list1]
    list2= ast.literal_eval(x2)
    list2 = [i.strip() for i in list2]
    list1 = list1+list2
    for const in Armature.constraints:
        print(str(const)+" is the name of the constraint")
        for bones in list1:
            print(str(const)+" is checking "+str(bones))
            if": Copy Rotation":
    for objects in own.childrenRecursive:
        if 'Actor1CameraHook' in objects:
            cam =bge.logic.getGetCurrentScene().active_carmera
            if cam['Target']==own:
        if 'CamTarget' in objects:

but I am having issues with the constraint names format not matching each other :frowning:

edit: I think it’s because they were added using diff versions, I will clear them all and add them back

eval() is evil.

Because it executes any Python code that is in that string … it could even clean your hard disk ;).

Why is there a string in this property? It does not look like you entered that manually.
Why didn’t you added a list instead? That is what you finally expect.

I stored a property in a object on a hidden layer,
that was a list stored as a string, in the ragdoll
group instance empty,

I dont know how to
access group objects spawned as a instance
from the empty you add them with,
so I just stored them.

I got it working btw, I had100% of the code right and forgot to
play 1 frame of action on the added armature for a while


now it works great
check my thread for team projects wrectified.