diff --git a/init.lua b/init.lua index ecd045b..0abbfd7 100644 --- a/init.lua +++ b/init.lua @@ -1,33 +1,37 @@ --[[ -Copyright 2016 - Auke Kok +Copyright 2017 - Elijah Duffy License: - - Code: WTFPL + - Code: MIT - Models and textures: CC-BY-SA-3.0 -Usage: /give camera:camera +Usage: /camera - left click a camera item to start recording. While recording: + Execute command to start recording. While recording: - use up/down to accelerate/decelerate - use jump to brake - use crouch to stop recording - right click a camera item to play back a recording. While playing back: + Use /camera playback to play back a recording. While playing back: - use crouch to stop playing back --]] local recordings = {} +-- camera def local camera = { description = "Camera", + visual = "wielditem", + textures = {}, physical = false, - visual = "mesh", - mesh = "camera.obj", - textures = { "camera_camera.png" }, - collisionbox = {-0.5,-0.5,-0.5, 0.5,0.5,0.5}, + is_visible = false, + collide_with_objects = false, + collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, + physical = false, + visual = "cube", driver = nil, mode = 0, velocity = {x=0, y=0, z=0}, @@ -42,6 +46,8 @@ local camera = { end, } + +-- on step function camera:on_step(dtime) if not self.driver then self.object:remove() @@ -64,7 +70,7 @@ function camera:on_step(dtime) -- always modify yaw/pitch to match player self.object:set_look_pitch(self.driver:get_look_pitch()) self.object:set_look_yaw(self.driver:get_look_yaw()) - + -- accel/decel/stop local ctrl = self.driver:get_player_control() local speed = vector.distance(vector.new(), vel) @@ -109,26 +115,33 @@ function camera:on_step(dtime) end end +-- Register entity. minetest.register_entity("camera:camera", camera) -minetest.register_craftitem("camera:camera", { - description = "Camera", - inventory_image = "camera_item.png", - on_use = function(itemstack, player, pointed_thing) - local object = minetest.add_entity(player:getpos(), "camera:camera") - object:get_luaentity():init(player, 0) - object:setyaw(player:get_look_yaw()) - player:set_attach(object, "", {x=0,y=10,z=0}, {x=0,y=0,z=0}) - end, - on_secondary_use = function(itemstack, player, pointed_thing) - if not recordings[player:get_player_name()] then - return +-- Register chatcommand. +minetest.register_chatcommand("camera", { + description = "Manipulate recording", + params = "