aboutsummaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua25
1 files changed, 12 insertions, 13 deletions
diff --git a/init.lua b/init.lua
index 5087d72..97ecf80 100644
--- a/init.lua
+++ b/init.lua
@@ -5,13 +5,13 @@ local armor_path = minetest.get_modpath("3d_armor")
-- contains .motors loaded from mod storage
-- runtime variables and api functions
elevator = {
- SPEED = minetest.settings:get("elevator_speed") or 10, -- Initial speed of a box.
- ACCEL = minetest.settings:get("elevator_accel") or 0.1, -- Acceleration of a box.
+ SPEED = tonumber(minetest.settings:get("elevator_speed")) or 10, -- Initial speed of a box.
+ ACCEL = tonumber(minetest.settings:get("elevator_accel")) or 0.1, -- Acceleration of a box.
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,
+ PTIMEOUT = tonumber(minetest.settings:get("elevator_time")) or 120, -- Maximum time a box can go without players nearby.
+ SLOW_DIST = tonumber(minetest.settings:get("elevator_slow_dist")) or 16,
+ SLOW_SPEED_FACTOR = tonumber(minetest.settings:get("elevator_slow_speed_factor")) or 0.11,
boxes = {}, -- Elevator boxes in action.
lastboxes = {}, -- Player near box timeout.
riding = {}, -- Players riding boxes.
@@ -51,13 +51,12 @@ 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)
+ -- 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
-
+ if delta_y < elevator.SLOW_DIST then
+ speed = elevator.SPEED * elevator.SLOW_SPEED_FACTOR
end
-- Set the speed.
@@ -314,9 +313,9 @@ 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 vector.distance(p,self.target) < elevator.SLOW_DIST then
+ self.object:set_velocity({x=0, y=elevator.SPEED*elevator.SLOW_SPEED_FACTOR*self.vmult, z=0})
+ end
if node.name == "elevator:shaft" then
-- Nothing, just continue on our way.