diff --git a/README.md b/README.md index 0a230d3..10e8e88 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ MoreMesecons is a mod for minetest wich adds some mesecons items. * `Adjustable Player Detector` : Like a mesecons player detector, but you can change its detection radius by right-click. * `Craftable Command Block` : A command block with just some commands accepted. The admin can change the accepted command (first line of the init.lua), default "tell". Only "@nearest" can be used in the commands, and the admin can change the maximum distance of "@nearest" (default 8 blocks). * `Dual Delayer` : If it receives a mesecons signal, port 1 turns on immediatly and port 2 turns on 0.4 seconds later. At the end of the signal, port 2 turns off immediatly and port 1 turns off 0.4 secondes later. For example, this is useful for double extenders. +* `Entity Detector` : You can use it to detect an entity. You can choose the entity to detect by right-click (use itemstring, for example "mobs:rat". To detect a dropped item, write "__builtin:item". To detect a specific dropped item, write its itemstring (for example "default:cobble")). * `Player Killer` : This block kills the nearest player (with a maximal distance of 8 blocks by default) (if this player isn't its owner) when it receives a mesecons signal. * `Sayer` : This node sends a message to every players inside a radius of 8 nodes. * `Signal Changer` : If it receives a signal on its pin "F", it turns on. If ti receives a signal on its pin "O", it turns off. @@ -21,3 +22,4 @@ MoreMesecons is a mod for minetest wich adds some mesecons items. * `Teleporter` : If you place one teleporter, if it receives a mesecons, it teleports the nearest player on itself. If you place two teleporters on the same axis, if one receives a mesecons signal, it teleports the nearest player on the second (with a maximal distance of 50 nodes by default). The player teleporter must be inside a radius of 25 nodes. * `Temporary Gate` : If it receives a mesecons signal, whatever its duration, a mesecons signal is send with a fixed duration. You can change it by right-click (in seconds) (you can write for example 0.2 to send a pulse, or 20 to send long signals). * `Wireless` : Place 2 (or more) wireless somewhere. Change their channel by right-click. If you send a signal to a wireless, every wireless wich have the same channel will send the signal. +* `Wireless Jammer` : If it receives a mesecons signal, it deactivates all wireless (receptors) in a radius of 15 nodes. diff --git a/moremesecons_wireless/init.lua b/moremesecons_wireless/init.lua index ca7a396..adcc481 100644 --- a/moremesecons_wireless/init.lua +++ b/moremesecons_wireless/init.lua @@ -1,3 +1,5 @@ +local JAMMER_MAX_DISTANCE = 15 + local wireless = {} local wireless_rids = {} @@ -18,7 +20,7 @@ local wireless_activate = function(pos) meta = minetest.get_meta(pos) channel_first_wireless = meta:get_string("channel") meta = minetest.get_meta(wireless[i]) - if wireless[i] ~= pos and meta:get_string("channel") == channel_first_wireless then + if wireless[i] ~= pos and meta:get_string("channel") == channel_first_wireless and not minetest.find_node_near(pos, JAMMER_MAX_DISTANCE, {"moremesecons_wireless:jammer_on"}) then mesecon.receptor_on(wireless[i]) end end @@ -33,7 +35,7 @@ local wireless_deactivate = function(pos) meta = minetest.get_meta(pos) channel_first_wireless = meta:get_string("channel") meta = minetest.get_meta(wireless[i]) - if wireless[i] ~= pos and meta:get_string("channel") == channel_first_wireless then + if wireless[i] ~= pos and meta:get_string("channel") == channel_first_wireless and not minetest.find_node_near(pos, JAMMER_MAX_DISTANCE, {"moremesecons_wireless:jammer_on"}) then mesecon.receptor_off(wireless[i]) end end @@ -69,6 +71,33 @@ minetest.register_node("moremesecons_wireless:wireless", { end, }) +mesecon.register_node("moremesecons_wireless:jammer", { + description="Wireless Jammer", + paramtype = "light", +},{ + tiles = {"moremesecons_jammer_off.png"}, + groups = {dig_immediate=2}, + mesecons = {effector = { + action_on = function(pos) + table.foreach(pos, print) + minetest.swap_node(pos, {name="moremesecons_wireless:jammer_on"}) + end }} +},{ + tiles = {"moremesecons_jammer_on.png"}, + groups = {dig_immediate=2, not_in_creative_inventory=1}, + mesecons = {effector = { + action_off = function(pos) + minetest.swap_node(pos, {name="moremesecons_wireless:jammer_off"}) + end }} +}) + +minetest.register_craft({ + output = "moremesecons_wireless:jammer_off", + recipe = { + {"moremesecons_wireless:wireless", "mesecons_torch:mesecon_torch_on", "moremesecons_wireless:wireless"} + } +}) + minetest.register_craft({ output = "moremesecons_wireless:wireless 2", recipe = { diff --git a/moremesecons_wireless/textures/moremesecons_jammer_off.png b/moremesecons_wireless/textures/moremesecons_jammer_off.png new file mode 100644 index 0000000..8f39a5a Binary files /dev/null and b/moremesecons_wireless/textures/moremesecons_jammer_off.png differ diff --git a/moremesecons_wireless/textures/moremesecons_jammer_on.png b/moremesecons_wireless/textures/moremesecons_jammer_on.png new file mode 100644 index 0000000..d689561 Binary files /dev/null and b/moremesecons_wireless/textures/moremesecons_jammer_on.png differ