diff options
-rw-r--r-- | .luacheckrc | 2 | ||||
-rw-r--r-- | callbuttons.lua | 13 | ||||
-rw-r--r-- | controllerfw.lua | 44 | ||||
-rw-r--r-- | dbdkiosk.lua | 7 | ||||
-rw-r--r-- | dispatcherfw.lua | 16 | ||||
-rw-r--r-- | drive_entity.lua | 3 | ||||
-rw-r--r-- | drive_null.lua | 4 | ||||
-rw-r--r-- | laptop.lua | 8 | ||||
-rw-r--r-- | pilantern.lua | 6 |
9 files changed, 83 insertions, 20 deletions
diff --git a/.luacheckrc b/.luacheckrc index 6b5385e..8ce3cc6 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,4 +1,4 @@ -max_line_length = 200 +max_line_length = 160 globals = { "celevator", diff --git a/callbuttons.lua b/callbuttons.lua index 961d96e..58cd40d 100644 --- a/callbuttons.lua +++ b/callbuttons.lua @@ -1,7 +1,12 @@ celevator.callbutton = {} local function makebuttontex(dir,upon,downon,inventory) - local tex = "[combine:64x64:0,0=celevator_cabinet_sides.png:32,0=celevator_cabinet_sides.png:0,32=celevator_cabinet_sides.png:32,32=celevator_cabinet_sides.png:22,24=celevator_callbutton_panel.png" + local tex = "[combine:64x64".. + ":0,0=celevator_cabinet_sides.png".. + ":32,0=celevator_cabinet_sides.png".. + ":0,32=celevator_cabinet_sides.png".. + ":32,32=celevator_cabinet_sides.png".. + ":22,24=celevator_callbutton_panel.png" if inventory then tex = "[combine:32x32:5,0=celevator_callbutton_panel.png" end if dir == "up" then if inventory then @@ -112,7 +117,11 @@ local function disambiguatedir(pos,player) end for _,state in ipairs(validstates) do - local boringside = "[combine:64x64:0,0=celevator_cabinet_sides.png:32,0=celevator_cabinet_sides.png:0,32=celevator_cabinet_sides.png:32,32=celevator_cabinet_sides.png" + local boringside = "[combine:64x64".. + ":0,0=celevator_cabinet_sides.png".. + ":32,0=celevator_cabinet_sides.png".. + ":0,32=celevator_cabinet_sides.png".. + ":32,32=celevator_cabinet_sides.png" local nname = "celevator:callbutton_"..state[1] local dropname = nname local light = 0 diff --git a/controllerfw.lua b/controllerfw.lua index 0b2e590..c268124 100644 --- a/controllerfw.lua +++ b/controllerfw.lua @@ -424,7 +424,12 @@ elseif event.type == "ui" then end elseif mem.screenstate == "status" then for i=1,#mem.params.floornames,1 do - if event.fields[string.format("carcall%d",i)] and (mem.carstate == "normal" or mem.carstate == "test" or mem.carstate == "capture" or mem.carstate == "indep") then + if event.fields[string.format("carcall%d",i)] + and (mem.carstate == "normal" + or mem.carstate == "test" + or mem.carstate == "capture" + or mem.carstate == "indep") + then mem.carcalls[i] = true elseif event.fields[string.format("upcall%d",i)] and mem.carstate == "normal" and not mem.capturesw then if mem.params.groupmode == "group" then @@ -1153,7 +1158,15 @@ if mem.params.groupmode == "group" then end end -if (mem.carstate == "normal" or mem.carstate == "capture" or mem.carstate == "test" or mem.carstate == "indep" or mem.carstate == "fs2") and mem.doorstate == "closed" then +local canprocesscalls = { + normal = true, + capture = true, + test = true, + indep = true, + fs2 = true, +} + +if canprocesscalls[mem.carstate] and mem.doorstate == "closed" then if not mem.carmotion then if mem.direction == "up" then if getnextcallabove("up") then @@ -1353,7 +1366,8 @@ elseif mem.screenstate == "status" then fs("label[1,1;CAR STATUS]") fs(string.format("label[1,2;%s]",modenames[mem.carstate])) fs(string.format("label[1,2.5;Doors %s]",doorstates[mem.doorstate])) - fs(string.format("label[1,3;Position: %0.02fm Speed: %+0.02fm/s PI: %s]",mem.drive.status.apos,mem.drive.status.vel,minetest.formspec_escape(mem.params.floornames[getpos()]))) + local currentfloor = minetest.formspec_escape(mem.params.floornames[getpos()]) + fs(string.format("label[1,3;Position: %0.02fm Speed: %+0.02fm/s PI: %s]",mem.drive.status.apos,mem.drive.status.vel,currentfloor)) if #mem.faultlog > 0 then fs("label[1,3.5;Fault(s) Active]") else @@ -1369,7 +1383,12 @@ elseif mem.screenstate == "status" then local greenoff = "celevator_led_green_off.png" fs(string.format("image[7,1;0.7,0.7;%s]",mem.carstate == "fault" and redon or redoff)) fs("label[8,1.35;FAULT]") - fs(string.format("image[7,1.9;0.7,0.7;%s]",(mem.carstate == "mrinspect" or mem.carstate == "carinspect" or mem.carstate == "inspconflict") and yellowon or yellowoff)) + local inspectionstates = { + mrinspect = true, + carinspect = true, + inspconflict = true, + } + fs(string.format("image[7,1.9;0.7,0.7;%s]",inspectionstates[mem.carstate] and yellowon or yellowoff)) fs("label[8,2.25;INSP/ACCESS]") fs(string.format("image[7,2.8;0.7,0.7;%s]",mem.carstate == "normal" and greenon or greenoff)) fs("label[8,3.15;NORMAL OPERATION]") @@ -1426,7 +1445,8 @@ elseif mem.screenstate == "faults" then if #mem.faultlog-i >= 1 then local currfault = mem.faultlog[#mem.faultlog-i] local date = os.date("*t",currfault.timestamp) - fs(string.format("label[1,%0.1f;%04d-%02d-%02d %02d:%02d:%02d - %s]",2+i,date.year,date.month,date.day,date.hour,date.min,date.sec,faultnames[currfault.ftype])) + local timestamp = string.format("%04d-%02d-%02d %02d:%02d:%02d",date.year,date.month,date.day,date.hour,date.min,date.sec) + fs(string.format("label[1,%0.1f;%s - %s]",2+i,timestamp,faultnames[currfault.ftype])) end end else @@ -1487,7 +1507,10 @@ if mem.drive.status.dpos > mem.drive.status.apos then elseif mem.drive.status.dpos < mem.drive.status.apos then arrow = "v" end -mem.infotext = string.format("ID %d: Floor %s %s - %s - Doors %s",mem.carid,mem.params.floornames[getpos()],arrow,modenames[mem.carstate],doorstates[mem.doorstate]) +local floorname = mem.params.floornames[getpos()] +local modename = modenames[mem.carstate] +local doorstate = doorstates[mem.doorstate] +mem.infotext = string.format("ID %d: Floor %s %s - %s - Doors %s",mem.carid,floorname,arrow,modename,doorstate) if mem.drive.type then mem.showrunning = mem.drive.status.vel ~= 0 @@ -1565,11 +1588,13 @@ for i=1,floorcount,1 do local xp = col*1.25 local tex = mem.carcalls[i] and litimg or unlitimg local star = (i == (mem.params.mainlanding or 1) and "*" or "") - mem.copformspec = mem.copformspec..string.format("image_button[%f,%f;1.2,1.2;%s;carcall%d;%s;false;false;%s]",xp,yp,tex,i,minetest.formspec_escape(star..mem.params.floornames[i]),litimg) + local label = minetest.formspec_escape(star..mem.params.floornames[i]) + mem.copformspec = mem.copformspec..string.format("image_button[%f,%f;1.2,1.2;%s;carcall%d;%s;false;false;%s]",xp,yp,tex,i,label,litimg) end local doxp = (copcols == 1) and 0.5 or 1.25 -mem.copformspec = mem.copformspec..string.format("image_button[%f,%f;1.2,1.2;%s;open;%s;false;false;%s]",doxp,coprows*1.25+2.5,unlitimg,minetest.formspec_escape("<|>"),litimg) +local openlabel = minetest.formspec_escape("<|>") +mem.copformspec = mem.copformspec..string.format("image_button[%f,%f;1.2,1.2;%s;open;%s;false;false;%s]",doxp,coprows*1.25+2.5,unlitimg,openlabel,litimg) local dcxp = 3.75 if copcols == 1 then @@ -1577,7 +1602,8 @@ if copcols == 1 then elseif copcols == 2 then dcxp = 2.5 end -mem.copformspec = mem.copformspec..string.format("image_button[%f,%f;1.2,1.2;%s;close;%s;false;false;%s]",dcxp,coprows*1.25+2.5,unlitimg,minetest.formspec_escape(">|<"),litimg) +local closelabel = minetest.formspec_escape(">|<") +mem.copformspec = mem.copformspec..string.format("image_button[%f,%f;1.2,1.2;%s;close;%s;false;false;%s]",dcxp,coprows*1.25+2.5,unlitimg,closelabel,litimg) mem.copformspec = mem.copformspec..string.format("image_button[0.4,0.5;1.4,1.4;%s;callcancel;Call\nCancel;false;false;%s]",unlitimg,litimg) diff --git a/dbdkiosk.lua b/dbdkiosk.lua index 7f5996f..1250685 100644 --- a/dbdkiosk.lua +++ b/dbdkiosk.lua @@ -14,7 +14,12 @@ function celevator.dbdkiosk.updatefields(pos) local meta = minetest.get_meta(pos) local screenstate = meta:get_string("screenstate") if screenstate == "connect" then - meta:set_string("formspec","formspec_version[7]size[8,5]field[0.5,0.5;7,1;carid;Dispatcher ID;]field[0.5,2;7,1;landing;Landing Number;]button[3,3.5;2,1;save;Save]") + meta:set_string("formspec","formspec_version[7]".. + "size[8,5]".. + "field[0.5,0.5;7,1;carid;Dispatcher ID;]".. + "field[0.5,2;7,1;landing;Landing Number;]".. + "button[3,3.5;2,1;save;Save]" + ) elseif screenstate == "main" then local landing = meta:get_int("landing") local fs = "formspec_version[7]" diff --git a/dispatcherfw.lua b/dispatcherfw.lua index 97a4127..88e1537 100644 --- a/dispatcherfw.lua +++ b/dispatcherfw.lua @@ -595,7 +595,11 @@ elseif event.channel == "status" then interrupt(1,"run") end end -elseif event.type == "abm" or event.type == "remotewake" or (event.iid == "run" and mem.powerstate ~= "asleep") and (mem.screenstate == "status" or mem.screenstate == "menu") then +elseif event.type == "abm" + or event.type == "remotewake" + or (event.iid == "run" and mem.powerstate ~= "asleep") + and (mem.screenstate == "status" or mem.screenstate == "menu") +then local busy = false if not mem.upcalls then mem.upcalls = {} end if not mem.dncalls then mem.dncalls = {} end @@ -637,7 +641,10 @@ elseif event.type == "abm" or event.type == "remotewake" or (event.iid == "run" besteta = eta bestcar = carid end - if getpos(carid) == i and mem.carstatus[carid].direction == "up" and (mem.carstatus[carid].doorstate == "opening" or mem.carstatus[carid].doorstate == "open") then + if getpos(carid) == i + and mem.carstatus[carid].direction == "up" + and (mem.carstatus[carid].doorstate == "opening" or mem.carstatus[carid].doorstate == "open") + then alreadyserved = true end end @@ -716,7 +723,10 @@ elseif event.type == "abm" or event.type == "remotewake" or (event.iid == "run" besteta = eta bestcar = carid end - if getpos(carid) == i and mem.carstatus[carid].direction == "down" and (mem.carstatus[carid].doorstate == "opening" or mem.carstatus[carid].doorstate == "open") then + if getpos(carid) == i + and mem.carstatus[carid].direction == "down" + and (mem.carstatus[carid].doorstate == "opening" or mem.carstatus[carid].doorstate == "open") + then alreadyserved = true end end diff --git a/drive_entity.lua b/drive_entity.lua index ecbabdf..ae72bca 100644 --- a/drive_entity.lua +++ b/drive_entity.lua @@ -655,7 +655,8 @@ function celevator.drives.entity.movedoors(drivepos,direction,nudge) local carpos = vector.add(origin,vector.new(0,apos,0)) local carnode = celevator.get_node(carpos) local hwdoorpos = vector.add(carpos,vector.rotate_around_axis(minetest.fourdir_to_dir(carnode.param2),vector.new(0,1,0),math.pi)) - if direction == "open" and (minetest.get_item_group(celevator.get_node(hwdoorpos).name,"_celevator_hwdoor_root") == 1 or drivemeta:get_string("doorstate") == "closing") then + local isroot = minetest.get_item_group(celevator.get_node(hwdoorpos).name,"_celevator_hwdoor_root") == 1 + if direction == "open" and (isroot or drivemeta:get_string("doorstate") == "closing") then celevator.doors.hwopen(hwdoorpos,drivepos) drivemeta:set_string("doorstate","opening") elseif direction == "close" and celevator.get_node(hwdoorpos).name == "celevator:hwdoor_placeholder" then diff --git a/drive_null.lua b/drive_null.lua index beb7d4d..1a22e22 100644 --- a/drive_null.lua +++ b/drive_null.lua @@ -229,7 +229,9 @@ function celevator.drives.null.getstatus(pos,call2) end function celevator.drives.null.resetfault(pos) - --This drive has no possible faults at this time (drive communication faults are generated by the controller), but the controller expects to be able to call this + --This drive has no possible faults at this time + --(drive communication faults are generated by the controller), + --but the controller expects to be able to call this minetest.get_meta(pos):set_string("fault","") end @@ -447,8 +447,14 @@ laptop.register_app("celevator",{ local meta = minetest.get_meta(pos) local cmem = minetest.deserialize(meta:get_string("mem")) if not cmem then return end + local carcallacceptstates = { + normal = true, + test = true, + capture = true, + indep = true, + } for i=1,#cmem.params.floornames,1 do - if fields[string.format("carcall%d",i)] and (cmem.carstate == "normal" or cmem.carstate == "test" or cmem.carstate == "capture" or cmem.carstate == "indep") then + if fields[string.format("carcall%d",i)] and carcallacceptstates[cmem.carstate] then celevator.controller.run(pos,{ type = "remotemsg", source = 0, diff --git a/pilantern.lua b/pilantern.lua index 75de06f..7dda0a5 100644 --- a/pilantern.lua +++ b/pilantern.lua @@ -1,7 +1,11 @@ celevator.pi = {} celevator.lantern = {} -local boringside = "[combine:64x64:0,0=celevator_cabinet_sides.png:32,0=celevator_cabinet_sides.png:0,32=celevator_cabinet_sides.png:32,32=celevator_cabinet_sides.png" +local boringside = "[combine:64x64".. + ":0,0=celevator_cabinet_sides.png".. + ":32,0=celevator_cabinet_sides.png".. + ":0,32=celevator_cabinet_sides.png".. + ":32,32=celevator_cabinet_sides.png" local displaytex = boringside..":16,40=celevator_pi_background.png" minetest.register_entity("celevator:pi_entity",{ |