From c8e5e800e815e44e81d1c2ff8ae478ded719f359 Mon Sep 17 00:00:00 2001 From: SX <50966843+S-S-X@users.noreply.github.com> Date: Sat, 23 May 2020 22:24:35 +0300 Subject: [PATCH] Machine conduct digilines downwards (#49) * Custom digiline rules for machines * Add custom digiline receptor and effector rules for machines * technic.digiline.rules must be always available, even if digilines is disabled Co-authored-by: SX --- technic/machines/HV/forcefield.lua | 8 ++++++-- technic/machines/init.lua | 14 ++++++++++++++ technic/machines/register/battery_box.lua | 8 ++++++-- technic/machines/supply_converter.lua | 8 ++++++-- technic/machines/switching_station.lua | 10 +++++++--- 5 files changed, 39 insertions(+), 9 deletions(-) diff --git a/technic/machines/HV/forcefield.lua b/technic/machines/HV/forcefield.lua index d3bc984..f4be8ba 100644 --- a/technic/machines/HV/forcefield.lua +++ b/technic/machines/HV/forcefield.lua @@ -172,8 +172,12 @@ local mesecons = { } local digiline_def = { - receptor = {action = function() end}, + receptor = { + rules = technic.digilines.rules, + action = function() end + }, effector = { + rules = technic.digilines.rules, action = function(pos, node, channel, msg) local meta = minetest.get_meta(pos) if channel ~= meta:get_string("channel") then @@ -203,7 +207,7 @@ local digiline_def = { return end if msg.command == "get" then - digilines.receptor_send(pos, digilines.rules.default, channel, { + digilines.receptor_send(pos, technic.digilines.rules, channel, { enabled = meta:get_int("enabled"), range = meta:get_int("range"), shape = meta:get_int("shape") diff --git a/technic/machines/init.lua b/technic/machines/init.lua index 735dc1f..9469ea8 100644 --- a/technic/machines/init.lua +++ b/technic/machines/init.lua @@ -1,5 +1,19 @@ local path = technic.modpath.."/machines" +technic.digilines = { + rules = { + -- digilines.rules.default + {x= 1,y= 0,z= 0},{x=-1,y= 0,z= 0}, -- along x beside + {x= 0,y= 0,z= 1},{x= 0,y= 0,z=-1}, -- along z beside + {x= 1,y= 1,z= 0},{x=-1,y= 1,z= 0}, -- 1 node above along x diagonal + {x= 0,y= 1,z= 1},{x= 0,y= 1,z=-1}, -- 1 node above along z diagonal + {x= 1,y=-1,z= 0},{x=-1,y=-1,z= 0}, -- 1 node below along x diagonal + {x= 0,y=-1,z= 1},{x= 0,y=-1,z=-1}, -- 1 node below along z diagonal + -- added rules for digi cable + {x = 0, y = -1, z = 0}, -- along y below + } +} + dofile(path.."/register/init.lua") -- Tiers diff --git a/technic/machines/register/battery_box.lua b/technic/machines/register/battery_box.lua index bf4d96a..c518dab 100644 --- a/technic/machines/register/battery_box.lua +++ b/technic/machines/register/battery_box.lua @@ -358,8 +358,12 @@ function technic.register_battery_box(data) end end, digiline = { - receptor = {action = function() end}, + receptor = { + rules = technic.digilines.rules, + action = function() end + }, effector = { + rules = technic.digilines.rules, action = function(pos, node, channel, msg) if msg ~= "GET" and msg ~= "get" then return @@ -369,7 +373,7 @@ function technic.register_battery_box(data) return end local inv = meta:get_inventory() - digilines.receptor_send(pos, digilines.rules.default, channel, { + digilines.receptor_send(pos, technic.digilines.rules, channel, { demand = meta:get_int(tier.."_EU_demand"), supply = meta:get_int(tier.."_EU_supply"), input = meta:get_int(tier.."_EU_input"), diff --git a/technic/machines/supply_converter.lua b/technic/machines/supply_converter.lua index 24601c6..8e66b47 100644 --- a/technic/machines/supply_converter.lua +++ b/technic/machines/supply_converter.lua @@ -69,8 +69,12 @@ local mesecons = { local digiline_def = { - receptor = {action = function() end}, + receptor = { + rules = technic.digilines.rules, + action = function() end + }, effector = { + rules = technic.digilines.rules, action = function(pos, node, channel, msg) if type(msg) ~= "string" then return @@ -81,7 +85,7 @@ local digiline_def = { end msg = msg:lower() if msg == "get" then - digilines.receptor_send(pos, digilines.rules.default, channel, { + digilines.receptor_send(pos, technic.digilines.rules, channel, { enabled = meta:get_int("enabled"), power = meta:get_int("power"), mesecon_mode = meta:get_int("mesecon_mode") diff --git a/technic/machines/switching_station.lua b/technic/machines/switching_station.lua index f902795..cc8f297 100644 --- a/technic/machines/switching_station.lua +++ b/technic/machines/switching_station.lua @@ -69,8 +69,12 @@ minetest.register_node("technic:switching_station",{ end, mesecons = mesecon_def, digiline = { - receptor = {action = function() end}, + receptor = { + rules = technic.digilines.rules, + action = function() end + }, effector = { + rules = technic.digilines.rules, action = function(pos, node, channel, msg) if msg ~= "GET" and msg ~= "get" then return @@ -79,7 +83,7 @@ minetest.register_node("technic:switching_station",{ if channel ~= meta:get_string("channel") then return end - digilines.receptor_send(pos, digilines.rules.default, channel, { + digilines.receptor_send(pos, technic.digilines.rules, channel, { supply = meta:get_int("supply"), demand = meta:get_int("demand") }) @@ -367,7 +371,7 @@ technic.switching_station_run = function(pos) if PR_eu_supply ~= meta:get_int("supply") or RE_eu_demand ~= meta:get_int("demand") then local channel = meta:get_string("channel") - digilines.receptor_send(pos, digilines.rules.default, channel, { + digilines.receptor_send(pos, technic.digilines.rules, channel, { supply = PR_eu_supply, demand = RE_eu_demand })