From 9938d13412f981177d436c546dc575ac71129988 Mon Sep 17 00:00:00 2001 From: paly2 Date: Thu, 10 Sep 2015 18:33:07 +0200 Subject: [PATCH] Add the "wireless jammer" --- README.md | 2 ++ moremesecons_wireless/init.lua | 33 ++++++++++++++++-- .../textures/moremesecons_jammer_off.png | Bin 0 -> 196 bytes .../textures/moremesecons_jammer_on.png | Bin 0 -> 262 bytes 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 moremesecons_wireless/textures/moremesecons_jammer_off.png create mode 100644 moremesecons_wireless/textures/moremesecons_jammer_on.png 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 0000000000000000000000000000000000000000..8f39a5a5c069d6800ebc9ec2a602dbf89217abca GIT binary patch literal 196 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#J|`EKu|j{dTOv?Mvcxr_#5q4VH#M(>!MP|ku_QG`p**uBL&4qCHz2%`PaLSo z&eO#)MC1J435I+O3Or1fkN@xQsqSU=)J_&Y#kg&1hGxiQMusXO5AXNV%VJI)pYO3g klIw=eB&FuJl}juhGVm%&^NSw+1#%XHr>mdKI;Vst034q-1poj5 literal 0 HcmV?d00001 diff --git a/moremesecons_wireless/textures/moremesecons_jammer_on.png b/moremesecons_wireless/textures/moremesecons_jammer_on.png new file mode 100644 index 0000000000000000000000000000000000000000..d689561a668a19f79bc40b32a8a46a7c07e34b96 GIT binary patch literal 262 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkP>{XE z)7O>#J|`EKg{ak$=uV)JWQl7;iF1B#Zfaf$gL6@8Vo7R>LV0FMhJw4NZ$Nk>pEyua zgQtsQh{pNeNr8L^6gZsY&%UdF`YyScInX>QY0FVD7dD3bzx7lW96hWqo$>zm>^bb4 zqCZ_`^sMq|l+{^VVkA8wc_(ws4b{XbPqi%@_q;8fWWcfO&w0T;90i#xiqe7#3KkVv zYE`^id@63m?^S||@%C>^{Wb1AaovCY@b}_9)(=_kay#