diff options
author | Beha <shacknetisp@mail.com> | 2021-06-14 12:45:33 -0400 |
---|---|---|
committer | Beha <shacknetisp@mail.com> | 2021-06-14 12:45:33 -0400 |
commit | d9df0bf57269a24cd608b63b126d21832f6d476f (patch) | |
tree | b11621546460a9d717db1d190db39cd1babe9be0 | |
parent | a0f873e26e280b41c2b002e73b23aee606d93b3a (diff) | |
parent | 575bc0c119f9aa61c5e24411ad46701c52e17a63 (diff) | |
download | elevator-d9df0bf57269a24cd608b63b126d21832f6d476f.tar.gz elevator-d9df0bf57269a24cd608b63b126d21832f6d476f.tar.bz2 elevator-d9df0bf57269a24cd608b63b126d21832f6d476f.zip |
Merge branch 'master' of https://github.com/gpcf/elevator into gpcf-master
-rw-r--r-- | .luacheckrc | 2 | ||||
-rw-r--r-- | crafts.lua | 2 | ||||
-rw-r--r-- | helpers.lua | 2 | ||||
-rw-r--r-- | init.lua | 20 |
4 files changed, 21 insertions, 5 deletions
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", } @@ -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) @@ -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<elevator.SLOW_DIST) then + speed = elevator.SLOW_SPEED + + end + -- Set the speed. - obj:set_velocity({x=0, y=elevator.SPEED*obj:get_luaentity().vmult, z=0}) + obj:set_velocity({x=0, y=speed*obj:get_luaentity().vmult, z=0}) obj:set_acceleration({x=0, y=elevator.ACCEL*obj:get_luaentity().vmult, z=0}) + -- Set the tables. elevator.boxes[motorhash] = obj elevator.riding[sender:get_player_name()] = { @@ -137,7 +148,6 @@ elevator.build_motor = function(hash) end elevator.unbuild = function(pos, add) - local need_saving = false local p = table.copy(pos) p.y = p.y - 1 -- Loop down through the network, set any elevators below this to the off position. @@ -304,6 +314,10 @@ local box_entity = { for y=self.lastpos.y,pos.y,((self.lastpos.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 |