Ranking
Original Post
i need help
guys this code
--FreeCam v3
--by FNugget
--12/08/08
local x,y,z,lx,ly,lz,r,s = 0,0,1,1,0,1,1
local s,damp,dr = 0.1,0.95,4.5
local dx,dy,dz = 0,0,0
local theta = 0
local phi = 0
local deg = 180/math.pi
local key2 = { }
for i = 0,200 do
key2[i] = 0
end
local shift
local i = 0
local keyframes = {}
local playing = 0
local function camera()
shift = get_shift_key_state()
--IKJL
if (key2[105] == 1) then
if (shift > 0) then
z = z + s
lz = lz + s
else
x = x + s*math.cos(theta/deg)
y = y + s*math.sin(theta/deg)
lx = lx + s*math.cos(theta/deg)
ly = ly + s*math.sin(theta/deg)
end
end
if (key2[107] == 1) then
if (shift > 0) then
z = z - s
lz = lz - s
else
x = x - s*math.cos(theta/deg)
y = y - s*math.sin(theta/deg)
lx = lx - s*math.cos(theta/deg)
ly = ly - s*math.sin(theta/deg)
end
end
if (key2[106] == 1) then
x = x + s*math.cos((theta+90)/deg)
y = y + s*math.sin((theta+90)/deg)
lx = lx + s*math.cos((theta+90)/deg)
ly = ly + s*math.sin((theta+90)/deg)
end
if (key2[108] == 1) then
x = x + s*math.cos((theta-90)/deg)
y = y + s*math.sin((theta-90)/deg)
lx = lx + s*math.cos((theta-90)/deg)
ly = ly + s*math.sin((theta-90)/deg)
end
--WSAD
if (key2[119] == 1) then
if (shift > 0) then
if (phi < -80) then
phi = phi - (phi + 89.9)/5
else
phi = phi - 2
end
else
if (r < 5*s) then
r = 0.05 + r/1.5
else
r = r - s
end
end
x = lx - r*math.cos(theta/deg)*math.cos(phi/deg)
y = ly - r*math.sin(theta/deg)*math.cos(phi/deg)
z = lz - r*math.sin(phi/deg)
end
if (key2[115] == 1) then
if (shift > 0) then
if (phi > 80) then
phi = phi - (phi - 89.9)/5
else
phi = phi + 2
end
else
r = r + s
end
x = lx - r*math.cos(theta/deg)*math.cos(phi/deg)
y = ly - r*math.sin(theta/deg)*math.cos(phi/deg)
z = lz - r*math.sin(phi/deg)
end
if (key2[97] == 1) then
theta = theta - 2
x = lx - r*math.cos(theta/deg)*math.cos(phi/deg)
y = ly - r*math.sin(theta/deg)*math.cos(phi/deg)
end
if (key2[100] == 1) then
theta = theta + 2
x = lx - r*math.cos(theta/deg)*math.cos(phi/deg)
y = ly - r*math.sin(theta/deg)*math.cos(phi/deg)
end
--QE
if (key2[113] == 1) then
if (shift > 0) then
i = 0
keyframes = {}
echo("All steps cleared")
else
if (i == 0) then
i = i + 1
keyframes[i] = {x=x,y=y,z=z,lx=lx,ly=ly,lz=lz,theta=theta,phi=phi ,frame=get_world_state().match_frame}
echo("Step: " .. i .. " saved at " .. keyframes[i].frame)
else
if (keyframes[i].frame ~= get_world_state().match_frame) then
i = i + 1
keyframes[i] = {x=x,y=y,z=z,lx=lx,ly=ly,lz=lz,theta=theta,phi=phi ,frame=get_world_state().match_frame}
echo("Step: " .. i .. " saved at " .. keyframes[i].frame)
end
end
end
end
if (key2[101] == 1) then
if(playing == 0) then
rewind_replay()
add_hook("draw2d","camtween",cameratween)
playing = 1
else
remove_hook("draw2d","camtween")
playing = 0
end
key2[101] = 0
end
--UO
if (key2[117] == 1) then
if (shift > 0) then
damp = damp + 0.001
if (damp > 0.999) then
damp = 0.999
end
else
damp = damp - 0.001
if (damp < 0.900) then
damp = 0.900
end
end
echo("Friction: " .. 1000*(1 - damp))
end
if (key2[111] == 1) then
if (shift > 0) then
dr = dr + 0.01
if (dr > 5) then
dr = 5
end
else
dr = dr - 0.01
if (dr < 4) then
dr = 4
end
end
echo("Velocity Gain: " .. 100*(5 - dr))
end

set_camera_lookat(lx, ly, lz)
set_camera_pos(x,y,z)
return 1
end
function cameratween()
a = 1
for b = 2,#keyframes do
for c = 0,(keyframes[b].frame - keyframes[a].frame) do
if(get_world_state().match_frame == (keyframes[a].frame + c)) then
dx = damp*dx + (keyframes[b].x - x)/(dr*(keyframes[b].frame - keyframes[a].frame))
dy = damp*dy + (keyframes[b].y - y)/(dr*(keyframes[b].frame - keyframes[a].frame))
dz = damp*dz + (keyframes[b].z - z)/(dr*(keyframes[b].frame - keyframes[a].frame))
x = x + dx
y = y + dy
z = z + dz
lx = keyframes[a].lx + c*(keyframes[b].lx - keyframes[a].lx)/(keyframes[b].frame - keyframes[a].frame)
ly = keyframes[a].ly + c*(keyframes[b].ly - keyframes[a].ly)/(keyframes[b].frame - keyframes[a].frame)
lz = keyframes[a].lz + c*(keyframes[b].lz - keyframes[a].lz)/(keyframes[b].frame - keyframes[a].frame)
theta = keyframes[b].theta + c*(keyframes[b].theta - keyframes[a].theta)/(keyframes[b].frame - keyframes[a].frame)
phi = keyframes[b].phi + c*(keyframes[b].phi - keyframes[a].phi)/(keyframes[b].frame - keyframes[a].frame)
end
end
a = b
end
end
local function keypress(key)
key2[key] = 1
return 1
end
local function dekeypress(key)
key2[key] = 0
if((key == 101) or ((key >= 105) and (key <= 10)) then
return 1
end
end

add_hook("camera", "fovcam", camera)
add_hook("key_down", "key", keypress)
add_hook("key_up", "dekey", dekeypress)




i donnt know to to get on my big fat toribash thingy!!
open folder \toribash\data\script
make file freecam.lua
open this file by any txt-editor
copypast fnugget's code
save/close file
launch toribash
type /ls freecam.lua
enjoy