diff --git a/mods/boat/init.lua b/mods/boat/init.lua index 87ca1ec..4dcc1f8 100644 --- a/mods/boat/init.lua +++ b/mods/boat/init.lua @@ -12,8 +12,7 @@ minetest.register_entity("boat:boat", { is_visible = true, }, - driver = "", - + rider = "", get_staticdata = function(self) @@ -35,9 +34,65 @@ minetest.register_entity("boat:boat", { self.object:set_velocity({x = 0, y = 0, z = 0}) self.object:set_acceleration({x = 0, y = -9.81, z = 0}) end, - + + + --players push boat + push = function(self) + local pos = self.object:getpos() + for _,object in ipairs(minetest.get_objects_inside_radius(pos, 1)) do + if object:is_player() and object:get_player_name() ~= self.rider then + local player_pos = object:getpos() + pos.y = 0 + player_pos.y = 0 + + local currentvel = self.object:getvelocity() + + local vel = vector.subtract(pos, player_pos) + vel = vector.normalize(vel) + local distance = vector.distance(pos,player_pos) + + distance = (1-distance)*10 + + vel = vector.multiply(vel,distance) + + + local acceleration = vector.new(vel.x-currentvel.x,0,vel.z-currentvel.z) + + self.object:add_velocity(acceleration) + end + end + end, + + --makes the boat float + float = function(self) + local pos = self.object:getpos() + local node = minetest.get_node(pos).name + local vel = self.object:getvelocity() + local goal = 1 + local acceleration = vector.new(0,goal-vel.y,0) + self.swimming = false + + if node == "main:water" or node =="main:waterflow" then + print("float man") + self.swimming = true + self.object:add_velocity(acceleration) + end + end, + + + --slows the boat down + slowdown = function(self) + local vel = self.object:getvelocity() + local deceleration = vector.multiply(vel, -0.01) + self.object:add_velocity(deceleration) + + + + end, on_step = function(self, dtime) - + self.push(self) + self.float(self) + self.slowdown(self) end, }) diff --git a/mods/mob/init.lua b/mods/mob/init.lua index 00c4e7b..3e8f035 100644 --- a/mods/mob/init.lua +++ b/mods/mob/init.lua @@ -158,7 +158,7 @@ minetest.register_entity("mob:pig", { local acceleration = vector.new(0,goal-vel.y,0) self.swimming = false - if node == ("main:water" or "main:water_flow") then + if node == ("main:water" or "main:waterflow") then self.swimming = true self.object:add_velocity(acceleration) end diff --git a/todo.txt b/todo.txt index c871058..3acddf3 100644 --- a/todo.txt +++ b/todo.txt @@ -23,6 +23,7 @@ --ladders - only placeable on walls --eating animation - particles? - entity? boats +redstone - make nodes drop multiple items individually crafting bench fishing bows