forked from MineClone5/MineClone5
Fix incorrect power transmission of buttons
This commit is contained in:
parent
f612d1b584
commit
4f9be58871
|
@ -550,55 +550,4 @@ function mesecon.is_powered(pos, rule)
|
||||||
else return sourcepos end
|
else return sourcepos end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Rules rotation Functions:
|
|
||||||
function mesecon.rotate_rules_right(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = -rule.z,
|
|
||||||
y = rule.y,
|
|
||||||
z = rule.x,
|
|
||||||
name = rule.name,
|
|
||||||
spread = rule.spread,})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.rotate_rules_left(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = rule.z,
|
|
||||||
y = rule.y,
|
|
||||||
z = -rule.x,
|
|
||||||
name = rule.name,
|
|
||||||
spread = rule.spread,})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.rotate_rules_down(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = -rule.y,
|
|
||||||
y = rule.x,
|
|
||||||
z = rule.z,
|
|
||||||
name = rule.name,
|
|
||||||
spread = rule.spread,})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
||||||
function mesecon.rotate_rules_up(rules)
|
|
||||||
local nr = {}
|
|
||||||
for i, rule in ipairs(rules) do
|
|
||||||
table.insert(nr, {
|
|
||||||
x = rule.y,
|
|
||||||
y = -rule.x,
|
|
||||||
z = rule.z,
|
|
||||||
name = rule.name,
|
|
||||||
spread = rule.spread,})
|
|
||||||
end
|
|
||||||
return nr
|
|
||||||
end
|
|
||||||
|
|
|
@ -42,12 +42,22 @@ mesecon.rules.buttonlike =
|
||||||
{x =-1, y = 0, z = 0},
|
{x =-1, y = 0, z = 0},
|
||||||
{x = 1, y = 0, z = 0, spread = true}}
|
{x = 1, y = 0, z = 0, spread = true}}
|
||||||
|
|
||||||
|
mesecon.rules.floor =
|
||||||
|
{{x = 1, y = 0, z = 0},
|
||||||
|
{x =-1, y = 0, z = 0},
|
||||||
|
{x = 0, y = 1, z = 0},
|
||||||
|
{x = 0, y =-1, z = 0, spread = true},
|
||||||
|
{x = 0, y = 0, z = 1},
|
||||||
|
{x = 0, y = 0, z =-1}}
|
||||||
|
|
||||||
mesecon.rules.flat =
|
mesecon.rules.flat =
|
||||||
{{x = 1, y = 0, z = 0},
|
{{x = 1, y = 0, z = 0},
|
||||||
{x =-1, y = 0, z = 0},
|
{x =-1, y = 0, z = 0},
|
||||||
{x = 0, y = 0, z = 1},
|
{x = 0, y = 0, z = 1},
|
||||||
{x = 0, y = 0, z =-1}}
|
{x = 0, y = 0, z =-1}}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-- NOT IN ORIGNAL MESECONS
|
-- NOT IN ORIGNAL MESECONS
|
||||||
mesecon.rules.mcl_alldirs_spread =
|
mesecon.rules.mcl_alldirs_spread =
|
||||||
{{x= 1, y= 0, z= 0, spread = true},
|
{{x= 1, y= 0, z= 0, spread = true},
|
||||||
|
@ -59,23 +69,41 @@ mesecon.rules.mcl_alldirs_spread =
|
||||||
|
|
||||||
-- END OF UNOFFICIAL RULES
|
-- END OF UNOFFICIAL RULES
|
||||||
|
|
||||||
mesecon.rules.buttonlike_get = function(node)
|
local rules_buttonlike = {
|
||||||
local rules = mesecon.rules.buttonlike
|
xp = mesecon.rules.buttonlike,
|
||||||
local dir = minetest.facedir_to_dir(node.param2)
|
xn = mesecon.rotate_rules_right(mesecon.rotate_rules_right(mesecon.rules.buttonlike)),
|
||||||
if dir.x == 1 then
|
yp = mesecon.rotate_rules_down(mesecon.rules.buttonlike),
|
||||||
-- No action needed
|
yn = mesecon.rotate_rules_up(mesecon.rules.buttonlike),
|
||||||
elseif dir.z == -1 then
|
zp = mesecon.rotate_rules_right(mesecon.rules.buttonlike),
|
||||||
rules=mesecon.rotate_rules_left(rules)
|
zn = mesecon.rotate_rules_left(mesecon.rules.buttonlike),
|
||||||
elseif dir.x == -1 then
|
}
|
||||||
rules=mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules))
|
|
||||||
elseif dir.z == 1 then
|
local rules_wallmounted = {
|
||||||
rules=mesecon.rotate_rules_right(rules)
|
xp = mesecon.rotate_rules_down(mesecon.rules.floor),
|
||||||
elseif dir.y == -1 then
|
xn = mesecon.rotate_rules_up(mesecon.rules.floor),
|
||||||
rules=mesecon.rotate_rules_up(rules)
|
yp = mesecon.rotate_rules_up(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
||||||
elseif dir.y == 1 then
|
yn = mesecon.rules.floor,
|
||||||
rules=mesecon.rotate_rules_down(rules)
|
zp = mesecon.rotate_rules_left(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
||||||
|
zn = mesecon.rotate_rules_right(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
||||||
|
}
|
||||||
|
|
||||||
|
local function rules_from_dir(ruleset, dir)
|
||||||
|
if dir.x == 1 then return ruleset.xp end
|
||||||
|
if dir.y == 1 then return ruleset.yp end
|
||||||
|
if dir.z == 1 then return ruleset.zp end
|
||||||
|
if dir.x == -1 then return ruleset.xn end
|
||||||
|
if dir.y == -1 then return ruleset.yn end
|
||||||
|
if dir.z == -1 then return ruleset.zn end
|
||||||
end
|
end
|
||||||
return rules
|
|
||||||
|
mesecon.rules.buttonlike_get = function(node)
|
||||||
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
|
return rules_from_dir(rules_buttonlike, dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
mesecon.rules.wallmounted_get = function(node)
|
||||||
|
local dir = minetest.wallmounted_to_dir(node.param2)
|
||||||
|
return rules_from_dir(rules_wallmounted, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
mesecon.state.on = "on"
|
mesecon.state.on = "on"
|
||||||
|
|
|
@ -6,6 +6,59 @@ function mesecon.move_node(pos, newpos)
|
||||||
minetest.get_meta(pos):from_table(meta)
|
minetest.get_meta(pos):from_table(meta)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--Rules rotation Functions:
|
||||||
|
function mesecon.rotate_rules_right(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = -rule.z,
|
||||||
|
y = rule.y,
|
||||||
|
z = rule.x,
|
||||||
|
name = rule.name,
|
||||||
|
spread = rule.spread,})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.rotate_rules_left(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = rule.z,
|
||||||
|
y = rule.y,
|
||||||
|
z = -rule.x,
|
||||||
|
name = rule.name,
|
||||||
|
spread = rule.spread,})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.rotate_rules_down(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = -rule.y,
|
||||||
|
y = rule.x,
|
||||||
|
z = rule.z,
|
||||||
|
name = rule.name,
|
||||||
|
spread = rule.spread,})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
|
function mesecon.rotate_rules_up(rules)
|
||||||
|
local nr = {}
|
||||||
|
for i, rule in ipairs(rules) do
|
||||||
|
table.insert(nr, {
|
||||||
|
x = rule.y,
|
||||||
|
y = -rule.x,
|
||||||
|
z = rule.z,
|
||||||
|
name = rule.name,
|
||||||
|
spread = rule.spread,})
|
||||||
|
end
|
||||||
|
return nr
|
||||||
|
end
|
||||||
|
|
||||||
function mesecon.flattenrules(allrules)
|
function mesecon.flattenrules(allrules)
|
||||||
--[[
|
--[[
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
-- A button that when pressed emits power for 1 second
|
-- A button that when pressed emits power for 1 second
|
||||||
-- and then turns off again
|
-- and then turns off again
|
||||||
|
|
||||||
local button_get_output_rules = mesecon.rules.buttonlike_get
|
local button_get_output_rules = mesecon.rules.wallmounted_get
|
||||||
|
|
||||||
local boxes_off = {
|
local boxes_off = {
|
||||||
type = "wallmounted",
|
type = "wallmounted",
|
||||||
|
|
|
@ -16,7 +16,9 @@ local rotate_torch_rules = function (rules, param2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local torch_get_output_rules = mesecon.rules.alldirs
|
local torch_get_output_rules = function()
|
||||||
|
return mesecon.rules.mcl_alldirs_spread
|
||||||
|
end
|
||||||
|
|
||||||
local torch_get_input_rules = function(node)
|
local torch_get_input_rules = function(node)
|
||||||
local rules = {{x = -2, y = 0, z = 0},
|
local rules = {{x = -2, y = 0, z = 0},
|
||||||
|
|
Loading…
Reference in New Issue