mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-01-27 08:40:16 +01:00
Allow specifying a port for digilines messages to be sent from the lua_controller
This commit is contained in:
parent
583d2c1441
commit
96086f6627
@ -37,6 +37,14 @@ local rules = {
|
|||||||
d = {x = 0, y = 0, z = -1, name="D"},
|
d = {x = 0, y = 0, z = -1, name="D"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local digiline_port_rules = {}
|
||||||
|
for port, rule in pairs(rules) do
|
||||||
|
digiline_port_rules[port] = {
|
||||||
|
rule,
|
||||||
|
vector.add(rule, {x=0,y=1,z=0}),
|
||||||
|
vector.add(rule, {x=0,y=-1,z=0})
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
------------------
|
------------------
|
||||||
-- Action stuff --
|
-- Action stuff --
|
||||||
@ -429,7 +437,7 @@ local function get_digiline_send(pos, itbl, send_warning)
|
|||||||
if not minetest.global_exists("digilines") then return end
|
if not minetest.global_exists("digilines") then return end
|
||||||
local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
|
local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
|
||||||
local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
|
local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
|
||||||
return function(channel, msg)
|
return function(channel, msg, port)
|
||||||
-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
|
-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
|
||||||
-- or via anything that could.
|
-- or via anything that could.
|
||||||
-- Make sure channel is string, number or boolean
|
-- Make sure channel is string, number or boolean
|
||||||
@ -453,7 +461,7 @@ local function get_digiline_send(pos, itbl, send_warning)
|
|||||||
table.insert(itbl, function ()
|
table.insert(itbl, function ()
|
||||||
-- Runs outside of string metatable sandbox
|
-- Runs outside of string metatable sandbox
|
||||||
local luac_id = minetest.get_meta(pos):get_int("luac_id")
|
local luac_id = minetest.get_meta(pos):get_int("luac_id")
|
||||||
mesecon.queue:add_action(pos, "lc_digiline_relay", {channel, luac_id, msg})
|
mesecon.queue:add_action(pos, "lc_digiline_relay", {channel, luac_id, msg, port })
|
||||||
end)
|
end)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@ -715,13 +723,14 @@ mesecon.queue:add_function("lc_interrupt", function (pos, luac_id, iid)
|
|||||||
run(pos, {type="interrupt", iid = iid})
|
run(pos, {type="interrupt", iid = iid})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
mesecon.queue:add_function("lc_digiline_relay", function (pos, channel, luac_id, msg)
|
mesecon.queue:add_function("lc_digiline_relay", function (pos, channel, luac_id, msg, port)
|
||||||
if not digiline then return end
|
if not digiline then return end
|
||||||
-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
|
-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
|
||||||
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
|
||||||
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
|
if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
|
||||||
-- The actual work
|
-- The actual work
|
||||||
digiline:receptor_send(pos, digiline.rules.default, channel, msg)
|
local send_rules = (port and digiline_port_rules[string.lower(port)]) or digilines.rules.default
|
||||||
|
digiline:receptor_send(pos, send_rules, channel, msg)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user