diff --git a/.luacheckrc b/.luacheckrc index db7f279..67f13ed 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -15,10 +15,12 @@ read_globals = { -- Minetest "minetest", + "core", "vector", "VoxelManip", -- deps "default", "screwdriver", "farming", "armor", + "mcl_core", "mcl_sounds", } diff --git a/crafts.lua b/crafts.lua index 412d020..e78bd48 100644 --- a/crafts.lua +++ b/crafts.lua @@ -82,7 +82,7 @@ elseif technic_path and chains_path then {"chains:chain", "default:diamond", "chains:chain"} }, }) -elseif technic_path and farming and farming.mod and farming.mod == "redo" then +elseif technic_path and farming and farming.mod and ( farming.mod == "redo" or farming.mod == "undo" ) then -- add alternative recipe with hemp rope minetest.register_craft({ output = "elevator:elevator_off", diff --git a/helpers.lua b/helpers.lua index 45816f1..5215c1a 100644 --- a/helpers.lua +++ b/helpers.lua @@ -13,7 +13,7 @@ elevator.teleport_player_from_elevator = function(player) if node.name == "elevator:elevator_on" then local front = vector.subtract(pos, minetest.facedir_to_dir(node.param2)) local front_above = vector.add(front, {x=0, y=1, z=0}) - local front_below = vector.subtract(front, {x=0, y=1, z=0}) + -- local front_below = vector.subtract(front, {x=0, y=1, z=0}) -- If the front isn't solid, it's ok to teleport the player. if not solid(front) and not solid(front_above) then player:set_pos(front) diff --git a/init.lua b/init.lua index fdd8d92..5087d72 100644 --- a/init.lua +++ b/init.lua @@ -10,7 +10,8 @@ elevator = { VISUAL_INCREASE = 1.75, VERSION = 8, -- Elevator interface/database version. PTIMEOUT = minetest.settings:get("elevator_time") or 120, -- Maximum time a box can go without players nearby. - + SLOW_DIST = 16, + SLOW_SPEED = 1.75, boxes = {}, -- Elevator boxes in action. lastboxes = {}, -- Player near box timeout. riding = {}, -- Players riding boxes. @@ -50,9 +51,19 @@ elevator.create_box = function(motorhash, pos, target, sender) obj:get_luaentity().target = target obj:get_luaentity().halfway = {x=pos.x, y=(pos.y+target.y)/2, z=pos.z} obj:get_luaentity().vmult = (target.y < pos.y) and -1 or 1 + -- FIX for "overshooting" + local delta_y = math.abs(pos.y-target.y) + + local speed = elevator.SPEED + if (delta_y pos.y) and -0.3 or 0.3) do local p = vector.round({x=pos.x, y=y, z=pos.z}) local node = get_node(p) + if vector.distance(p,self.target) < elevator.SLOW_DIST then + self.object:set_velocity({x=0, y=elevator.SLOW_SPEED*self.vmult, z=0}) + end + if node.name == "elevator:shaft" then -- Nothing, just continue on our way. elseif node.name == "elevator:elevator_on" or node.name == "elevator:elevator_off" then