Consolidate horizontal rules getters (#602)

This commit is contained in:
Jude Melton-Houghton
2022-06-05 05:19:18 -04:00
committed by GitHub
parent 58305f52bc
commit 0a4a88b1b9
8 changed files with 49 additions and 89 deletions

View File

@ -11,25 +11,14 @@ local nodebox = {
},
}
local function gate_rotate_rules(node, rules)
for rotations = 0, node.param2 - 1 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local gate_get_output_rules = mesecon.horiz_rules_getter({{x = 1, y = 0, z = 0}})
local function gate_get_output_rules(node)
return gate_rotate_rules(node, {{x=1, y=0, z=0}})
end
local gate_get_input_rules_oneinput = mesecon.horiz_rules_getter({{x =-1, y = 0, z = 0}})
local function gate_get_input_rules_oneinput(node)
return gate_rotate_rules(node, {{x=-1, y=0, z=0}})
end
local function gate_get_input_rules_twoinputs(node)
return gate_rotate_rules(node, {{x=0, y=0, z=1, name="input1"},
{x=0, y=0, z=-1, name="input2"}})
end
local gate_get_input_rules_twoinputs = mesecon.horiz_rules_getter({
{x = 0, y = 0, z = 1, name = "input1"},
{x = 0, y = 0, z = -1, name = "input2"},
})
local function set_gate(pos, node, state)
local gate = minetest.registered_nodes[node.name]