From bec98bd9cbe3b5efc28ee08959ff81b0c4c4fcf8 Mon Sep 17 00:00:00 2001 From: cheapie Date: Sat, 15 Mar 2025 13:24:02 -0500 Subject: Prevent releveling in inspection --- drive_entity.lua | 7 +++++-- 1 file 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") -- cgit v1.2.3