summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcheapie <cheapiephp@gmail.com>2026-07-10 12:24:34 -0500
committercheapie <cheapiephp@gmail.com>2026-07-10 12:24:34 -0500
commit8702321ec72972a1e0ad2b9a8d3dcd4b515d9658 (patch)
tree23a8d40a1bd09a4d3a21dceee3f81231229ad255
parent0dfd371e1ca3d5b73fb1ea0b41adfccd8db01aef (diff)
downloadcelevator-8702321ec72972a1e0ad2b9a8d3dcd4b515d9658.tar
celevator-8702321ec72972a1e0ad2b9a8d3dcd4b515d9658.tar.gz
celevator-8702321ec72972a1e0ad2b9a8d3dcd4b515d9658.tar.bz2
celevator-8702321ec72972a1e0ad2b9a8d3dcd4b515d9658.tar.xz
celevator-8702321ec72972a1e0ad2b9a8d3dcd4b515d9658.zip
Improve floor table editing
-rw-r--r--controllerfw.lua5
-rw-r--r--dispatcherfw.lua11
2 files changed, 10 insertions, 6 deletions
diff --git a/controllerfw.lua b/controllerfw.lua
index 73c6206..9962c52 100644
--- a/controllerfw.lua
+++ b/controllerfw.lua
@@ -369,8 +369,9 @@ elseif event.type == "ui" then
elseif event.fields.edit then
mem.screenstate = (mem.screenstate == "oobe_floortable" and "oobe_floortable_edit" or "floortable_edit")
elseif event.fields.add and #mem.params.floornames < maxfloors then
- table.insert(mem.params.floorheights,5)
- table.insert(mem.params.floornames,tostring(#mem.params.floornames+1))
+ table.insert(mem.params.floorheights,mem.params.floorheights[#mem.params.floorheights] or 5)
+ local previous = tonumber(mem.params.floornames[#mem.params.floornames]) or #mem.params.floornames
+ table.insert(mem.params.floornames,tostring(math.floor(previous)+1))
elseif event.fields.remove and #mem.params.floornames > 2 then
table.remove(mem.params.floorheights,mem.editingfloor)
table.remove(mem.params.floornames,mem.editingfloor)
diff --git a/dispatcherfw.lua b/dispatcherfw.lua
index 02b540e..250a4d1 100644
--- a/dispatcherfw.lua
+++ b/dispatcherfw.lua
@@ -362,6 +362,7 @@ elseif event.type == "ui" then
end
elseif mem.screenstate == "oobe_floortable" or mem.screenstate == "floortable" then
local exp = event.fields.floor and core.explode_textlist_event(event.fields.floor) or {}
+ local maxfloors = tonumber(core.settings:get("celevator.max_landings")) or 100
if event.fields.back then
mem.screenstate = "oobe_welcome"
elseif event.fields.next then
@@ -390,9 +391,10 @@ elseif event.type == "ui" then
mem.screenstate = (mem.screenstate == "oobe_floortable" and "oobe_floortable_edit" or "floortable_edit")
elseif event.fields.edit then
mem.screenstate = (mem.screenstate == "oobe_floortable" and "oobe_floortable_edit" or "floortable_edit")
- elseif event.fields.add then
- table.insert(mem.params.floorheights,5)
- table.insert(mem.params.floornames,tostring(#mem.params.floornames+1))
+ elseif event.fields.add and #mem.params.floornames < maxfloors then
+ table.insert(mem.params.floorheights,mem.params.floorheights[#mem.params.floorheights] or 5)
+ local previous = tonumber(mem.params.floornames[#mem.params.floornames]) or #mem.params.floornames
+ table.insert(mem.params.floornames,tostring(math.floor(previous)+1))
elseif event.fields.remove and #mem.params.floornames > 2 then
table.remove(mem.params.floorheights,mem.editingfloor)
table.remove(mem.params.floornames,mem.editingfloor)
@@ -961,7 +963,8 @@ elseif mem.screenstate == "oobe_floortable" or mem.screenstate == "floortable" t
fs(core.formspec_escape(floortext)..(i==1 and "" or ","))
end
fs(";"..tostring(#mem.params.floornames-mem.editingfloor+1)..";false]")
- if #mem.params.floornames < 100 then fs("button[8,2;2,1;add;"..S("New Floor").."]") end
+ local maxfloors = tonumber(core.settings:get("celevator.max_landings")) or 100
+ if #mem.params.floornames < maxfloors then fs("button[8,2;2,1;add;"..S("New Floor").."]") end
fs("button[8,3.5;2,1;edit;"..S("Edit Floor").."]")
if #mem.params.floornames > 2 then fs("button[8,5;2,1;remove;"..S("Remove Floor").."]") end
if mem.editingfloor < #mem.params.floornames then fs("button[8,6.5;2,1;moveup;"..S("Move Up").."]") end