The way you are looping through all the entities to find the target is kind of backwards. You know you want your plane to have a propeller. You don't need to place it in the editor every time you want a plane. It's far easier just to do this in the spawn function:
Function Spawn(model)
entity=base_Spawn(model)
entity.propeller = LoadModel( "abstract::propeller.gmf" )
If entity.propeller~=nil then
attachmentposition=TFormPoint(Vec3(1,0,1),model,nil)
entity.propeller:SetPosition( attachmentposition )
CreateJointHinge( model, entity.propeller, attachmentposition, Vec3(0,0,1) )
End
End
Make sure you get rid of the propeller in the Kill function:
Function Kill( model )
entity=entitytable[ model ]
If entity~=nil then
If entity.propeller~=nil then
entity.propeller:Free()
entity.propeller=nil
End
End
base_Kill(model)
End
I used this kind of automatic subobjects in the train cars to attach wheels to the car.