forked from minetest-mods/camera
Add /camera speed_factor <speed> command for customized speed at starting record.
This commit is contained in:
parent
ba7f352909
commit
71924a4d07
24
init.lua
24
init.lua
@ -91,7 +91,7 @@ local camera = {
|
|||||||
|
|
||||||
local player_look_dir = nil
|
local player_look_dir = nil
|
||||||
local target_look_position = nil
|
local target_look_position = nil
|
||||||
--local target_look_position = {x=-265, y=9.5, z=-126}
|
local speed_factor = 0.1 -- default speed factor
|
||||||
|
|
||||||
-- [event] On step
|
-- [event] On step
|
||||||
function camera:on_step(dtime)
|
function camera:on_step(dtime)
|
||||||
@ -120,10 +120,8 @@ function camera:on_step(dtime)
|
|||||||
adj = vec_pos.z
|
adj = vec_pos.z
|
||||||
end
|
end
|
||||||
|
|
||||||
if adj ~= 0 then
|
if adj > 0 then opp = opp * -1 end
|
||||||
if adj > 0 then opp = opp * -1 end
|
self.driver:set_look_pitch(opp/adj)
|
||||||
self.driver:set_look_pitch(opp/adj)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Yaw
|
-- Yaw
|
||||||
opp = vec_pos.x
|
opp = vec_pos.x
|
||||||
@ -208,12 +206,12 @@ function camera:on_step(dtime)
|
|||||||
|
|
||||||
-- if up, accelerate forward
|
-- if up, accelerate forward
|
||||||
if ctrl.up then
|
if ctrl.up then
|
||||||
speed = math.min(speed + 0.1, 20)
|
speed = math.min(speed + speed_factor, 20)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if down, accelerate backward
|
-- if down, accelerate backward
|
||||||
if ctrl.down then
|
if ctrl.down then
|
||||||
speed = math.max(speed - 0.1, -20)
|
speed = math.max(speed - speed_factor, -20)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if jump, brake
|
-- if jump, brake
|
||||||
@ -326,6 +324,18 @@ minetest.register_chatcommand("camera", {
|
|||||||
else
|
else
|
||||||
return false, "Missing coords (/camera look_target <x,y,z>)"
|
return false, "Missing coords (/camera look_target <x,y,z>)"
|
||||||
end
|
end
|
||||||
|
elseif param1 == "speed" then
|
||||||
|
if param2 and param2 ~= "" then
|
||||||
|
local speed = tonumber(param2)
|
||||||
|
if speed then
|
||||||
|
speed_factor = 1/speed
|
||||||
|
return true, "Speed factor fixed to "..speed_factor
|
||||||
|
else
|
||||||
|
return false, "Invalid speed factor (/camera speed <number>)"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false, "Missing speed parameter (/camera speed <number>)"
|
||||||
|
end
|
||||||
else -- else, begin recording
|
else -- else, begin recording
|
||||||
player_look_dir = player:get_look_dir()
|
player_look_dir = player:get_look_dir()
|
||||||
local object = minetest.add_entity(player:getpos(), "camera:camera")
|
local object = minetest.add_entity(player:getpos(), "camera:camera")
|
||||||
|
Loading…
Reference in New Issue
Block a user