2017-03-01 04:57:58 +01:00
|
|
|
digilines = {}
|
2022-08-13 15:03:12 +02:00
|
|
|
digilines.S = minetest.get_translator("digilines")
|
2017-03-01 04:57:58 +01:00
|
|
|
|
2023-12-02 21:45:07 +01:00
|
|
|
digilines.mcl = minetest.get_modpath("mcl_core")
|
|
|
|
|
|
|
|
-- sounds check
|
|
|
|
if minetest.get_modpath("default") then digilines.sounds = default end
|
|
|
|
if digilines.mcl then digilines.sounds = mcl_sounds end
|
|
|
|
|
|
|
|
|
2017-03-01 11:47:26 +01:00
|
|
|
-- Backwards compatibility code.
|
|
|
|
-- We define a proxy table whose methods can be called with the
|
|
|
|
-- `foo:bar` notation, and it will redirect the call to the
|
|
|
|
-- real function, dropping the first implicit argument.
|
|
|
|
local digiline; digiline = setmetatable({}, {
|
|
|
|
__index = function(_, k)
|
|
|
|
-- Get method from real table.
|
|
|
|
local v = digilines[k]
|
|
|
|
if type(v) == "function" then
|
|
|
|
-- We need to wrap functions in order to ignore
|
|
|
|
-- the implicit `self` argument.
|
|
|
|
local f = v
|
|
|
|
return function(self, ...)
|
|
|
|
-- Trap invalid calls of the form `digiline.foo(...)`.
|
|
|
|
assert(self == digiline)
|
|
|
|
return f(...)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return v
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
rawset(_G, "digiline", digiline)
|
|
|
|
|
|
|
|
-- Let's test our proxy table.
|
|
|
|
function digilines._testproxy(x)
|
|
|
|
return x
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Test using old `digiline:foobar` form.
|
|
|
|
assert(digiline:_testproxy("foobar") == "foobar")
|
|
|
|
|
|
|
|
-- Test using new `digilines.foobar` form.
|
|
|
|
assert(digilines._testproxy("foobar") == "foobar")
|
|
|
|
|
|
|
|
-- Test calling incorrect form raises an error.
|
|
|
|
assert(not pcall(function() digiline._testproxy("foobar") end))
|
2016-05-28 01:08:53 +02:00
|
|
|
|
|
|
|
local modpath = minetest.get_modpath("digilines")
|
|
|
|
dofile(modpath .. "/presetrules.lua")
|
|
|
|
dofile(modpath .. "/util.lua")
|
|
|
|
dofile(modpath .. "/internal.lua")
|
|
|
|
dofile(modpath .. "/wires_common.lua")
|
|
|
|
dofile(modpath .. "/wire_std.lua")
|
2013-01-20 00:03:51 +01:00
|
|
|
|
2017-03-01 11:26:20 +01:00
|
|
|
function digilines.receptor_send(pos, rules, channel, msg)
|
2013-01-20 00:03:51 +01:00
|
|
|
local checked = {}
|
2017-02-20 00:15:00 +01:00
|
|
|
checked[minetest.hash_node_position(pos)] = true -- exclude itself
|
2013-01-20 00:03:51 +01:00
|
|
|
for _,rule in ipairs(rules) do
|
2017-03-01 11:26:20 +01:00
|
|
|
if digilines.rules_link(pos, digilines.addPosRule(pos, rule)) then
|
|
|
|
digilines.transmit(digilines.addPosRule(pos, rule), channel, msg, checked)
|
2013-01-20 00:03:51 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2013-05-10 22:56:47 +02:00
|
|
|
|
2023-12-02 21:45:07 +01:00
|
|
|
local fiber = "mesecons_materials:fiber"
|
|
|
|
local insulated = "mesecons_insulated:insulated_off"
|
|
|
|
local gold_ingot = "default:gold_ingot"
|
|
|
|
|
|
|
|
if digilines.mcl then
|
|
|
|
gold_ingot = "mcl_core:gold_ingot"
|
|
|
|
-- MCL dont support mesecons insulated
|
|
|
|
if not minetest.get_modpath("mesecons_insulated") then
|
|
|
|
insulated = "mesecons:redstone"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-05-10 22:56:47 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
output = 'digilines:wire_std_00000000 2',
|
|
|
|
recipe = {
|
2023-12-02 21:45:07 +01:00
|
|
|
{fiber, fiber, fiber},
|
|
|
|
{insulated, insulated, gold_ingot},
|
|
|
|
{fiber, fiber, fiber},
|
2013-05-10 22:56:47 +02:00
|
|
|
}
|
2016-05-28 01:08:53 +02:00
|
|
|
})
|
|
|
|
|
2019-03-06 06:35:36 +01:00
|
|
|
-- For minetest 0.4 support returned nil are also tested: ~= false
|
|
|
|
if minetest.settings:get_bool("digilines_enable_inventory", true) ~= false then
|
2016-05-28 01:08:53 +02:00
|
|
|
dofile(modpath .. "/inventory.lua")
|
|
|
|
end
|
|
|
|
|
2019-03-06 06:35:36 +01:00
|
|
|
if minetest.settings:get_bool("digilines_enable_lcd", true) ~= false then
|
2016-05-28 01:08:53 +02:00
|
|
|
dofile(modpath .. "/lcd.lua")
|
|
|
|
end
|
|
|
|
|
2019-03-06 06:35:36 +01:00
|
|
|
if minetest.settings:get_bool("digilines_enable_lightsensor", true) ~= false then
|
2016-05-28 01:08:53 +02:00
|
|
|
dofile(modpath .. "/lightsensor.lua")
|
|
|
|
end
|
|
|
|
|
2019-03-06 06:35:36 +01:00
|
|
|
if minetest.settings:get_bool("digilines_enable_rtc", true) ~= false then
|
2016-05-28 01:08:53 +02:00
|
|
|
dofile(modpath .. "/rtc.lua")
|
|
|
|
end
|