I tried to modify the dismember script, to show the name of the joint you have dismembered/fractured, and whether you have dismembered/fractured it.
It worked up until i added IF/THEN/ELSE and "ctype" things, before it always said the joint with dismembered or fractured by it depending on what you clicked.
(note: this is my first attempt at lua so be kind please :] )
-- dm.lua
function set_joint(player, joint)
if (joint ~= -1) then
cjointinfo = get_joint_info(player, joint)
cjoint = joint
cplayer = player
end
end
function keydown(key)
if ((key == string.byte("q")) and ((cplayer ~= -1) and (cjoint ~= -1))) then
dismember_joint(cplayer,cjoint)
ctype = "dismember"
elseif ((key == string.byte("o")) and ((cplayer ~= -1) and (cjoint ~= -1))) then
fracture_joint(cplayer,cjoint)
ctype = "fracture"
end
end
function keyup()
ctype = ""
end
cplayer = -1
cjoint = -1
local function draw_centered_text_example()
if ((ctype == "fracture")) then
set_color(0, 0, 1, 1)
draw_centered_text(cjointinfo.name.. " " ..ctype, 100, 2)
elseif ((ctype == "dismember"}} then
set_color(1, 0, 0, 1)
draw_centered_text(cjointinfo.name.. " " ..ctype, 100, 2)
elseif ((ctype == "")) then
set_color(0, 0, 0, 1)
draw_centered_text(cjointinfo.name, 100, 2)
end
end
add_hook("draw2d", "draw_centered_text_example", draw_centered_text_example)
add_hook("joint_select", "dm", set_joint)
add_hook("key_down", "dm", keydown)
add_hook("key_up", "dm", keydup)
Now it doesn't do anything. Help please :].