Clean up the redstone rules

This commit is contained in:
Wuzzy 2018-01-12 01:37:32 +01:00
parent 54c0d1d750
commit e4ab20509f
7 changed files with 44 additions and 79 deletions

View file

@ -15,22 +15,6 @@ mesecon.rules.default =
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1}}
mesecon.rules.pplate = mesecon.mergetable(mesecon.rules.default, {{x=0, y=-2, z=0}})
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},
@ -39,6 +23,42 @@ mesecon.rules.alldirs =
{x= 0, y= 0, z= 1},
{x= 0, y= 0, z=-1}}
mesecon.rules.pplate =
{{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},
{x = 0, y = -2, 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}}
mesecon.rules.buttonlike =
{{x = 1, y = 0, z = 0},
{x = 1, y = 1, z = 0},
{x = 1, y =-1, z = 0},
{x = 1, y = 0, z =-1},
{x = 1, y = 0, z = 1},
{x = 2, y = 0, z = 0},
{x = 0, y = 1, z = 0},
{x = 0, y = -1, z = 0},
{x =-1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1}}
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},
{x = 2, y = 0, z = 0},
{x =-2, y = 0, z = 0},
{x = 0, y = 0, z = 2},
{x = 0, y = 0, z =-2}}
mesecon.rules.buttonlike_get = function(node)
local rules = mesecon.rules.buttonlike
local dir = minetest.facedir_to_dir(node.param2)

View file

@ -2,11 +2,7 @@
-- A button that when pressed emits power for 1 second
-- and then turns off again
-- FIXME: Power node behind as well
local button_get_output_rules = function(node)
local rules = mesecon.rules.alldirs
return rules
end
local button_get_output_rules = mesecon.rules.buttonlike_get
local boxes_off = {
type = "wallmounted",

View file

@ -26,7 +26,8 @@ The note block will only play a note when it is below air, otherwise, it stays s
mesecons = {effector = { -- play sound when activated
action_on = function (pos, node)
mesecon.noteblock_play(pos, node.param2)
end
end,
rules = mesecon.rules.alldirs,
}},
_mcl_blast_resistance = 4,
_mcl_hardness = 0.8,

View file

@ -10,22 +10,6 @@ local pp_box_on = {
fixed = { -7/16, -8/16, -7/16, 7/16, -7.5/16, 7/16 },
}
local pplate_rules = {
{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=-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=0},
{x=0, y=-2, z=0},
{x=0, y=1, z=0},
}
local function pp_on_timer(pos, elapsed)
local node = minetest.get_node(pos)
local basename = minetest.registered_nodes[node.name].pressureplate_basename
@ -68,7 +52,7 @@ local function pp_on_timer(pos, elapsed)
end
if disable then
minetest.set_node(pos, {name = basename .. "_off"})
mesecon.receptor_off(pos, pplate_rules)
mesecon.receptor_off(pos, mesecon.rules.pplate)
end
elseif node.name == basename .. "_off" then
for k, obj in pairs(objs) do
@ -76,7 +60,7 @@ local function pp_on_timer(pos, elapsed)
if obj_does_activate(obj, activated_by) then
if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.set_node(pos, {name = basename .. "_on"})
mesecon.receptor_on(pos, pplate_rules)
mesecon.receptor_on(pos, mesecon.rules.pplate)
break
end
end
@ -137,7 +121,7 @@ function mesecon.register_pressure_plate(basename, description, textures_off, te
groups = groups_off,
tiles = textures_off,
mesecons = {receptor = { state = mesecon.state.off, rules = pplate_rules }},
mesecons = {receptor = { state = mesecon.state.off, rules = mesecon.rules.pplate }},
_doc_items_longdesc = longdesc,
},{
node_box = pp_box_on,
@ -145,7 +129,7 @@ function mesecon.register_pressure_plate(basename, description, textures_off, te
groups = groups_on,
tiles = textures_on,
mesecons = {receptor = { state = mesecon.state.on, rules = pplate_rules }},
mesecons = {receptor = { state = mesecon.state.on, rules = mesecon.rules.pplate }},
_doc_items_create_entry = false,
})

View file

@ -1,17 +1,4 @@
local lever_get_output_rules = function(node)
local rules = {
{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 = -1, z = 0},
{x = 0, y = 1, z = 0},
}
local dir = minetest.facedir_to_dir(node.param2)
dir = vector.multiply(dir, 2)
table.insert(rules, dir)
return rules
end
local lever_get_output_rules = mesecon.rules.buttonlike_get
-- LEVER
minetest.register_node("mesecons_walllever:wall_lever_off", {

View file

@ -235,13 +235,6 @@ function mcl_doors:register_door(name, def)
end
end
local mrules = {
{x = 0, y = 0, z = -1},
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
}
minetest.register_node(name.."_b_1", {
tiles = {"blank.png", tt[2].."^[transformFXR90", tb[2], tb[2].."^[transformFX", tb[1], tb[1].."^[transformFX"},
paramtype = "light",
@ -274,7 +267,6 @@ function mcl_doors:register_door(name, def)
mesecons = { effector = {
action_on = on_mesecons_signal_open,
rules = mrules,
}},
can_dig = check_player_priv,
@ -322,7 +314,6 @@ function mcl_doors:register_door(name, def)
mesecons = { effector = {
action_on = on_mesecons_signal_open_top,
rules = mrules,
}},
can_dig = check_player_priv,
@ -370,7 +361,6 @@ function mcl_doors:register_door(name, def)
mesecons = { effector = {
action_off = on_mesecons_signal_close,
rules = mrules,
}},
can_dig = check_player_priv,
@ -418,7 +408,6 @@ function mcl_doors:register_door(name, def)
mesecons = { effector = {
action_off = on_mesecons_signal_close_top,
rules = mrules,
}},
can_dig = check_player_priv,

View file

@ -13,14 +13,6 @@ local mcl_hoppers_formspec =
"listring[current_name;main]"..
"listring[current_player;main]"
local redstone_rules =
{{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}}
-- Downwards hopper (base definition)
local def_hopper = {
@ -153,7 +145,6 @@ def_hopper_enabled.mesecons = {
action_on = function(pos, node)
minetest.swap_node(pos, {name="mcl_hoppers:hopper_disabled", param2=node.param2})
end,
rules = redstone_rules,
},
}
@ -170,7 +161,6 @@ def_hopper_disabled.mesecons = {
action_off = function(pos, node)
minetest.swap_node(pos, {name="mcl_hoppers:hopper", param2=node.param2})
end,
rules = redstone_rules,
},
}
@ -267,7 +257,6 @@ def_hopper_side_enabled.mesecons = {
action_on = function(pos, node)
minetest.swap_node(pos, {name="mcl_hoppers:hopper_side_disabled", param2=node.param2})
end,
rules = redstone_rules,
},
}
minetest.register_node("mcl_hoppers:hopper_side", def_hopper_side_enabled)
@ -279,7 +268,6 @@ def_hopper_side_disabled.mesecons = {
action_off = function(pos, node)
minetest.swap_node(pos, {name="mcl_hoppers:hopper_side", param2=node.param2})
end,
rules = redstone_rules,
},
}
minetest.register_node("mcl_hoppers:hopper_side_disabled", def_hopper_side_disabled)