forked from minetest-mods/MoreMesecons
Wireless: make an "on" version of the wireless node
This avoids self-activating bugs
This commit is contained in:
parent
5422017493
commit
ae9935fcca
@ -125,6 +125,7 @@ end
|
||||
|
||||
local is_jammed
|
||||
local function wireless_activate(pos)
|
||||
print("activating wireless at pos " .. minetest.pos_to_string(pos))
|
||||
if is_jammed(pos) then
|
||||
-- jamming doesn't disallow receiving signals, only sending them
|
||||
return
|
||||
@ -138,8 +139,10 @@ local function wireless_activate(pos)
|
||||
return
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, {name = "moremesecons_wireless:wireless_on"})
|
||||
for i, wl_pos in ipairs(wireless[owner][channel]) do
|
||||
if i ~= id then
|
||||
minetest.swap_node(wl_pos, {name = "moremesecons_wireless:wireless_on"})
|
||||
mesecon.receptor_on(wl_pos)
|
||||
end
|
||||
end
|
||||
@ -158,8 +161,10 @@ local function wireless_deactivate(pos)
|
||||
return
|
||||
end
|
||||
|
||||
minetest.swap_node(pos, {name = "moremesecons_wireless:wireless_off"})
|
||||
for i, wl_pos in ipairs(wireless[owner][channel]) do
|
||||
if i ~= id then
|
||||
minetest.swap_node(wl_pos, {name = "moremesecons_wireless:wireless_off"})
|
||||
mesecon.receptor_off(wl_pos)
|
||||
end
|
||||
end
|
||||
@ -186,17 +191,10 @@ local function on_digiline_receive(pos, node, channel, msg)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("moremesecons_wireless:wireless", {
|
||||
tiles = {"moremesecons_wireless.png"},
|
||||
mesecon.register_node("moremesecons_wireless:wireless", {
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
description = "Wireless",
|
||||
walkable = true,
|
||||
groups = {cracky=3},
|
||||
mesecons = {effector = {
|
||||
action_on = wireless_activate,
|
||||
action_off = wireless_deactivate
|
||||
}},
|
||||
digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
@ -237,8 +235,22 @@ minetest.register_node("moremesecons_wireless:wireless", {
|
||||
update_mod_storage()
|
||||
end
|
||||
end,
|
||||
}, {
|
||||
tiles = {"moremesecons_wireless_off.png"},
|
||||
groups = {cracky=3},
|
||||
mesecons = {effector = {
|
||||
action_on = wireless_activate,
|
||||
}},
|
||||
}, {
|
||||
tiles = {"moremesecons_wireless_on.png"},
|
||||
groups = {cracky=3, not_in_creative_inventory=1},
|
||||
mesecons = {effector = {
|
||||
action_off = wireless_deactivate
|
||||
}},
|
||||
})
|
||||
|
||||
minetest.register_alias("moremesecons_wireless:wireless", "moremesecons_wireless:wireless_off")
|
||||
|
||||
local jammers = {}
|
||||
local function add_jammer(pos)
|
||||
if get(jammers, pos.z,pos.y,pos.x) then
|
||||
@ -345,7 +357,7 @@ minetest.register_craft({
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "moremesecons_wireless:wireless 2",
|
||||
output = "moremesecons_wireless:wireless_off 2",
|
||||
recipe = {
|
||||
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
|
||||
{"", "mesecons_torch:mesecon_torch_on", ""},
|
||||
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
BIN
moremesecons_wireless/textures/moremesecons_wireless_on.png
Normal file
BIN
moremesecons_wireless/textures/moremesecons_wireless_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 KiB |
Loading…
Reference in New Issue
Block a user