aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2021-02-11 12:26:28 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2021-02-11 12:26:28 +0100
commita847527b632ef19efd5dcf8ea77b495984ff9cc9 (patch)
tree97df340b7b83049ff5e08c5aa3f82a218083e634
parentb5512ed80fd27d91535fbc99dde29ef924e86ed0 (diff)
downloadlinetrack-a847527b632ef19efd5dcf8ea77b495984ff9cc9.tar.gz
linetrack-a847527b632ef19efd5dcf8ea77b495984ff9cc9.tar.bz2
linetrack-a847527b632ef19efd5dcf8ea77b495984ff9cc9.zip
modify for new_lzb branchHEADmaster
-rw-r--r--interlocking.lua30
1 files changed, 12 insertions, 18 deletions
diff --git a/interlocking.lua b/interlocking.lua
index 98faa94..8f1f9ab 100644
--- a/interlocking.lua
+++ b/interlocking.lua
@@ -1,13 +1,14 @@
+
local setaspectf = function()
return function(pos, node, asp)
- if not asp.main.free then
- if asp.shunt.free then
+ if asp.main == 0 then
+ if asp.shunt then
advtrains.ndb.swap_node(pos, {name="linetrack:signal_shunt", param2 = node.param2})
else
advtrains.ndb.swap_node(pos, {name="linetrack:signal_danger", param2 = node.param2})
end
else
- if asp.dst.free and asp.main.speed == -1 then
+ if asp.dst ~= 0 and asp.main == -1 then
advtrains.ndb.swap_node(pos, {name="linetrack:signal_free", param2 = node.param2})
else
advtrains.ndb.swap_node(pos, {name="linetrack:signal_slow", param2 = node.param2})
@@ -21,18 +22,10 @@ local setaspectf = function()
end
local suppasp = {
- main = {
- free = nil,
- speed = {6, -1},
- },
- dst = {
- free = nil,
- speed = nil,
- },
- shunt = {
- free = nil,
- proceed_as_main = true,
- },
+ main = {0, 6, -1},
+ dst = {0, false},
+ shunt = nil,
+ proceed_as_main = true,
info = {
call_on = false,
dead_end = false,
@@ -40,11 +33,12 @@ local suppasp = {
}
}
+
for typ, prts in pairs({
danger = {asp = advtrains.interlocking.DANGER, n = "slow", ici=true},
- slow = {asp = { main = { free = true, speed = 6 }, shunt = {proceed_as_main = true}} , n = "free"},
- free = {asp = { main = { free = true, speed = -1 }, shunt = {proceed_as_main = true}} , n = "shunt"},
- shunt = {asp = { main = {free = false}, shunt = {free = true} } , n = "danger"},
+ slow = {asp = { main = 6, proceed_as_main = true} , n = "free"},
+ free = {asp = { main = -1, proceed_as_main = true} , n = "shunt"},
+ shunt = {asp = { main = 0, shunt = true} , n = "danger"},
}) do
minetest.register_node("linetrack:signal_"..typ, {
description = "Generic Main Signal",
ass="hl opt">] assert(chatcommand, "Attempt to override non-existent chatcommand "..name) for k, v in pairs(redefinition) do rawset(chatcommand, k, v) end core.registered_chatcommands[name] = chatcommand end local cmd_marker = "/" local function gettext(...) return ... end local function gettext_replace(text, replace) return text:gsub("$1", replace) end if INIT == "client" then cmd_marker = "." gettext = core.gettext gettext_replace = fgettext_ne end local function do_help_cmd(name, param) local function format_help_line(cmd, def) local msg = core.colorize("#00ffff", cmd_marker .. cmd) if def.params and def.params ~= "" then msg = msg .. " " .. def.params end if def.description and def.description ~= "" then msg = msg .. ": " .. def.description end return msg end if param == "" then local cmds = {} for cmd, def in pairs(core.registered_chatcommands) do if INIT == "client" or core.check_player_privs(name, def.privs) then cmds[#cmds + 1] = cmd end end table.sort(cmds) return true, gettext("Available commands: ") .. table.concat(cmds, " ") .. "\n" .. gettext_replace("Use '$1help <cmd>' to get more information," .. " or '$1help all' to list everything.", cmd_marker) elseif param == "all" then local cmds = {} for cmd, def in pairs(core.registered_chatcommands) do if INIT == "client" or core.check_player_privs(name, def.privs) then cmds[#cmds + 1] = format_help_line(cmd, def) end end table.sort(cmds) return true, gettext("Available commands:").."\n"..table.concat(cmds, "\n") elseif INIT == "game" and param == "privs" then local privs = {} for priv, def in pairs(core.registered_privileges) do privs[#privs + 1] = priv .. ": " .. def.description end table.sort(privs) return true, "Available privileges:\n"..table.concat(privs, "\n") else local cmd = param local def = core.registered_chatcommands[cmd] if not def then return false, gettext("Command not available: ")..cmd else return true, format_help_line(cmd, def) end end end if INIT == "client" then core.register_chatcommand("help", { params = gettext("[all/<cmd>]"), description = gettext("Get help for commands"), func = function(param) return do_help_cmd(nil, param) end, }) else core.register_chatcommand("help", { params = "[all/privs/<cmd>]", description = "Get help for commands or list privileges", func = do_help_cmd, }) end