local player_index = 0
local body_index
local body_info
local angle_x, angle_y, angle_z
local trx, try
local file = io.open("!test.tbm","w")
file:write ("# mod automatically generated by Melmoth's Stance Maker\n\n")
for joint_index = 0,19 do
joint_info = get_joint_info (player_index, joint_index)
joint_pos = get_joint_pos2 (player_index, joint_index)
local radius = get_joint_radius (player_index, joint_index)
local jointname = string.lower(joint_info.name)
jointname,_ = jointname:gsub("right ", "r_")
jointname,_ = jointname:gsub("left ", "l_")
file:write ("joint " .. string.lower(jointname) .. "\n")
file:write ("\tradius " .. radius .. "\n")
file:write ("\tpos " .. joint_pos.x .. " " .. (0.45 + joint_pos.y) .. " " .. (0.06 + joint_pos.z) .. "\n")
end
file:write ("\n")
for body_index = 0,20 do
body_info = get_body_info (player_index, body_index)
local bodyname = body_info.name
if (bodyname == "THORAX") then
bodyname = "groin"
end
angle_y = math.asin(body_info.rot.r2) -- Calculate Y-axis angle
C = math.cos(angle_y)
angle_y = -(angle_y * 180) / math.pi
if ( math.abs( C ) > 0.005 ) then
-- no Gimball lock, so get X-axis angle
trx = body_info.rot.r10 / C
try = -(body_info.rot.r6 / C)
angle_x = -(math.atan2( try, trx ) * 180) / math.pi
trx = body_info.rot.r0 / C -- Get Z-axis angle
try = -(body_info.rot.r1 / C)
angle_z = -(math.atan2( try, trx ) * 180) / math.pi
else
-- Gimball lock has occurred
angle_x = 0 -- Set X-axis angle to zero
trx = body_info.rot.r5 -- And calculate Z-axis angle
try = body_info.rot.r4;
angle_z = -(math.atan2( try, trx ) * 180) / math.pi
end
file:write ("body " .. string.lower(bodyname) .. "\n")
file:write ("\tsides " .. body_info.sides.x .. " " .. body_info.sides.y .. " " .. body_info.sides.z .. "\n")
file:write ("\tpos " .. body_info.pos.x .. " " .. (0.45 + body_info.pos.y) .. " " .. (0.06 + body_info.pos.z) .. "\n")
file:write ("\trot " .. angle_x .. " " .. angle_y .. " " .. angle_z .. "\n")
file:write ("\n")
end
file:close()
add_hook("draw3d","test",
function()
set_color(0,0,0,1)
for joint_index = 0,19 do
joint_info = get_joint_info (player_index, joint_index)
joint_pos = get_joint_pos2 (player_index, joint_index)
local radius = get_joint_radius (player_index, joint_index)
draw_sphere(joint_pos.x-3,joint_pos.y,joint_pos.z,radius)
draw_sphere(joint_pos.x+3,joint_pos.y,joint_pos.z,radius)
end
for body_index = 0,20 do
body_info = get_body_info (player_index, body_index)
angle_y = math.asin(body_info.rot.r2) -- Calculate Y-axis angle
C = math.cos(angle_y)
angle_y = -(angle_y * 180) / math.pi
if ( math.abs( C ) > 0.005 ) then
-- no Gimball lock, so get X-axis angle
trx = body_info.rot.r10 / C
try = -(body_info.rot.r6 / C)
angle_x = -(math.atan2( try, trx ) * 180) / math.pi
trx = body_info.rot.r0 / C -- Get Z-axis angle
try = -(body_info.rot.r1 / C)
angle_z = -(math.atan2( try, trx ) * 180) / math.pi
else
-- Gimball lock has occurred
angle_x = 0 -- Set X-axis angle to zero
trx = body_info.rot.r5 -- And calculate Z-axis angle
try = body_info.rot.r4;
angle_z = -(math.atan2( try, trx ) * 180) / math.pi
end
set_color(1,0,0,1)
if(body_index == 0) then
draw_sphere(body_info.pos.x-3,body_info.pos.y,body_info.pos.z,body_info.sides.x)
draw_sphere(body_info.pos.x+3,body_info.pos.y,body_info.pos.z,body_info.sides.x)
elseif(body_index > 0 and body_index < 15) or (body_index > 18) then
draw_box(body_info.pos.x-3,body_info.pos.y,body_info.pos.z,body_info.sides.x,body_info.sides.y,body_info.sides.z,angle_x,angle_y,angle_z)
draw_box_m(body_info.pos.x+3,body_info.pos.y,body_info.pos.z,body_info.sides.x,body_info.sides.y,body_info.sides.z,body_info.rot)
else --Legs are odd..
draw_capsule(body_info.pos.x-3,body_info.pos.y,body_info.pos.z,body_info.sides.x+0.2,body_info.sides.y-0.17,angle_x,angle_y,angle_z)
draw_capsule_m(body_info.pos.x+3,body_info.pos.y,body_info.pos.z,body_info.sides.x+0.2,body_info.sides.y-0.17,body_info.rot)
end
end
end
)
So idk, it must be a problem to do with either the creation of the mod file, or the way mods work?