Minor cleanup.

master
number Zero 2017-01-12 01:02:39 +03:00
parent f07d379cb1
commit eae5201d13
4 changed files with 30 additions and 40 deletions

View File

@ -3,26 +3,16 @@
local OVERLOAD_THRESHOLD = 20.0
local rules_in = {
[0] = {{x = -1, y = 0, z = 0}},
[1] = {{x = 0, y = 0, z = 1}},
[2] = {{x = 1, y = 0, z = 0}},
[3] = {{x = 0, y = 0, z = -1}},
}
local rules_out = {
[0] = {{x = 1, y = 0, z = 0}},
[1] = {{x = 0, y = 0, z = -1}},
[2] = {{x = -1, y = 0, z = 0}},
[3] = {{x = 0, y = 0, z = 1}},
}
local function diode_rules_in(node)
return rules_in[node.param2]
return {
digiline_routing.get_base_rule(0, node.param2),
}
end
local function diode_rules_out(node)
return rules_out[node.param2]
return {
digiline_routing.get_base_rule(2, node.param2),
}
end
local function diode_action(pos, node, channel, msg)

View File

@ -7,6 +7,7 @@ digiline_routing = {}
local MODNAME = "digiline_routing"
local MODPATH = minetest.get_modpath(MODNAME)
dofile(MODPATH.."/util.lua")
dofile(MODPATH.."/overheating.lua")
dofile(MODPATH.."/multiblock.lua")
dofile(MODPATH.."/diode.lua")

View File

@ -3,34 +3,17 @@
local OVERLOAD_THRESHOLD = 20.0
local BASE_RULES = {
[0] = {x = -1, y = 0, z = 0},
[1] = {x = 0, y = 0, z = 1},
[2] = {x = 1, y = 0, z = 0},
[3] = {x = 0, y = 0, z = -1},
}
local rules_in = {}
local rules_out = {}
for k = 0,3 do
rules_in[k] = {}
rules_out[k] = {}
-- for m = 0,2 do
-- table.insert(rules_in[k], BASE_RULES[(k + m + 3) % 4])
-- table.insert(rules_out[k], BASE_RULES[(k + m + 1) % 4])
-- end
table.insert(rules_in[k], BASE_RULES[(k) % 4])
table.insert(rules_in[k], BASE_RULES[(k + 2) % 4])
table.insert(rules_out[k], BASE_RULES[(k + 1) % 4])
end
local function splitter_rules_in(node)
return rules_in[node.param2]
return {
digiline_routing.get_base_rule(0, node.param2),
digiline_routing.get_base_rule(2, node.param2),
}
end
local function splitter_rules_out(node)
return rules_out[node.param2]
return {
digiline_routing.get_base_rule(1, node.param2),
}
end
local function splitter_place(...)

16
util.lua Normal file
View File

@ -0,0 +1,16 @@
-- © 2017 numberZero
-- License: GNU Lesser General Public License, version 2 (or any later version)
local BASE_RULES = {
[0] = {x = -1, y = 0, z = 0},
[1] = {x = 0, y = 0, z = 1},
[2] = {x = 1, y = 0, z = 0},
[3] = {x = 0, y = 0, z = -1},
}
digiline_routing.get_base_rule = function(rule, param2)
if param2 >= 4 then
return nil
end
return BASE_RULES[(rule + param2) % 4]
end