Quote: "maybe try this out
+ Code Snippet
function GetLimbIDByName(objectno,limbname$)
perform checklist for object limbs objectno
for x = 0 to checklist quantity()
if checklist string$(x) = limbname$ then limbno = x
next x
endfunction limbno
"
Here's a better version of the same thing. It's faster and stops searching once it finds the proper limb.
function GetLimbIDByName(objectno,limbname$)
perform checklist for object limbs objectno
for x = 0 to checklist quantity()
if checklist string$(x) = limbname$ then ExitFunction x
next x
endfunction -1
Quote: " That all works, however it can be considered a waste of time to constantly iterate through potentially all limbs only to find that the last one (or none!) has the sought name.
Although seeing as you probably at most have a couple of hundred limbs it might not be a very big slowdown issue."
I agree, that's why you keep track of the limbs. This way you check once and never have to check again.
Dim Character_Limbs(50)
Make a standardized limb list for your objects. Then store the real limb numbers in the array in the proper array indexes. Basically you need to "Map Out" the limb structure of your objects.
If you decide to do this then I really recommend streamlining the process like this:
function MapCharacterLimbs(objNum)
perform checklist for object limbs objNum
for x = 0 to checklist quantity()
if checklist string$(x) = "Head" Then Character_Limbs(0) = x
if checklist string$(x) = "Chest" Then Character_Limbs(1) = x
if checklist string$(x) = "RightLeg" Then Character_Limbs(2) = x
next x
endfunction
This way the processing time is O(n) instead of O(n*n) and thus faster than the previously suggested method. If you studied software development in school, this is BIG O notation for describing how long a program takes to execute.
Quote: "If you have Matrix1Utilities you can use the "lookup" tables.
Unfortunately they're only string-to-string maps so you'll have to convert your limb ID's back and forth between strings and numbers.
Something like this (pseudocode, not sure if it'll compile but demonstrating the general idea):"
I don't want to give Matrix1Utilities bad press because the plugin is great. But don't do it that way. The priority here is speed. The Example you provided, to map all the limbs is going to be O(n*n) or worse. You're in the heat of battle, JAWS and ODDJOB have you pinned down behind a crate, the golden gun only has one bullet, the cavalry is loading and there's no time for choppy frames.
Taking a step back: You should really think about the process you are using to create these objects. Most people will find ways to skip this nonsense and have their modelling program create objects with the proper limb numbers from the start. Figuring this out could save you some work.