Allow changing inspection speed
Can be set to 0.1-0.7m/s, cannot be higher than contract speed
This commit is contained in:
parent
e8242dd09b
commit
90e7f15112
@ -427,7 +427,7 @@ function celevator.controller.finish(pos,mem,changedinterrupts)
|
|||||||
if drivetype then
|
if drivetype then
|
||||||
for _,command in ipairs(mem.drive.commands) do
|
for _,command in ipairs(mem.drive.commands) do
|
||||||
if command.command == "moveto" then
|
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
|
elseif command.command == "setmaxvel" then
|
||||||
celevator.drives[drivetype].setmaxvel(drivepos,command.maxvel)
|
celevator.drives[drivetype].setmaxvel(drivepos,command.maxvel)
|
||||||
elseif command.command == "resetpos" then
|
elseif command.command == "resetpos" then
|
||||||
|
@ -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.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.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.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
|
if event.type == "program" then
|
||||||
mem.carstate = "uninit"
|
mem.carstate = "uninit"
|
||||||
@ -266,6 +267,7 @@ if event.type == "program" then
|
|||||||
altrecalllanding = 2,
|
altrecalllanding = 2,
|
||||||
carcallsecurity = {},
|
carcallsecurity = {},
|
||||||
nudgetimer = 30,
|
nudgetimer = 30,
|
||||||
|
inspectionspeed = 0.2,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
elseif event.type == "ui" then
|
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
|
if altrecalllanding and altrecalllanding >= 1 and altrecalllanding <= #mem.params.floorheights then
|
||||||
mem.params.altrecalllanding = math.floor(altrecalllanding)
|
mem.params.altrecalllanding = math.floor(altrecalllanding)
|
||||||
end
|
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
|
elseif event.fields.floortable then
|
||||||
mem.screenstate = "floortable"
|
mem.screenstate = "floortable"
|
||||||
elseif event.fields.cancel then
|
elseif event.fields.cancel then
|
||||||
@ -448,22 +454,24 @@ elseif event.type == "ui" then
|
|||||||
juststarted = true
|
juststarted = true
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "setmaxvel",
|
command = "setmaxvel",
|
||||||
maxvel = 0.2,
|
maxvel = mem.params.inspectionspeed,
|
||||||
})
|
})
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "moveto",
|
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
|
elseif event.fields.inspectdown and mem.carstate == "mrinspect" and mem.doorstate == "closed" and mem.drive.status.apos-1 >= 0 then
|
||||||
mem.carmotion = true
|
mem.carmotion = true
|
||||||
juststarted = true
|
juststarted = true
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "setmaxvel",
|
command = "setmaxvel",
|
||||||
maxvel = 0.2,
|
maxvel = mem.params.inspectionspeed,
|
||||||
})
|
})
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "moveto",
|
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
|
elseif event.fields.parameters then
|
||||||
mem.screenstate = "parameters"
|
mem.screenstate = "parameters"
|
||||||
@ -656,22 +664,24 @@ elseif event.type == "cartopbox" then
|
|||||||
juststarted = true
|
juststarted = true
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "setmaxvel",
|
command = "setmaxvel",
|
||||||
maxvel = 0.2,
|
maxvel = mem.params.inspectionspeed,
|
||||||
})
|
})
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "moveto",
|
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
|
elseif event.control == "down" and mem.carstate == "carinspect" and mem.doorstate == "closed" and mem.drive.status.apos-1 >= 0 then
|
||||||
mem.carmotion = true
|
mem.carmotion = true
|
||||||
juststarted = true
|
juststarted = true
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "setmaxvel",
|
command = "setmaxvel",
|
||||||
maxvel = 0.2,
|
maxvel = mem.params.inspectionspeed,
|
||||||
})
|
})
|
||||||
drivecmd({
|
drivecmd({
|
||||||
command = "moveto",
|
command = "moveto",
|
||||||
pos = math.floor(mem.drive.status.apos)-1
|
pos = math.floor(mem.drive.status.apos)-1,
|
||||||
|
inspection = true,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
elseif event.type == "dispatchermsg" then
|
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
|
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,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[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[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,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))
|
fs(string.format("field[4.5,7;3,1;altrecalllanding;Alternate Recall Landing;%d]",mem.params.altrecalllanding))
|
||||||
|
@ -373,6 +373,7 @@ function celevator.drives.entity.step(dtime)
|
|||||||
local dpos = tonumber(meta:get_string("dpos")) or 0
|
local dpos = tonumber(meta:get_string("dpos")) or 0
|
||||||
local maxvel = tonumber(meta:get_string("maxvel")) or 0.2
|
local maxvel = tonumber(meta:get_string("maxvel")) or 0.2
|
||||||
local startpos = tonumber(meta:get_string("startpos")) or 0
|
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"))
|
local origin = minetest.string_to_pos(meta:get_string("origin"))
|
||||||
if not origin then
|
if not origin then
|
||||||
minetest.log("error","[celevator] [entity drive] Invalid origin for drive at "..minetest.pos_to_string(pos))
|
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 state == "start" then
|
||||||
if math.abs(dpos-startpos) > 0.1 then
|
if math.abs(dpos-startpos) > 0.1 then
|
||||||
sound = true
|
sound = true
|
||||||
if maxvel > 0.2 then
|
if not inspection then
|
||||||
accelsound(pos)
|
accelsound(pos)
|
||||||
else
|
else
|
||||||
motorsound(pos,"slow")
|
motorsound(pos,"slow")
|
||||||
@ -443,15 +444,15 @@ function celevator.drives.entity.step(dtime)
|
|||||||
end
|
end
|
||||||
apos = math.floor(apos+0.5)
|
apos = math.floor(apos+0.5)
|
||||||
minetest.after(0.25,celevator.drives.entity.updatecopformspec,pos)
|
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
|
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)
|
vel = math.min(dremain,maxvel)
|
||||||
if celevator.drives.entity.movementsoundstate[hash] == "fast" or celevator.drives.entity.movementsoundstate[hash] == "accel" then
|
if celevator.drives.entity.movementsoundstate[hash] == "fast" or celevator.drives.entity.movementsoundstate[hash] == "accel" then
|
||||||
decelsound(pos)
|
decelsound(pos)
|
||||||
carsound(pos,"decel",maxvel)
|
carsound(pos,"decel",maxvel)
|
||||||
end
|
end
|
||||||
elseif dmoved+0.1 > maxvel then
|
elseif dmoved+0.1 > maxvel or inspection then
|
||||||
vel = maxvel
|
vel = maxvel
|
||||||
else
|
else
|
||||||
vel = dmoved+0.1
|
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)
|
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)
|
apos = math.floor(apos+0.5)
|
||||||
minetest.after(0.25,celevator.drives.entity.updatecopformspec,pos)
|
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
|
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)
|
vel = math.min(dremain,maxvel)
|
||||||
if celevator.drives.entity.movementsoundstate[hash] == "fast" or celevator.drives.entity.movementsoundstate[hash] == "accel" then
|
if celevator.drives.entity.movementsoundstate[hash] == "fast" or celevator.drives.entity.movementsoundstate[hash] == "accel" then
|
||||||
decelsound(pos)
|
decelsound(pos)
|
||||||
end
|
end
|
||||||
elseif dmoved+0.1 > maxvel then
|
elseif dmoved+0.1 > maxvel or inspection then
|
||||||
vel = maxvel
|
vel = maxvel
|
||||||
else
|
else
|
||||||
vel = dmoved+0.1
|
vel = dmoved+0.1
|
||||||
@ -520,7 +521,7 @@ end
|
|||||||
|
|
||||||
minetest.register_globalstep(celevator.drives.entity.step)
|
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)
|
local meta = celevator.get_meta(pos)
|
||||||
meta:mark_as_private({"apos","dpos","vel","maxvel","state","startpos","doorstate"})
|
meta:mark_as_private({"apos","dpos","vel","maxvel","state","startpos","doorstate"})
|
||||||
local carid = celevator.get_meta(pos):get_int("carid")
|
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))
|
meta:set_string("dpos",tostring(target))
|
||||||
if meta:get_string("state") == "stopped" then
|
if meta:get_string("state") == "stopped" then
|
||||||
meta:set_string("state","start")
|
meta:set_string("state","start")
|
||||||
|
meta:set_int("inspection",inspection and 1 or 0)
|
||||||
meta:set_string("startpos",meta:get_string("apos"))
|
meta:set_string("startpos",meta:get_string("apos"))
|
||||||
local hash = minetest.hash_node_position(pos)
|
local hash = minetest.hash_node_position(pos)
|
||||||
local entitydrives_running = minetest.deserialize(celevator.storage:get_string("entitydrives_running")) or {}
|
local entitydrives_running = minetest.deserialize(celevator.storage:get_string("entitydrives_running")) or {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user