Add a setting for disabling the wireless jammer

Fixes #17
This commit is contained in:
upsilon 2021-03-07 10:23:29 +01:00
parent 227cba54b2
commit 021100b3d4
2 changed files with 75 additions and 70 deletions

View File

@ -330,6 +330,15 @@ mesecon.register_node("moremesecons_wireless:wireless", {
minetest.register_alias("moremesecons_wireless:wireless", "moremesecons_wireless:wireless_off") minetest.register_alias("moremesecons_wireless:wireless", "moremesecons_wireless:wireless_off")
minetest.register_craft({
output = "moremesecons_wireless:wireless_off 2",
recipe = {
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
{"", "mesecons_torch:mesecon_torch_on", ""},
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
}
})
local function remove_jammer(pos) local function remove_jammer(pos)
moremesecons.remove_data_from_pos(jammers, pos) moremesecons.remove_data_from_pos(jammers, pos)
end end
@ -357,83 +366,76 @@ function is_jammed(pos)
return false return false
end end
mesecon.register_node("moremesecons_wireless:jammer", { if moremesecons.setting("wireless", "enable_jammer", true) then
description = "Wireless Jammer", mesecon.register_node("moremesecons_wireless:jammer", {
paramtype = "light", description = "Wireless Jammer",
drawtype = "nodebox", paramtype = "light",
},{ drawtype = "nodebox",
tiles = {"mesecons_wire_off.png^moremesecons_jammer_top.png", "moremesecons_jammer_bottom.png", "mesecons_wire_off.png^moremesecons_jammer_side_off.png"}, },{
node_box = { tiles = {"mesecons_wire_off.png^moremesecons_jammer_top.png", "moremesecons_jammer_bottom.png", "mesecons_wire_off.png^moremesecons_jammer_side_off.png"},
type = "fixed", node_box = {
fixed = { type = "fixed",
-- connection fixed = {
{-1/16, -0.5, -0.5, 1/16, -7/16, 0.5}, -- connection
{-0.5, -0.5, -1/16, 0.5, -7/16, 1/16}, {-1/16, -0.5, -0.5, 1/16, -7/16, 0.5},
{-0.5, -0.5, -1/16, 0.5, -7/16, 1/16},
--stabilization --stabilization
{-1/16, -7/16, -1/16, 1/16, -6/16, 1/16}, {-1/16, -7/16, -1/16, 1/16, -6/16, 1/16},
-- fields -- fields
{-7/16, -6/16, -7/16, 7/16, -4/16, 7/16}, {-7/16, -6/16, -7/16, 7/16, -4/16, 7/16},
{-5/16, -4/16, -5/16, 5/16, -3/16, 5/16}, {-5/16, -4/16, -5/16, 5/16, -3/16, 5/16},
{-3/16, -3/16, -3/16, 3/16, -2/16, 3/16}, {-3/16, -3/16, -3/16, 3/16, -2/16, 3/16},
{-1/16, -2/16, -1/16, 1/16, -1/16, 1/16}, {-1/16, -2/16, -1/16, 1/16, -1/16, 1/16},
},
}, },
}, groups = {dig_immediate=2},
groups = {dig_immediate=2}, mesecons = {effector = {
mesecons = {effector = { rules = mesecon.rules.flat,
rules = mesecon.rules.flat, action_on = function(pos)
action_on = function(pos) add_jammer(pos)
add_jammer(pos) minetest.swap_node(pos, {name="moremesecons_wireless:jammer_on"})
minetest.swap_node(pos, {name="moremesecons_wireless:jammer_on"}) end
end }}
}} },{
},{ tiles = {"mesecons_wire_on.png^moremesecons_jammer_top.png", "moremesecons_jammer_bottom.png", "mesecons_wire_on.png^moremesecons_jammer_side_on.png"},
tiles = {"mesecons_wire_on.png^moremesecons_jammer_top.png", "moremesecons_jammer_bottom.png", "mesecons_wire_on.png^moremesecons_jammer_side_on.png"}, node_box = {
node_box = { type = "fixed",
type = "fixed", fixed = {
fixed = { -- connection
-- connection {-1/16, -0.5, -0.5, 1/16, -7/16, 0.5},
{-1/16, -0.5, -0.5, 1/16, -7/16, 0.5}, {-0.5, -0.5, -1/16, 0.5, -7/16, 1/16},
{-0.5, -0.5, -1/16, 0.5, -7/16, 1/16},
--stabilization --stabilization
{-1/16, -7/16, -1/16, 1/16, 5/16, 1/16}, {-1/16, -7/16, -1/16, 1/16, 5/16, 1/16},
-- fields -- fields
{-7/16, -6/16, -7/16, 7/16, -4/16, 7/16}, {-7/16, -6/16, -7/16, 7/16, -4/16, 7/16},
{-5/16, -3/16, -5/16, 5/16, -1/16, 5/16}, {-5/16, -3/16, -5/16, 5/16, -1/16, 5/16},
{-3/16, 0, -3/16, 3/16, 2/16, 3/16}, {-3/16, 0, -3/16, 3/16, 2/16, 3/16},
{-1/16, 3/16, -1/16, 1/16, 5/16, 1/16}, {-1/16, 3/16, -1/16, 1/16, 5/16, 1/16},
},
}, },
}, groups = {dig_immediate=2, not_in_creative_inventory=1},
groups = {dig_immediate=2, not_in_creative_inventory=1}, mesecons = {effector = {
mesecons = {effector = { rules = mesecon.rules.flat,
rules = mesecon.rules.flat, action_off = function(pos)
action_off = function(pos) remove_jammer(pos)
remove_jammer(pos) minetest.swap_node(pos, {name="moremesecons_wireless:jammer_off"})
minetest.swap_node(pos, {name="moremesecons_wireless:jammer_off"}) end
end }},
}}, on_destruct = remove_jammer,
on_destruct = remove_jammer, on_construct = add_jammer,
on_construct = add_jammer, })
})
minetest.register_craft({ minetest.register_craft({
output = "moremesecons_wireless:jammer_off", output = "moremesecons_wireless:jammer_off",
recipe = { recipe = {
{"moremesecons_wireless:wireless", "mesecons_torch:mesecon_torch_on", "moremesecons_wireless:wireless"} {"moremesecons_wireless:wireless", "mesecons_torch:mesecon_torch_on", "moremesecons_wireless:wireless"}
} }
}) })
end
minetest.register_craft({
output = "moremesecons_wireless:wireless_off 2",
recipe = {
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
{"", "mesecons_torch:mesecon_torch_on", ""},
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
}
})
if moremesecons.setting("wireless", "enable_lbm", false) then if moremesecons.setting("wireless", "enable_lbm", false) then
minetest.register_lbm({ minetest.register_lbm({

View File

@ -63,6 +63,9 @@ moremesecons_teleporter.enable_lbm (Enable Registration LBM) bool false
[Wireless] [Wireless]
# Whether to enable the wireless jammer node
moremesecons_wireless.enable_jammer (Enable wireless jammer) bool true
# Wireless Jammer action range # Wireless Jammer action range
# Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value # Any value less than or equal to 0 will be changed to 1 and a NaN value will be changed to the default value
moremesecons_wireless.jammer_max_distance (Wireless Jammer action range) float 15 moremesecons_wireless.jammer_max_distance (Wireless Jammer action range) float 15