diff options
Diffstat (limited to 'controllerfw.lua')
-rw-r--r-- | controllerfw.lua | 51 |
1 files changed, 44 insertions, 7 deletions
diff --git a/controllerfw.lua b/controllerfw.lua index 5abb165..1850a1e 100644 --- a/controllerfw.lua +++ b/controllerfw.lua @@ -97,7 +97,7 @@ local function getpos(pioffset) ret = ret+v if ret > searchpos then return k end end - return mem.params.floorheights[#mem.params.floorheights] + return #mem.params.floorheights end local function gettarget(floor) @@ -232,8 +232,27 @@ if mem.params and not mem.recallto then mem.recallto = mem.params.mainlanding or if mem.params and not mem.params.inspectionspeed then mem.params.inspectionspeed = 0.2 end if mem.params and not mem.params.indepunlock then mem.params.indepunlock = {} end if mem.params and not mem.params.secoverrideusers then mem.params.secoverrideusers = {} end +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 @@ -279,6 +298,7 @@ if event.type == "program" then inspectionspeed = 0.2, indepunlock = {}, secoverrideusers = {}, + swingcallwhennotswing = true, } end elseif event.type == "ui" then @@ -342,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) @@ -508,6 +528,9 @@ elseif event.type == "ui" then if event.fields.indepunlock then mem.params.indepunlock[mem.editingfloor] = (event.fields.indepunlock == "true") end + if event.fields.swingcallwhennotswing then + mem.params.swingcallwhennotswing = (event.fields.swingcallwhennotswing == "true") + end if event.fields.save then mem.screenstate = "parameters" elseif event.fields.floor then @@ -585,7 +608,7 @@ elseif event.iid == "closed" and (mem.doorstate == "closing" or mem.doorstate == end elseif event.type == "callbutton" and (mem.carstate == "normal" or mem.carstate == "swing") then if mem.doorstate == "closed" or mem.direction ~= event.dir or getpos() ~= event.landing then - if mem.params.groupmode == "group" then + if mem.params.groupmode == "group" and not (mem.carstate == "normal" and not mem.params.swingcallwhennotswing) then if event.dir == "up" and event.landing >= 1 and event.landing < #mem.params.floornames then mem.swingupcalls[event.landing] = true elseif event.dir == "down" and event.landing > 1 and event.landing <= #mem.params.floornames then @@ -755,6 +778,12 @@ elseif event.type == "cartopbox" then }) end elseif event.type == "dispatchermsg" then + local swingstateok = false + if mem.carstate == "normal" then + swingstateok = mem.params.swingcallwhennotswing + elseif mem.carstate == "swing" then + swingstateok = true + end if event.channel == "pairrequest" and mem.screenstate == "oobe_dispatcherconnect" then mem.params.floornames = event.msg.floornames mem.params.floorheights = event.msg.floorheights @@ -804,9 +833,9 @@ elseif event.type == "dispatchermsg" then mem.groupupcalls[event.msg] = nil elseif event.channel == "groupdncancel" then mem.groupdncalls[event.msg] = nil - elseif event.channel == "swingupcall" and (mem.carstate == "normal" or mem.carstate == "swing") then + elseif event.channel == "swingupcall" and swingstateok then mem.swingupcalls[event.msg] = true - elseif event.channel == "swingdncall" and (mem.carstate == "normal" or mem.carstate == "swing") then + elseif event.channel == "swingdncall" and swingstateok then mem.swingdncalls[event.msg] = true elseif event.channel == "carcall" and (mem.carstate == "normal" or mem.carstate == "swing") then mem.carcalls[event.msg] = true @@ -820,13 +849,19 @@ elseif event.type == "dispatchermsg" then if not event.msg then mem.flashfirehat = false end end elseif event.type == "remotemsg" then + local swingstateok = false + if mem.carstate == "normal" then + swingstateok = mem.params.swingcallwhennotswing + elseif mem.carstate == "swing" then + swingstateok = true + end if event.channel == "groupupcall" and mem.carstate == "normal" then mem.groupupcalls[event.msg] = true elseif event.channel == "groupdncall" and mem.carstate == "normal" then mem.groupdncalls[event.msg] = true - elseif event.channel == "swingupcall" and (mem.carstate == "normal" or mem.carstate == "swing") then + elseif event.channel == "swingupcall" and swingstateok then mem.swingupcalls[event.msg] = true - elseif event.channel == "swingdncall" and (mem.carstate == "normal" or mem.carstate == "swing") then + elseif event.channel == "swingdncall" and swingstateok then mem.swingdncalls[event.msg] = true elseif event.channel == "upcall" and (mem.carstate == "normal" or mem.carstate == "swing") then mem.upcalls[event.msg] = true @@ -1480,6 +1515,7 @@ elseif mem.screenstate == "carcallsecurity" then fs(minetest.formspec_escape(string.format("%s - %s",mem.params.floornames[i],secmode))..(i==1 and "" or ",")) end fs(";"..tostring(#mem.params.floornames-mem.editingfloor+1)..";false]") + fs("checkbox[1,9.5;swingcallwhennotswing;Allow Swing Calls When Not In Swing Operation;"..tostring(mem.params.swingcallwhennotswing).."]") if mem.editingfloor ~= (mem.params.mainlanding or 1) then fs("dropdown[8,2;4,1;secmode;Security Disabled,Authorized Users Only,Locked;") if mem.params.carcallsecurity[mem.editingfloor] == "auth" then @@ -1553,6 +1589,7 @@ local arrowenabled = { indep = true, capture = true, test = true, + swing = true, } mem.piuparrow = mem.drive.status.vel > 0 and arrowenabled[mem.carstate] mem.pidownarrow = mem.drive.status.vel < 0 and arrowenabled[mem.carstate] |