2012-12-09 13:28:32 +01:00
|
|
|
mesecon.rules = {}
|
2012-12-08 14:14:04 +01:00
|
|
|
mesecon.state = {}
|
|
|
|
|
2017-10-08 01:39:02 +02:00
|
|
|
mesecon.rules.default = {
|
|
|
|
{x = 0, y = 0, z = -1},
|
|
|
|
{x = 1, y = 0, z = 0},
|
|
|
|
{x = -1, y = 0, z = 0},
|
|
|
|
{x = 0, y = 0, z = 1},
|
|
|
|
{x = 1, y = 1, z = 0},
|
|
|
|
{x = 1, y = -1, z = 0},
|
|
|
|
{x = -1, y = 1, z = 0},
|
|
|
|
{x = -1, y = -1, z = 0},
|
|
|
|
{x = 0, y = 1, z = 1},
|
|
|
|
{x = 0, y = -1, z = 1},
|
|
|
|
{x = 0, y = 1, z = -1},
|
|
|
|
{x = 0, y = -1, z = -1},
|
|
|
|
}
|
|
|
|
|
2020-12-19 23:12:00 +03:00
|
|
|
mesecon.rules.floor = mesecon.merge_rule_sets(mesecon.rules.default, {{x = 0, y = -1, z = 0}})
|
2017-10-08 01:39:02 +02:00
|
|
|
|
2020-12-19 23:12:00 +03:00
|
|
|
mesecon.rules.pplate = mesecon.merge_rule_sets(mesecon.rules.floor, {{x = 0, y = -2, z = 0}})
|
2017-10-08 01:39:02 +02:00
|
|
|
|
|
|
|
mesecon.rules.buttonlike = {
|
|
|
|
{x = 1, y = 0, z = 0},
|
|
|
|
{x = 1, y = 1, z = 0},
|
|
|
|
{x = 1, y = -1, z = 0},
|
|
|
|
{x = 1, y = -1, z = 1},
|
|
|
|
{x = 1, y = -1, z = -1},
|
|
|
|
{x = 2, y = 0, z = 0},
|
|
|
|
}
|
|
|
|
|
|
|
|
mesecon.rules.flat = {
|
|
|
|
{x = 1, y = 0, z = 0},
|
|
|
|
{x = -1, y = 0, z = 0},
|
|
|
|
{x = 0, y = 0, z = 1},
|
|
|
|
{x = 0, y = 0, z = -1},
|
|
|
|
}
|
|
|
|
|
|
|
|
mesecon.rules.alldirs = {
|
|
|
|
{x = 1, y = 0, z = 0},
|
|
|
|
{x = -1, y = 0, z = 0},
|
|
|
|
{x = 0, y = 1, z = 0},
|
|
|
|
{x = 0, y = -1, z = 0},
|
|
|
|
{x = 0, y = 0, z = 1},
|
|
|
|
{x = 0, y = 0, z = -1},
|
|
|
|
}
|
|
|
|
|
|
|
|
local rules_wallmounted = {
|
|
|
|
xp = mesecon.rotate_rules_down(mesecon.rules.floor),
|
|
|
|
xn = mesecon.rotate_rules_up(mesecon.rules.floor),
|
|
|
|
yp = mesecon.rotate_rules_up(mesecon.rotate_rules_up(mesecon.rules.floor)),
|
|
|
|
yn = mesecon.rules.floor,
|
|
|
|
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 rules_buttonlike = {
|
|
|
|
xp = mesecon.rules.buttonlike,
|
|
|
|
xn = mesecon.rotate_rules_right(mesecon.rotate_rules_right(mesecon.rules.buttonlike)),
|
|
|
|
yp = mesecon.rotate_rules_down(mesecon.rules.buttonlike),
|
|
|
|
yn = mesecon.rotate_rules_up(mesecon.rules.buttonlike),
|
|
|
|
zp = mesecon.rotate_rules_right(mesecon.rules.buttonlike),
|
|
|
|
zn = mesecon.rotate_rules_left(mesecon.rules.buttonlike),
|
|
|
|
}
|
|
|
|
|
|
|
|
local function rules_from_dir(ruleset, dir)
|
2022-09-11 08:50:26 -04:00
|
|
|
if not dir then return {} end
|
|
|
|
|
2017-10-08 01:39:02 +02:00
|
|
|
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
|
2017-10-21 17:05:09 +03:00
|
|
|
if dir.z == -1 then return ruleset.zn end
|
2017-10-08 01:39:02 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
mesecon.rules.wallmounted_get = function(node)
|
|
|
|
local dir = minetest.wallmounted_to_dir(node.param2)
|
|
|
|
return rules_from_dir(rules_wallmounted, dir)
|
|
|
|
end
|
2015-10-04 13:30:34 +02:00
|
|
|
|
2012-12-09 13:28:32 +01:00
|
|
|
mesecon.rules.buttonlike_get = function(node)
|
2016-12-25 23:50:09 -06:00
|
|
|
local dir = minetest.facedir_to_dir(node.param2)
|
2017-10-08 01:39:02 +02:00
|
|
|
return rules_from_dir(rules_buttonlike, dir)
|
2012-12-09 13:28:32 +01:00
|
|
|
end
|
|
|
|
|
2012-12-08 14:14:04 +01:00
|
|
|
mesecon.state.on = "on"
|
|
|
|
mesecon.state.off = "off"
|