summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2024-05-14 17:42:12 -0500
committercheapie <no-email-for-you@example.com>2024-05-14 17:42:12 -0500
commit90e7f15112f47756983e1d2013b70f78d788b3dc (patch)
tree464f8c5cd9e0a59b53ae642fb475c7028339a97e
parente8242dd09bf08dbb63d1fa477cae85376573ee4a (diff)
downloadcelevator-90e7f15112f47756983e1d2013b70f78d788b3dc.tar
celevator-90e7f15112f47756983e1d2013b70f78d788b3dc.tar.gz
celevator-90e7f15112f47756983e1d2013b70f78d788b3dc.tar.bz2
celevator-90e7f15112f47756983e1d2013b70f78d788b3dc.tar.xz
celevator-90e7f15112f47756983e1d2013b70f78d788b3dc.zip
Allow changing inspection speed
Can be set to 0.1-0.7m/s, cannot be higher than contract speed
-rw-r--r--controller.lua2
-rw-r--r--controllerfw.lua27
-rw-r--r--drive_entity.lua18
3 files changed, 30 insertions, 17 deletions
diff --git a/controller.lua b/controller.lua
index 2e47c98..365cf73 100644
--- a/controller.lua
+++ b/controller.lua
@@ -427,7 +427,7 @@ function celevator.controller.finish(pos,mem,changedinterrupts)
if drivetype then
for _,command in ipairs(mem.drive.commands) do
if command.command == "moveto" then
- celevator.drives[drivetype].moveto(drivepos,command.pos)
+ celevator.drives[drivetype].moveto(drivepos,command.pos,command.inspection)
elseif command.command == "setmaxvel" then
celevator.drives[drivetype].setmaxvel(drivepos,command.maxvel)
elseif command.command == "resetpos" then
diff --git a/controllerfw.lua b/controllerfw.lua
index cd54dff..73c352f 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -224,6 +224,7 @@ if mem.params and not mem.params.carcallsecurity then mem.params.carcallsecurity
if mem.params and not mem.params.nudgetimer then mem.params.nudgetimer = 30 end
if mem.params and not mem.params.altrecalllanding then mem.params.altrecalllanding = 2 end
if mem.params and not mem.recallto then mem.recallto = mem.params.mainlanding or 1 end
+if mem.params and not mem.params.inspectionspeed then mem.params.inspectionspeed = 0.2 end
if event.type == "program" then
mem.carstate = "uninit"
@@ -266,6 +267,7 @@ if event.type == "program" then
altrecalllanding = 2,
carcallsecurity = {},
nudgetimer = 30,
+ inspectionspeed = 0.2,
}
end
elseif event.type == "ui" then
@@ -384,6 +386,10 @@ elseif event.type == "ui" then
if altrecalllanding and altrecalllanding >= 1 and altrecalllanding <= #mem.params.floorheights then
mem.params.altrecalllanding = math.floor(altrecalllanding)
end
+ local inspectionspeed = tonumber(event.fields.inspectionspeed)
+ if inspectionspeed and inspectionspeed >= 0.1 and inspectionspeed < 0.75 and inspectionspeed <= mem.params.contractspeed then
+ mem.params.inspectionspeed = inspectionspeed
+ end
elseif event.fields.floortable then
mem.screenstate = "floortable"
elseif event.fields.cancel then
@@ -448,22 +454,24 @@ elseif event.type == "ui" then
juststarted = true
drivecmd({
command = "setmaxvel",
- maxvel = 0.2,
+ maxvel = mem.params.inspectionspeed,
})
drivecmd({
command = "moveto",
- pos = math.floor(mem.drive.status.apos)+1
+ pos = math.floor(mem.drive.status.apos)+1,
+ inspection = true,
})
elseif event.fields.inspectdown and mem.carstate == "mrinspect" and mem.doorstate == "closed" and mem.drive.status.apos-1 >= 0 then
mem.carmotion = true
juststarted = true
drivecmd({
command = "setmaxvel",
- maxvel = 0.2,
+ maxvel = mem.params.inspectionspeed,
})
drivecmd({
command = "moveto",
- pos = math.floor(mem.drive.status.apos)-1
+ pos = math.floor(mem.drive.status.apos)-1,
+ inspection = true,
})
elseif event.fields.parameters then
mem.screenstate = "parameters"
@@ -656,22 +664,24 @@ elseif event.type == "cartopbox" then
juststarted = true
drivecmd({
command = "setmaxvel",
- maxvel = 0.2,
+ maxvel = mem.params.inspectionspeed,
})
drivecmd({
command = "moveto",
- pos = math.floor(mem.drive.status.apos)+1
+ pos = math.floor(mem.drive.status.apos)+1,
+ inspection = true,
})
elseif event.control == "down" and mem.carstate == "carinspect" and mem.doorstate == "closed" and mem.drive.status.apos-1 >= 0 then
mem.carmotion = true
juststarted = true
drivecmd({
command = "setmaxvel",
- maxvel = 0.2,
+ maxvel = mem.params.inspectionspeed,
})
drivecmd({
command = "moveto",
- pos = math.floor(mem.drive.status.apos)-1
+ pos = math.floor(mem.drive.status.apos)-1,
+ inspection = true,
})
end
elseif event.type == "dispatchermsg" then
@@ -1335,6 +1345,7 @@ elseif mem.screenstate == "parameters" then
if mem.params.groupmode == "simplex" then fs("button[8,10;3,1;floortable;Edit Floor Table]") end
fs(string.format("field[1,3;3,1;doortimer;Door Dwell Timer;%0.1f]",mem.params.doortimer))
fs(string.format("field[1,5;3,1;contractspeed;Contract Speed (m/s);%0.1f]",mem.params.contractspeed))
+ fs(string.format("field[4.5,5;3,1;inspectionspeed;Inspection Speed (m/s);%0.1f]",mem.params.inspectionspeed))
fs(string.format("field[1,7;3,1;mainlanding;Main Egress Landing;%d]",mem.params.mainlanding or 1))
fs(string.format("field[4.5,3;3,1;nudgetimer;Nudging Timer (0 = None);%0.1f]",mem.params.nudgetimer))
fs(string.format("field[4.5,7;3,1;altrecalllanding;Alternate Recall Landing;%d]",mem.params.altrecalllanding))
diff --git a/drive_entity.lua b/drive_entity.lua
index 728aa47..f3025f6 100644
--- a/drive_entity.lua
+++ b/drive_entity.lua
@@ -373,6 +373,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 inspection = meta:get_int("inspection") == 1
local origin = minetest.string_to_pos(meta:get_string("origin"))
if not origin then
minetest.log("error","[celevator] [entity drive] Invalid origin for drive at "..minetest.pos_to_string(pos))
@@ -383,7 +384,7 @@ function celevator.drives.entity.step(dtime)
if state == "start" then
if math.abs(dpos-startpos) > 0.1 then
sound = true
- if maxvel > 0.2 then
+ if not inspection then
accelsound(pos)
else
motorsound(pos,"slow")
@@ -443,15 +444,15 @@ function celevator.drives.entity.step(dtime)
end
apos = math.floor(apos+0.5)
minetest.after(0.25,celevator.drives.entity.updatecopformspec,pos)
- elseif dremain < 0.2 then
+ elseif dremain < 0.2 and not inspection then
vel = 0.2
- elseif dremain < 2*maxvel and dremain < dmoved then
+ elseif dremain < 2*maxvel and dremain < dmoved and not inspection then
vel = math.min(dremain,maxvel)
if celevator.drives.entity.movementsoundstate[hash] == "fast" or celevator.drives.entity.movementsoundstate[hash] == "accel" then
decelsound(pos)
carsound(pos,"decel",maxvel)
end
- elseif dmoved+0.1 > maxvel then
+ elseif dmoved+0.1 > maxvel or inspection then
vel = maxvel
else
vel = dmoved+0.1
@@ -486,14 +487,14 @@ function celevator.drives.entity.step(dtime)
celevator.car.spawncar(vector.round(vector.add(origin,vector.new(0,apos,0))),minetest.dir_to_yaw(minetest.fourdir_to_dir(carparam2)),carid)
apos = math.floor(apos+0.5)
minetest.after(0.25,celevator.drives.entity.updatecopformspec,pos)
- elseif dremain < 0.2 then
+ elseif dremain < 0.2 and not inspection then
vel = 0.2
- elseif dremain < 2*maxvel and dremain < dmoved then
+ elseif dremain < 2*maxvel and dremain < dmoved and not inspection then
vel = math.min(dremain,maxvel)
if celevator.drives.entity.movementsoundstate[hash] == "fast" or celevator.drives.entity.movementsoundstate[hash] == "accel" then
decelsound(pos)
end
- elseif dmoved+0.1 > maxvel then
+ elseif dmoved+0.1 > maxvel or inspection then
vel = maxvel
else
vel = dmoved+0.1
@@ -520,7 +521,7 @@ end
minetest.register_globalstep(celevator.drives.entity.step)
-function celevator.drives.entity.moveto(pos,target)
+function celevator.drives.entity.moveto(pos,target,inspection)
local meta = celevator.get_meta(pos)
meta:mark_as_private({"apos","dpos","vel","maxvel","state","startpos","doorstate"})
local carid = celevator.get_meta(pos):get_int("carid")
@@ -550,6 +551,7 @@ function celevator.drives.entity.moveto(pos,target)
meta:set_string("dpos",tostring(target))
if meta:get_string("state") == "stopped" then
meta:set_string("state","start")
+ meta:set_int("inspection",inspection and 1 or 0)
meta:set_string("startpos",meta:get_string("apos"))
local hash = minetest.hash_node_position(pos)
local entitydrives_running = minetest.deserialize(celevator.storage:get_string("entitydrives_running")) or {}