summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.luacheckrc17
-rw-r--r--fw.lua123
-rw-r--r--init.lua139
-rw-r--r--mod.conf1
4 files changed, 141 insertions, 139 deletions
diff --git a/.luacheckrc b/.luacheckrc
new file mode 100644
index 0000000..c729e1b
--- /dev/null
+++ b/.luacheckrc
@@ -0,0 +1,17 @@
+max_line_length = 160
+
+globals = {
+ "mem",
+}
+
+read_globals = {
+ "minetest",
+ "vector",
+ "event",
+ "os.datetable",
+ "interrupt",
+ "digiline_send",
+ "default",
+ "digilines",
+ "screwdriver",
+}
diff --git a/fw.lua b/fw.lua
index 039d45a..5ad63f2 100644
--- a/fw.lua
+++ b/fw.lua
@@ -4,18 +4,17 @@
--See http://unlicense.org/ for more information
--Lookup tables for human-readable strings and such
-lttypes = {"Permissive","Protected","Yellow Arrow Prot/Perm","Circular Green Prot/Perm"}
-pedtypes = {"Unsignalized","Signalized"}
-signaltypes = {"Streets 1","Roads","Streets 2"}
-pedbuttontypes = {"Normal","TrafficNeXt Compatibility"}
-shortphases = {"O","G","R","Y","FR","FY","FG","RY"} -- Green/red switched for, uh, reasons
-phases = {O = "Off",R = "Red",Y = "Yellow",G = "Green",RY = "RedYellow",FR = "FlashRed",FY = "FlashYellow",FG = "FlashGreen"}
-monitortypes = {"Straight","Left Turn","Pedestrian"}
-modes = {"Sensor","Timer","Phase Lock"}
-panellock = {"Unlocked","Locked"}
-logmodes = {"Quiet","Normal","Verbose"}
-pedrecallmodes = {"Never","Timer Only","Always"}
-ltrecallmodes = {"No","Yes"}
+local lttypes = {"Permissive","Protected","Yellow Arrow Prot/Perm","Circular Green Prot/Perm"}
+local pedtypes = {"Unsignalized","Signalized"}
+local signaltypes = {"Streets 1","Roads","Streets 2"}
+local pedbuttontypes = {"Normal","TrafficNeXt Compatibility"}
+local shortphases = {"O","G","R","Y","FR","FY","FG","RY"} -- Green/red switched for, uh, reasons
+local phases = {O = "Off",R = "Red",Y = "Yellow",G = "Green",RY = "RedYellow",FR = "FlashRed",FY = "FlashYellow",FG = "FlashGreen"}
+local modes = {"Sensor","Timer","Phase Lock"}
+local panellock = {"Unlocked","Locked"}
+local logmodes = {"Quiet","Normal","Verbose"}
+local pedrecallmodes = {"Never","Timer Only","Always"}
+local ltrecallmodes = {"No","Yes"}
--Only accept digilines signals on the necessary channels
local event_ok = false
@@ -28,7 +27,7 @@ if not event_ok then
end
--Used for reverse lookups
-function pivot(table)
+local function pivot(table)
local out = {}
for k,v in pairs(table) do
out[v] = k
@@ -37,19 +36,19 @@ function pivot(table)
end
--Phase setter thing
-function setlight(light,phase)
+local function setlight(light,phase)
mem.currentphase[light] = phase
end
--Log filter/formatter
-function log(desc,verboseonly)
+local function log(desc,verboseonly)
if mem.logmode ~= 1 and (mem.logmode == 3 or not verboseonly) then
print("[LTC-4000E @ "..mem.name.."] "..desc)
end
end
--Fault logger
-function logfault(desc,fatal)
+local function logfault(desc,fatal)
if fatal then mem.phaselocked = true end
log(string.format("%s FAULT: ",(fatal and "FATAL" or "Non-fatal"))..desc,false)
local date = os.datetable()
@@ -58,7 +57,7 @@ function logfault(desc,fatal)
end
--Checks if the schedule is currently active
-function isscheduled()
+local function isscheduled()
local hour = os.datetable().hour
if mem.schedstart < mem.schedend then
--Active during the day
@@ -127,8 +126,8 @@ if not mem.logmode then mem.logmode = 2 end
if not mem.lock then mem.lock = 2 end
--Handle special modes
-was_phaselocked = mem.phaselocked
-was_timed = mem.timed
+local was_phaselocked = mem.phaselocked
+local was_timed = mem.timed
mem.phaselocked = (isscheduled() and mem.schedmode == 3) or (not isscheduled() and mem.normalmode == 3)
mem.timed = (isscheduled() and mem.schedmode == 2) or (not isscheduled() and mem.normalmode == 2)
if was_phaselocked and not mem.phaselocked then
@@ -253,7 +252,13 @@ if event.type == "digiline" and string.sub(event.channel,1,8) == "preempt_" and
end
--Phase logic for already-running cycles
-if mem.busy and mem.cycle and event.type == "interrupt" and (event.iid == "tick" or event.iid == "manualtick") and not mem.phaselocked and (event.iid == "manualtick" or not mem.stoptime) then
+if mem.busy
+ and mem.cycle
+ and event.type == "interrupt"
+ and (event.iid == "tick" or event.iid == "manualtick")
+ and not mem.phaselocked
+ and (event.iid == "manualtick" or not mem.stoptime)
+then
log("Continuing existing cycle at phase "..mem.cycle,true)
if mem.cycle == "preempt_yellow" then
for k,v in pairs(mem.currentphase) do
@@ -289,7 +294,9 @@ if mem.busy and mem.cycle and event.type == "interrupt" and (event.iid == "tick"
setlight("at","R")
setlight("ct","R")
--Branch over to B/D leading left turn if necessary
- if (mem.det.bt and mem.det.dt and mem.ltbtype ~= 1 and mem.ltdtype ~= 1) or (((mem.det.bt and mem.ltbtype ~= 1) or (mem.det.dt and mem.ltdtype ~= 1)) and ((mem.det.ap and mem.pedatype ~= 1) or (mem.det.cp and mem.pedctype ~= 1))) then
+ if (mem.det.bt and mem.det.dt and mem.ltbtype ~= 1 and mem.ltdtype ~= 1)
+ or (((mem.det.bt and mem.ltbtype ~= 1) or (mem.det.dt and mem.ltdtype ~= 1)) and ((mem.det.ap and mem.pedatype ~= 1)
+ or (mem.det.cp and mem.pedctype ~= 1))) then
mem.cycle = "bdlead1"
elseif mem.det.bt and mem.ltbtype ~= 1 then
mem.cycle = "blead1"
@@ -542,7 +549,9 @@ if mem.busy and mem.cycle and event.type == "interrupt" and (event.iid == "tick"
if mem.peddtype ~= 1 then setlight("dp","G") end
interrupt(mem.sideped,"tick")
elseif mem.cycle == "sideped3" then
- if not (mem.det.b or mem.det.d or mem.det.at or mem.det.bt or mem.det.ct or mem.det.dt or mem.det.ap or mem.det.cp) and (mem.pedrecallmode == 3 or mem.det.bp or mem.det.dp) then
+ if not (mem.det.b or mem.det.d or mem.det.at or mem.det.bt or mem.det.ct or mem.det.dt or mem.det.ap or mem.det.cp)
+ and (mem.pedrecallmode == 3 or mem.det.bp or mem.det.dp)
+ then
mem.det.bp = nil
mem.det.dp = nil
interrupt(mem.sideped,"tick")
@@ -580,7 +589,7 @@ if mem.busy and mem.cycle and event.type == "interrupt" and (event.iid == "tick"
end
--Phase logic for starting new cycles
-detactive = false
+local detactive = false
for _,_ in pairs(mem.det) do detactive = true end
if (not mem.busy) and detactive and (not mem.stoptime) then
if mem.phaselocked then
@@ -590,17 +599,31 @@ if (not mem.busy) and detactive and (not mem.stoptime) then
else
log("Starting new cycle",true)
mem.stats.cycles = mem.stats.cycles + 1
- if mem.det.at and mem.ltatype ~= 1 and (mem.ltctype == 2 or mem.ltctype == 3) and not (mem.det.b or mem.det.d or mem.det.bt or mem.det.ct or mem.det.dt) then
+ if mem.det.at
+ and mem.ltatype ~= 1
+ and (mem.ltctype == 2 or mem.ltctype == 3)
+ and not (mem.det.b or mem.det.d or mem.det.bt or mem.det.ct or mem.det.dt)
+ then
mem.cycle = "yta1"
mem.busy = true
setlight("c","Y")
interrupt(mem.yellowa,"tick")
- elseif mem.det.ct and mem.ltctype ~=1 and (mem.ltatype == 2 or mem.ltatype == 3) and not (mem.det.b or mem.det.d or mem.det.at or mem.det.bt or mem.det.dt) then
+ elseif mem.det.ct
+ and mem.ltctype ~=1
+ and (mem.ltatype == 2 or mem.ltatype == 3)
+ and not (mem.det.b or mem.det.d or mem.det.at or mem.det.bt or mem.det.dt)
+ then
mem.cycle = "ytc1"
mem.busy = true
setlight("a","Y")
interrupt(mem.yellowa,"tick")
- elseif mem.det.b or mem.det.d or mem.det.bt or mem.det.dt or (mem.det.at and mem.ltatype ~= 1) or (mem.det.ct and mem.ltctype ~= 1) then
+ elseif mem.det.b
+ or mem.det.d
+ or mem.det.bt
+ or mem.det.dt
+ or (mem.det.at and mem.ltatype ~= 1)
+ or (mem.det.ct and mem.ltctype ~= 1)
+ then
mem.cycle = "straight1"
mem.busy = true
setlight("a","Y")
@@ -802,9 +825,7 @@ if event.type == "digiline" and event.channel == "touchscreen" then
interrupt(nil,"gapout")
interrupt(nil,"maxgreen")
end
- elseif mem.menu == "reboot" then
- --No fields/buttons on this screen, so do nothing
- else
+ elseif mem.menu ~= "reboot" then --Reboot screen exists has no controls
logfault("Unrecognized menu "..mem.menu,false)
mem.menu = "run"
end
@@ -921,14 +942,38 @@ elseif mem.menu == "mancyc" then
table.insert(disp,{command="addlabel",X=0,Y=0,label="Manual Call Entry"})
table.insert(disp,{command="addimage_button",X=1,Y=2,W=2,H=1,name="b",label="Straight B",image="digistuff_ts_bg.png"..(mem.det.b and "^[brighten" or "")})
table.insert(disp,{command="addimage_button",X=1,Y=4,W=2,H=1,name="d",label="Straight D",image="digistuff_ts_bg.png"..(mem.det.d and "^[brighten" or "")})
- if mem.ltatype ~= 1 then table.insert(disp,{command="addimage_button",X=4,Y=1,W=2,H=1,name="at",label="Left Turn A",image="digistuff_ts_bg.png"..(mem.det.at and "^[brighten" or "")}) end
- if mem.ltbtype ~= 1 then table.insert(disp,{command="addimage_button",X=4,Y=2,W=2,H=1,name="bt",label="Left Turn B",image="digistuff_ts_bg.png"..(mem.det.bt and "^[brighten" or "")}) end
- if mem.ltctype ~= 1 then table.insert(disp,{command="addimage_button",X=4,Y=3,W=2,H=1,name="ct",label="Left Turn C",image="digistuff_ts_bg.png"..(mem.det.ct and "^[brighten" or "")}) end
- if mem.ltdtype ~= 1 then table.insert(disp,{command="addimage_button",X=4,Y=4,W=2,H=1,name="dt",label="Left Turn D",image="digistuff_ts_bg.png"..(mem.det.dt and "^[brighten" or "")}) end
- if mem.pedatype ~= 1 then table.insert(disp,{command="addimage_button",X=7,Y=1,W=2,H=1,name="ap",label="Pedestrian A",image="digistuff_ts_bg.png"..(mem.det.ap and "^[brighten" or "")}) end
- if mem.pedbtype ~= 1 then table.insert(disp,{command="addimage_button",X=7,Y=2,W=2,H=1,name="bp",label="Pedestrian B",image="digistuff_ts_bg.png"..(mem.det.bp and "^[brighten" or "")}) end
- if mem.pedctype ~= 1 then table.insert(disp,{command="addimage_button",X=7,Y=3,W=2,H=1,name="cp",label="Pedestrian C",image="digistuff_ts_bg.png"..(mem.det.cp and "^[brighten" or "")}) end
- if mem.peddtype ~= 1 then table.insert(disp,{command="addimage_button",X=7,Y=4,W=2,H=1,name="dp",label="Pedestrian D",image="digistuff_ts_bg.png"..(mem.det.dp and "^[brighten" or "")}) end
+ if mem.ltatype ~= 1 then
+ local attex = "digistuff_ts_bg.png"..(mem.det.at and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=4,Y=1,W=2,H=1,name="at",label="Left Turn A",image=attex})
+ end
+ if mem.ltbtype ~= 1 then
+ local bttex = "digistuff_ts_bg.png"..(mem.det.bt and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=4,Y=2,W=2,H=1,name="bt",label="Left Turn B",image=bttex})
+ end
+ if mem.ltctype ~= 1 then
+ local cttex = "digistuff_ts_bg.png"..(mem.det.ct and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=4,Y=3,W=2,H=1,name="ct",label="Left Turn C",image=cttex})
+ end
+ if mem.ltdtype ~= 1 then
+ local dttex = "digistuff_ts_bg.png"..(mem.det.dt and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=4,Y=4,W=2,H=1,name="dt",label="Left Turn D",image=dttex})
+ end
+ if mem.pedatype ~= 1 then
+ local aptex = "digistuff_ts_bg.png"..(mem.det.ap and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=7,Y=1,W=2,H=1,name="ap",label="Pedestrian A",image=aptex})
+ end
+ if mem.pedbtype ~= 1 then
+ local bptex = "digistuff_ts_bg.png"..(mem.det.bp and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=7,Y=2,W=2,H=1,name="bp",label="Pedestrian B",image=bptex})
+ end
+ if mem.pedctype ~= 1 then
+ local cptex = "digistuff_ts_bg.png"..(mem.det.cp and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=7,Y=3,W=2,H=1,name="cp",label="Pedestrian C",image=cptex})
+ end
+ if mem.peddtype ~= 1 then
+ local dptex = "digistuff_ts_bg.png"..(mem.det.dp and "^[brighten" or "")
+ table.insert(disp,{command="addimage_button",X=7,Y=4,W=2,H=1,name="dp",label="Pedestrian D",image=dptex})
+ end
table.insert(disp,{command="addbutton",X=4,Y=6,W=2,H=1,name="cancel",label="Back"})
elseif mem.menu == "log" then
table.insert(disp,{command="addlabel",X=0,Y=0,label="Fault Log"})
@@ -1049,7 +1094,7 @@ elseif mem.menu == "monitoring" then
table.insert(disp,{command="addimage",X=5.25, Y=1.75, W=1,H=1,texture_name=sideline})
table.insert(disp,{command="addimage",X=6, Y=1.75, W=1,H=1,texture_name=centerline})
table.insert(disp,{command="addimage",X=6.75, Y=1.75, W=1,H=1,texture_name=sideline.."^[transformR180"})
-
+
--Approach C (right)
table.insert(disp,{command="addimage",X=7.5, Y=3.25, W=1,H=1,texture_name=sideline.."^[transformR270"})
table.insert(disp,{command="addimage",X=7.5, Y=4, W=1,H=1,texture_name=centerline.."^[transformR90"})
@@ -1149,7 +1194,7 @@ elseif mem.menu == "stats" then
table.insert(disp,{command="addlabel",X=4,Y=3.5,label="DP: "..mem.stats.dp})
table.insert(disp,{command="addlabel",X=0,Y=4.5,label="Total cycles: "..mem.stats.cycles})
local timesinceclear = os.time() - mem.stats.lastreset
- local lastclear = "ERROR"
+ local lastclear
if timesinceclear < 120 then --Two minutes
lastclear = math.floor(timesinceclear).." seconds"
elseif timesinceclear < 7200 then --Two hours
diff --git a/init.lua b/init.lua
index 672c344..6311034 100644
--- a/init.lua
+++ b/init.lua
@@ -30,7 +30,7 @@ local function process_command(meta,data,msg)
end
end
if not msg.texture_name or type(msg.texture_name) ~= "string" then
- return
+ return
end
local field = {type="image",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,texture_name=minetest.formspec_escape(msg.texture_name)}
table.insert(data,field)
@@ -45,33 +45,10 @@ local function process_command(meta,data,msg)
return
end
end
- local field = {type="field",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label),default=minetest.formspec_escape(msg.default)}
- table.insert(data,field)
- elseif msg.command == "addpwdfield" then
- for _,i in pairs({"X","Y","W","H"}) do
- if not msg[i] or type(msg[i]) ~= "number" then
- return
- end
- end
- for _,i in pairs({"name","label"}) do
- if not msg[i] or type(msg[i]) ~= "string" then
- return
- end
- end
- local field = {type="pwdfield",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label)}
- table.insert(data,field)
- elseif msg.command == "addtextarea" then
- for _,i in pairs({"X","Y","W","H"}) do
- if not msg[i] or type(msg[i]) ~= "number" then
- return
- end
- end
- for _,i in pairs({"name","label","default"}) do
- if not msg[i] or type(msg[i]) ~= "string" then
- return
- end
- end
- local field = {type="textarea",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label),default=minetest.formspec_escape(msg.default)}
+ local fieldname = minetest.formspec_escape(msg.name)
+ local fieldlabel = minetest.formspec_escape(msg.label)
+ local fielddefault = minetest.formspec_escape(msg.default)
+ local field = {type="field",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=fieldname,label=fieldlabel,default=fielddefault}
table.insert(data,field)
elseif msg.command == "addlabel" then
for _,i in pairs({"X","Y"}) do
@@ -80,21 +57,10 @@ local function process_command(meta,data,msg)
end
end
if not msg.label or type(msg.label) ~= "string" then
- return
+ return
end
local field = {type="label",X=msg.X,Y=msg.Y,label=minetest.formspec_escape(msg.label)}
table.insert(data,field)
- elseif msg.command == "addvertlabel" then
- for _,i in pairs({"X","Y"}) do
- if not msg[i] or type(msg[i]) ~= "number" then
- return
- end
- end
- if not msg.label or type(msg.label) ~= "string" then
- return
- end
- local field = {type="vertlabel",X=msg.X,Y=msg.Y,label=minetest.formspec_escape(msg.label)}
- table.insert(data,field)
elseif msg.command == "addbutton" then
for _,i in pairs({"X","Y","W","H"}) do
if not msg[i] or type(msg[i]) ~= "number" then
@@ -106,20 +72,9 @@ local function process_command(meta,data,msg)
return
end
end
- local field = {type="button",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label)}
- table.insert(data,field)
- elseif msg.command == "addbutton_exit" then
- for _,i in pairs({"X","Y","W","H"}) do
- if not msg[i] or type(msg[i]) ~= "number" then
- return
- end
- end
- for _,i in pairs({"name","label"}) do
- if not msg[i] or type(msg[i]) ~= "string" then
- return
- end
- end
- local field = {type="button_exit",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label)}
+ local buttonname = minetest.formspec_escape(msg.name)
+ local buttonlabel = minetest.formspec_escape(msg.label)
+ local field = {type="button",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,name=buttonname,label=buttonlabel}
table.insert(data,field)
elseif msg.command == "addimage_button" then
for _,i in pairs({"X","Y","W","H"}) do
@@ -132,20 +87,10 @@ local function process_command(meta,data,msg)
return
end
end
- local field = {type="image_button",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,image=minetest.formspec_escape(msg.image),name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label)}
- table.insert(data,field)
- elseif msg.command == "addimage_button_exit" then
- for _,i in pairs({"X","Y","W","H"}) do
- if not msg[i] or type(msg[i]) ~= "number" then
- return
- end
- end
- for _,i in pairs({"image","name","label"}) do
- if not msg[i] or type(msg[i]) ~= "string" then
- return
- end
- end
- local field = {type="image_button_exit",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,image=minetest.formspec_escape(msg.image),name=minetest.formspec_escape(msg.name),label=minetest.formspec_escape(msg.label)}
+ local ibuttonimage = minetest.formspec_escape(msg.image)
+ local ibuttonname = minetest.formspec_escape(msg.name)
+ local ibuttonlabel = minetest.formspec_escape(msg.label)
+ local field = {type="image_button",X=msg.X,Y=msg.Y,W=msg.W,H=msg.H,image=ibuttonimage,name=ibuttonname,label=ibuttonlabel}
table.insert(data,field)
elseif msg.command == "adddropdown" then
for _,i in pairs({"X","Y","W","H","selected_id"}) do
@@ -233,7 +178,7 @@ end
--Interrupt node timer stuff
local function getnextinterrupt(interrupts)
local nextint = 0
- for k,v in pairs(interrupts) do
+ for _,v in pairs(interrupts) do
if nextint == 0 or v < nextint then
nextint = v
end
@@ -268,7 +213,7 @@ local function setinterrupt(pos,time,iid)
end
--Load the (mostly unmodified) firmware
-local fw = loadfile(minetest.get_modpath("ltc4000e")..DIR_DELIM.."fw.lua")
+local fw = loadfile(minetest.get_modpath("ltc4000e").."/fw.lua")
local function run(pos,event)
--Determine controller type
@@ -305,7 +250,7 @@ local function run(pos,event)
ts_on_digiline_receive(pos,msg)
else
--Not an integrated peripheral, so send the message
- digiline:receptor_send(pos,cabinet_digiline_rules,channel,msg)
+ digilines.receptor_send(pos,cabinet_digiline_rules,channel,msg)
end
end
else
@@ -315,7 +260,7 @@ local function run(pos,event)
ts_on_digiline_receive(pos,msg)
else
--Not an integrated peripheral, so send the message
- digiline:receptor_send(pos,digiline.rules.default,channel,msg)
+ digilines.receptor_send(pos,digilines.rules.default,channel,msg)
end
end
end
@@ -352,7 +297,7 @@ local function oninterrupt(pos)
event.iid = i
run(pos,event)
end
- local interrupts = minetest.deserialize(meta:get_string("interrupts")) or {} --Reload as it may have changed
+ interrupts = minetest.deserialize(meta:get_string("interrupts")) or {} --Reload as it may have changed
for _,i in ipairs(current) do
if interrupts[i] and interrupts[i] <= os.time() then
interrupts[i] = nil
@@ -367,7 +312,7 @@ local function oninterrupt(pos)
meta:set_string("interrupts",minetest.serialize(interrupts))
end
-local function ts_on_receive_fields(pos,formname,fields,sender)
+local function ts_on_receive_fields(pos,_,fields,sender)
local meta = minetest.get_meta(pos)
local playername = sender:get_player_name()
local locked = meta:get_int("locked") == 1
@@ -413,14 +358,13 @@ minetest.register_node("ltc4000e:polemount", {
node_box = {
type = "fixed",
fixed = polemount_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = polemount_nodebox
- },
+ },
on_receive_fields = ts_on_receive_fields,
- digiline =
- {
+ digiline = {
receptor = {},
effector = {
action = function(pos,_,channel,msg)
@@ -498,18 +442,18 @@ minetest.register_node("ltc4000e:nema_bottom", {
end
end,
on_rotate = function(pos,node,user,mode,new_param2)
- if not screwdriver then
+ if not minetest.global_exists("screwdriver") then
return false
end
local ret = screwdriver.rotate_simple(pos,node,user,mode,new_param2)
- minetest.after(0,function(pos)
+ minetest.after(0,function()
local newnode = minetest.get_node(pos)
local param2 = newnode.param2
pos.y = pos.y + 1
local topnode = minetest.get_node(pos)
topnode.param2 = param2
minetest.set_node(pos,topnode)
- end,pos)
+ end)
return ret
end,
on_timer = oninterrupt,
@@ -551,17 +495,16 @@ minetest.register_node("ltc4000e:nema_bottom", {
node_box = {
type = "fixed",
fixed = bottom_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,-0.5,0.5,-0.2,0.5},
{-0.4,-0.2,-0.4,0.4,1.3,0.3},
}
- },
+ },
on_receive_fields = ts_on_receive_fields,
- digiline =
- {
+ digiline = {
receptor = {},
wire = {
rules = cabinet_digiline_rules,
@@ -593,11 +536,11 @@ minetest.register_node("ltc4000e:nema_top", {
node_box = {
type = "fixed",
fixed = top_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = {0,0,0,0,0,0}
- },
+ },
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_metal_defaults()
})
@@ -661,13 +604,10 @@ minetest.register_node("ltc4000e:nema_bottom_open", {
if not puncher:is_player() then
return
end
- local name = puncher:get_player_name()
local vpos = vector.new(pos.x,pos.y,pos.z)
local backdir = minetest.facedir_to_dir(node.param2)
local frontpos = vector.add(vpos,vector.multiply(backdir,-1))
local fronttoppos = vector.add(frontpos,vector.new(0,1,0))
- local frontnode = minetest.get_node(frontpos)
- local fronttopnode = minetest.get_node(fronttoppos)
minetest.set_node(frontpos,{name="air"})
minetest.set_node(fronttoppos,{name="air"})
node.name = "ltc4000e:nema_bottom"
@@ -686,17 +626,16 @@ minetest.register_node("ltc4000e:nema_bottom_open", {
node_box = {
type = "fixed",
fixed = bottom_open_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = {
{-0.5,-0.5,-0.5,0.5,-0.2,0.5},
{-0.4,-0.2,-0.4,0.4,1.3,0.3},
}
- },
+ },
on_receive_fields = ts_on_receive_fields,
- digiline =
- {
+ digiline = {
receptor = {},
wire = {
rules = cabinet_digiline_rules,
@@ -728,11 +667,11 @@ minetest.register_node("ltc4000e:nema_top_open", {
node_box = {
type = "fixed",
fixed = top_open_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = {0,0,0,0,0,0}
- },
+ },
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_metal_defaults()
})
@@ -752,11 +691,11 @@ minetest.register_node("ltc4000e:door_bottom", {
node_box = {
type = "fixed",
fixed = door_bottom_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = {0,0,0,0,0,0}
- },
+ },
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_metal_defaults()
})
@@ -776,11 +715,11 @@ minetest.register_node("ltc4000e:door_top", {
node_box = {
type = "fixed",
fixed = door_top_nodebox
- },
+ },
selection_box = {
type = "fixed",
fixed = {0,0,0,0,0,0}
- },
+ },
groups = {not_in_creative_inventory=1},
sounds = default.node_sound_metal_defaults()
})
diff --git a/mod.conf b/mod.conf
index afbd365..1cae1ac 100644
--- a/mod.conf
+++ b/mod.conf
@@ -1,3 +1,4 @@
name = ltc4000e
description = Advanced traffic signal controller
depends = default,digilines,digistuff
+optional_depends = screwdriver