summaryrefslogtreecommitdiff
path: root/controllerfw.lua
diff options
context:
space:
mode:
authorcheapie <no-email-for-you@example.com>2025-04-11 18:14:38 -0500
committercheapie <no-email-for-you@example.com>2025-04-11 18:24:24 -0500
commit8746da03e3ebb32ff79e5a24e1ed92534e90092a (patch)
tree530e0258d6a868e68342c33d4f82e241950763e2 /controllerfw.lua
parent46ff5fc78061554c30cfa2a3416e70f41a4437b1 (diff)
downloadcelevator-8746da03e3ebb32ff79e5a24e1ed92534e90092a.tar
celevator-8746da03e3ebb32ff79e5a24e1ed92534e90092a.tar.gz
celevator-8746da03e3ebb32ff79e5a24e1ed92534e90092a.tar.bz2
celevator-8746da03e3ebb32ff79e5a24e1ed92534e90092a.tar.xz
celevator-8746da03e3ebb32ff79e5a24e1ed92534e90092a.zip
Add extra checks to prevent and detect invalid floor tables
Diffstat (limited to 'controllerfw.lua')
-rw-r--r--controllerfw.lua20
1 files changed, 19 insertions, 1 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index 2b29db2..1850a1e 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -235,6 +235,24 @@ if mem.params and not mem.params.secoverrideusers then mem.params.secoverrideuse
if mem.params and mem.params.swingcallwhennotswing == nil then mem.params.swingcallwhennotswing = true end
if not mem.editinguser then mem.editinguser = 1 end
+if mem.params and #mem.params.floornames < 2 then
+ mem.params.floornames = {"1","2","3"}
+ mem.params.floorheights = {5,5,5}
+ mem.carstate = "bfdemand"
+ if mem.doorstate == "closed" then
+ drivecmd({
+ command = "setmaxvel",
+ maxvel = mem.params.contractspeed,
+ })
+ drivecmd({command = "resetpos"})
+ interrupt(0.1,"checkdrive")
+ mem.carmotion = true
+ juststarted = true
+ else
+ close()
+ end
+end
+
if event.type == "program" then
mem.carstate = "uninit"
mem.editingfloor = 1
@@ -344,7 +362,7 @@ elseif event.type == "ui" then
elseif event.fields.add then
table.insert(mem.params.floorheights,5)
table.insert(mem.params.floornames,tostring(#mem.params.floornames+1))
- elseif event.fields.remove then
+ elseif event.fields.remove and #mem.params.floornames > 2 then
table.remove(mem.params.floorheights,mem.editingfloor)
table.remove(mem.params.floornames,mem.editingfloor)
mem.editingfloor = math.max(1,mem.editingfloor-1)