Add the "wireless jammer"

This commit is contained in:
paly2 2015-09-10 18:33:07 +02:00
parent d77d77e451
commit 9938d13412
4 changed files with 33 additions and 2 deletions

View File

@ -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.

View File

@ -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 = {

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B