summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2025-03-15 13:24:02 -0500
committercheapie <no-email-for-you@example.com>2025-03-15 13:24:02 -0500
commitbec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8 (patch)
tree01a1afcdef1907aee0de9e9afbc163f85680ada8
parent8ae23dd41a29d7a4d59487fcb30baa20781dfc8c (diff)
downloadcelevator-bec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8.tar
celevator-bec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8.tar.gz
celevator-bec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8.tar.bz2
celevator-bec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8.tar.xz
celevator-bec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8.zip
Prevent releveling in inspection
-rw-r--r--drive_entity.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/drive_entity.lua b/drive_entity.lua
index 8c1d69a..cf823c5 100644
--- a/drive_entity.lua
+++ b/drive_entity.lua
@@ -374,6 +374,7 @@ function celevator.drives.entity.step(dtime)
local dpos = tonumber(meta:get_string("dpos")) or 0
local maxvel = tonumber(meta:get_string("maxvel")) or 0.2
local startpos = tonumber(meta:get_string("startpos")) or 0
+ local oldvel = tonumber(meta:get_string("vel")) or 0
local inspection = meta:get_int("inspection") == 1
local origin = minetest.string_to_pos(meta:get_string("origin"))
if not origin then
@@ -436,7 +437,8 @@ function celevator.drives.entity.step(dtime)
local dremain = math.abs(dpos-apos)
local dmoved = math.abs(apos-startpos)
local vel
- if dremain < 0.01 then
+ local relevel = (dpos < apos and oldvel > 0) or (dpos > apos and oldvel < 0)
+ if dremain < 0.01 or (inspection and relevel) then
vel = 0
meta:set_string("state","stopped")
motorsound(pos,"idle")
@@ -484,7 +486,8 @@ function celevator.drives.entity.step(dtime)
local dremain = math.abs(dpos-apos)
local dmoved = math.abs(apos-startpos)
local vel
- if dremain < 0.01 then
+ local relevel = (dpos < apos and oldvel > 0) or (dpos > apos and oldvel < 0)
+ if dremain < 0.01 or (relevel and inspection) then
vel = 0
meta:set_string("state","stopped")
motorsound(pos,"idle")