@TheComet
Very nice functions! A few suggestions on how to improve overhead and manage resources a little better.
If you don't plan on texturing each limb with a different image or you have no intention of moving the limbs independently, it's best to have a solid object without limbs. Limbs will slow processing down because they are indexed as individual meshes. You can do this by creating a mesh from the limbed object, deleting the limbed object then recreating the object using MAKE OBJECT.
In your general cleanup, I see you are deleting the unnecessary objects that you made meshes from. That's good, but you should also delete all of the unused meshes. Once you've created all the limbs from a mesh that you need, the mesh is no longer useful. If it's hanging around in memory, it's just eating up resources.
Also, in the general structure, you don't really need to create so many separate objects and separate meshes. One extra object and one extra mesh is all you need. You can reuse both. You are slowing your functions down and adding more code than you need by checking for so many available objects and meshes. The following example shows one way of implementing the overhead cuts I suggest. The top object is a solid mesh, the bottom object is limbed. I do use 1 check for available object and 1 check for available mesh which I don't really think is a great thing to do. I think it's best though, to have the user manage this themselves and for it not to be part of the function and have them pass the parameters of these values to the function unless there's too many objects or meshes to handle. DBC will error out if the object already exist, but it will replace the mesh with the new one if that exists.
autocam off
limb_example(1,20.0,0)
rem turn off culling for plains in object 1
set object 1,1,1,0
limb_example(2,10.0,1)
position object 2,0,-30,0
color limb 2,1,rgb(0,255,0)
color limb 2,2,rgb(255,0,0)
position camera 0,0,-100
do
turn object left 1,1
turn object left 2,1
loop
end
function limb_example(obj,size#,limbflag)
rem limbflag is to decide whether we want the limbs posable or
rem just a solid object
rem 0 = solid
rem 1 = posable
if limbflag > 0
limbflag=1
else
limbflag=0
endif
rem let's assume that there is no mesh that is the same as the object number
rem but in case there is, we will find the next available one - same for an
rem additional object we may need for a different shape
msh=obj
obj2=obj+1
while mesh exist(msh)=1
inc msh
endwhile
while object exist(obj2)=1
inc obj2
endwhile
rem begin the limb adding process
make object plain obj,size#,size#
make mesh from object msh,obj
add limb obj,1,msh
offset limb obj,1,size#,0,0
rem let's add a couple of other objects as limbs
make object sphere obj2,size#
make mesh from object msh,obj2
add limb obj,2,msh
offset limb obj,2,size#*2,0,0
delete object obj2
make object cube obj2,size#
make mesh from object msh,obj2
add limb obj,3,msh
offset limb obj,3,size#*3,0,0
delete object obj2
rem check the limbflag to see if we make the obejct solid
if limbflag=0
make mesh from object msh,obj
delete object obj
make object obj,msh,0
endif
rem cleanup our mesh
delete mesh msh
endfunction
Enjoy your day.