Fix a bug for temporarygate and add Signalchanger

This commit is contained in:
palige 2015-08-28 12:24:33 +02:00
commit a673ceb374
53 changed files with 1552 additions and 0 deletions

15
README.txt Normal file

@ -0,0 +1,15 @@
MOREMESECONS
By palige
Based on Mesecons by Jeija
With the participation of Mg
MoreMesecons add few mesecons objects to simplify circuits and add new possibilities.
NEW NODES ARE :
SWITCH TORCH : This torch must be connected like a mesetorch. On the first mesecons signal, it switch on. On the second mesecons signal, it switch off. This is a switch controlled by a mesecons signal. You can use it like a memory for example.
TEMPORARY GATE : This node must be connected like a mesecons delayer. If it receive a signal (short or long), it send a signal of duration can be modified by punch (1, 2, 3 or 4 seconds).
ADJUSTABLE BLINKY PLANT : Like a blinky plant, but you can change the signal duration with a right click.
PLAYER KILLER : This node must be connected like a player detector. If it receive a mesecons signal, the nearest player of player killer died. The maximal distance is 8.
TELEPORTER : This node teleports the nearest player at the position of the other teleporter in the same line (two identical directions (x, z or y). For example, first teleporter is at 33,10,-1057 ; and the second can be at 33,56,-1057 but NOT in 30,56,-1057.). They must are 2 teleporters.
WIRELESS : If you want to send a mesecons signal on very long distance, when you can't use "Mesecons", you can use "wireless" ! Put 2 wireless (or more if you want), type the channel and send a signal to the first : the second re-send it !
CRAFTABLE COMMAND BLOCK : You can't use command block in survival... So, MoreMesecons introduce the Craftable Command Block. You can choose authorized commands : just set the "accepted_commands" list on the begin of the init.lua file. If you don't give any commands, all commands will be accepted. This is especially useful for servers administrators.

1
modpack.txt Normal file

@ -0,0 +1 @@
The presence of this file indicates that the current folder is a modpack.

1
moremesecons/depends.txt Normal file

@ -0,0 +1 @@
mesecons

1
moremesecons/init.lua Normal file

@ -0,0 +1 @@
print("[OK] MoreMesecons")

0
moremesecons/init.lua~ Normal file

@ -0,0 +1 @@
mesecons

@ -0,0 +1,61 @@
-- The ADJUSTBALE_BLINKY_PLANT
-- File copy on blinky_plant by Jeija
local toggle_timer = function (pos, restart)
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
if timer:is_started() and not restart then
timer:stop()
else
timer:start(tonumber(meta:get_int("interval")))
end
end
local on_timer = function (pos)
local node = minetest.get_node(pos)
if(mesecon.flipstate(pos, node) == "on") then
mesecon.receptor_on(pos)
else
mesecon.receptor_off(pos)
end
toggle_timer(pos, false)
end
mesecon.register_node("moremesecons_adjustable_blinkyplant:adjustable_blinky_plant", {
description="Adjustable Blinky Plant",
drawtype = "plantlike",
inventory_image = "jeija_blinky_plant_off.png",
paramtype = "light",
walkable = false,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
},
on_timer = on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[interval;interval;${interval}]")
toggle_timer(pos, true)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
meta:set_string("interval", fields.interval)
toggle_timer(pos, true)
end,
},{
tiles = {"jeija_blinky_plant_off.png"},
groups = {dig_immediate=3},
mesecons = {receptor = { state = mesecon.state.off }}
},{
tiles = {"jeija_blinky_plant_on.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
mesecons = {receptor = { state = mesecon.state.on }},
})
minetest.register_craft({
output = "moremesecons_adjustable_blinkyplant:adjustable_blinky_plant_off 1",
recipe = { {"mesecons_blinkyplant:blinky_plant_off"},
{"default:mese_crystal_fragment"},}
})

@ -0,0 +1,62 @@
-- The ADJUSTBALE_BLINKY_PLANT
-- File copy on blinky_plant by Jeija
local toggle_timer = function (pos, restart)
local timer = minetest.get_node_timer(pos)
local meta = minetest.get_meta(pos)
if timer:is_started() and not restart then
timer:stop()
else
timer:start(tonumber(meta:get_int("interval")))
end
end
local on_timer = function (pos)
local node = minetest.get_node(pos)
if(mesecon.flipstate(pos, node) == "on") then
mesecon.receptor_on(pos)
else
mesecon.receptor_off(pos)
end
toggle_timer(pos, false)
end
mesecon.register_node("moremesecons_adjustable_blinkyplant:adjustable_blinky_plant", {
description="Adjustable Blinky Plant",
drawtype = "plantlike",
inventory_image = "jeija_blinky_plant_off.png",
paramtype = "light",
walkable = false,
sounds = default.node_sound_leaves_defaults(),
selection_box = {
type = "fixed",
fixed = {-0.3, -0.5, -0.3, 0.3, -0.5+0.7, 0.3},
},
on_timer = on_timer,
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[interval;interval;${interval}]")
toggle_timer(pos, true)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if not fields.interval then return end
meta:set_string("interval", fields.interval)
toggle_timer(pos, true)
end,
},{
tiles = {"jeija_blinky_plant_off.png"},
groups = {dig_immediate=3},
mesecons = {receptor = { state = mesecon.state.off }}
},{
tiles = {"jeija_blinky_plant_on.png"},
groups = {dig_immediate=3, not_in_creative_inventory=1},
mesecons = {receptor = { state = mesecon.state.on }},
})
minetest.register_craft({
output = "moremesecons_adjustable_blinkyplant:adjustable_blinky_plant_off 1",
recipe = { {"mesecons_blinkyplant:blinky_plant_off"},
{"default:mese_crystal_fragment"},}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 B

@ -0,0 +1 @@
mesecons

@ -0,0 +1,174 @@
accepted_commands = {"say", "tell"} -- Authorized commands. Any to accept all.
local function initialize_data(meta)
local commands = meta:get_string("commands")
meta:set_string("formspec",
"invsize[9,5;]" ..
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
"label[1,3.8;@nearest, @farthest, and @random are replaced by the respective player names]" ..
"button_exit[3.3,4.5;2,1;submit;Submit]")
local owner = meta:get_string("owner")
if owner == "" then
owner = "not owned"
else
owner = "owned by " .. owner
end
meta:set_string("infotext", "Command Block\n" ..
"(" .. owner .. ")\n" ..
"Commands: "..commands)
end
local function construct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("commands", "tell @nearest Commandblock unconfigured")
meta:set_string("owner", "")
initialize_data(meta)
end
local function after_place(pos, placer)
if placer then
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
initialize_data(meta)
end
end
local function receive_fields(pos, formname, fields, sender)
if not fields.submit then
return
end
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" and sender:get_player_name() ~= owner then
return
end
meta:set_string("commands", fields.commands)
initialize_data(meta)
end
local function resolve_commands(commands, pos)
local nearest, farthest = nil, nil
local min_distance, max_distance = math.huge, -1
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player:get_player_name()
end
if distance > max_distance then
max_distance = distance
farthest = player:get_player_name()
end
end
local random = players[math.random(#players)]:get_player_name()
commands = commands:gsub("@nearest", nearest)
commands = commands:gsub("@farthest", farthest)
commands = commands:gsub("@random", random)
return commands
end
local function commandblock_action_on(pos, node)
if node.name ~= "moremesecons_commandblock:commandblock_off" then
return
end
minetest.swap_node(pos, {name = "moremesecons_commandblock:commandblock_on"})
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner == "" then
return
end
local commands = resolve_commands(meta:get_string("commands"), pos)
for _, command in pairs(commands:split("\n")) do
local pos = command:find(" ")
local cmd, param = command, ""
if pos then
cmd = command:sub(1, pos - 1)
param = command:sub(pos + 1)
end
local cmddef = minetest.chatcommands[cmd]
local is_an_authorized_command = false
for i = 1, #accepted_commands do
if cmd == accepted_commands[i] then
is_an_authorized_command = true
break
end
end
if not is_an_authorized_command and #accepted_commands ~= 0 then
minetest.chat_send_player(owner, "You can not execute this command with a craftable command block ! This event will be reported.")
minetest.log("action", "Player "..owner.." tryed to execute an unauthorized command with a craftable command block.")
return
end
if not cmddef then
minetest.chat_send_player(owner, "The command "..cmd.." does not exist")
return
end
local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs)
if not has_privs then
minetest.chat_send_player(owner, "You don't have permission "
.."to run "..cmd
.." (missing privileges: "
..table.concat(missing_privs, ", ")..")")
return
end
cmddef.func(owner, param)
end
end
local function commandblock_action_off(pos, node)
if node.name == "moremesecons_commandblock:commandblock_on" then
minetest.swap_node(pos, {name = "moremesecons_commandblock:commandblock_off"})
end
end
local function can_dig(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
return owner == "" or owner == player:get_player_name()
end
minetest.register_node("moremesecons_commandblock:commandblock_off", {
description = "Craftable Command Block",
tiles = {"jeija_commandblock_off.png"},
inventory_image = minetest.inventorycube("jeija_commandblock_off.png"),
groups = {cracky=2, mesecon_effector_off=1},
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = can_dig,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = commandblock_action_on
}}
})
minetest.register_node("moremesecons_commandblock:commandblock_on", {
tiles = {"jeija_commandblock_on.png"},
groups = {cracky=2, mesecon_effector_on=1, not_in_creative_inventory=1},
light_source = 10,
drop = "moremesecons_commandblock:commandblock_off",
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = can_dig,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_off = commandblock_action_off
}}
})
minetest.register_craft({
output = "moremoremesecons_commandblock:commandblock_off",
recipe = {
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"},
{"default:mese_crystal","group:mesecon_conductor_craftable","default:mese_crystal"},
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"}
}
})

@ -0,0 +1,174 @@
accepted_commands = {"say", "tell"} -- Authorized commands. Any to accept all.
local function initialize_data(meta)
local commands = meta:get_string("commands")
meta:set_string("formspec",
"invsize[9,5;]" ..
"textarea[0.5,0.5;8.5,4;commands;Commands;"..commands.."]" ..
"label[1,3.8;@nearest, @farthest, and @random are replaced by the respective player names]" ..
"button_exit[3.3,4.5;2,1;submit;Submit]")
local owner = meta:get_string("owner")
if owner == "" then
owner = "not owned"
else
owner = "owned by " .. owner
end
meta:set_string("infotext", "Command Block\n" ..
"(" .. owner .. ")\n" ..
"Commands: "..commands)
end
local function construct(pos)
local meta = minetest.get_meta(pos)
meta:set_string("commands", "tell @nearest Commandblock unconfigured")
meta:set_string("owner", "")
initialize_data(meta)
end
local function after_place(pos, placer)
if placer then
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
initialize_data(meta)
end
end
local function receive_fields(pos, formname, fields, sender)
if not fields.submit then
return
end
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner ~= "" and sender:get_player_name() ~= owner then
return
end
meta:set_string("commands", fields.commands)
initialize_data(meta)
end
local function resolve_commands(commands, pos)
local nearest, farthest = nil, nil
local min_distance, max_distance = math.huge, -1
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player:get_player_name()
end
if distance > max_distance then
max_distance = distance
farthest = player:get_player_name()
end
end
local random = players[math.random(#players)]:get_player_name()
commands = commands:gsub("@nearest", nearest)
commands = commands:gsub("@farthest", farthest)
commands = commands:gsub("@random", random)
return commands
end
local function commandblock_action_on(pos, node)
if node.name ~= "moremesecons_commandblock:commandblock_off" then
return
end
minetest.swap_node(pos, {name = "moremesecons_commandblock:commandblock_on"})
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if owner == "" then
return
end
local commands = resolve_commands(meta:get_string("commands"), pos)
for _, command in pairs(commands:split("\n")) do
local pos = command:find(" ")
local cmd, param = command, ""
if pos then
cmd = command:sub(1, pos - 1)
param = command:sub(pos + 1)
end
local cmddef = minetest.chatcommands[cmd]
local is_an_authorized_command = false
for i = 1, #accepted_commands do
if cmd == accepted_commands[i] then
is_an_authorized_command = true
break
end
end
if not is_an_authorized_command and #accepted_commands ~= 0 then
minetest.chat_send_player(owner, "You can not execute this command with a craftable command block ! This event will be reported.")
minetest.log("action", "Player "..owner.." tryed tu execute an unauthorized command with a craftable command block.")
return
end
if not cmddef then
minetest.chat_send_player(owner, "The command "..cmd.." does not exist")
return
end
local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs)
if not has_privs then
minetest.chat_send_player(owner, "You don't have permission "
.."to run "..cmd
.." (missing privileges: "
..table.concat(missing_privs, ", ")..")")
return
end
cmddef.func(owner, param)
end
end
local function commandblock_action_off(pos, node)
if node.name == "moremesecons_commandblock:commandblock_on" then
minetest.swap_node(pos, {name = "moremesecons_commandblock:commandblock_off"})
end
end
local function can_dig(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
return owner == "" or owner == player:get_player_name()
end
minetest.register_node("moremesecons_commandblock:commandblock_off", {
description = "Craftable Command Block",
tiles = {"jeija_commandblock_off.png"},
inventory_image = minetest.inventorycube("jeija_commandblock_off.png"),
groups = {cracky=2, mesecon_effector_off=1},
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = can_dig,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = commandblock_action_on
}}
})
minetest.register_node("moremesecons_commandblock:commandblock_on", {
tiles = {"jeija_commandblock_on.png"},
groups = {cracky=2, mesecon_effector_on=1, not_in_creative_inventory=1},
light_source = 10,
drop = "moremesecons_commandblock:commandblock_off",
on_construct = construct,
after_place_node = after_place,
on_receive_fields = receive_fields,
can_dig = can_dig,
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_off = commandblock_action_off
}}
})
minetest.register_craft({
output = "moremoremesecons_commandblock:commandblock_off",
recipe = {
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"},
{"default:mese_crystal","group:mesecon_conductor_craftable","default:mese_crystal"},
{"group:mesecon_conductor_craftable","default:mese_crystal","group:mesecon_conductor_craftable"}
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

@ -0,0 +1,2 @@
mesecons
mesecons_materials

@ -0,0 +1,51 @@
local kill_nearest_player = function(pos)
local MAX_DISTANCE = 8 -- Use this number to set maximal distance to kill
-- Search the nearest player
local nearest = nil
local min_distance = math.huge
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player
end
end
-- And kill him
meta = minetest.get_meta(pos)
owner = meta:get_string("owner")
if owner then
if vector.distance(pos, nearest:getpos()) < MAX_DISTANCE and owner ~= nearest:get_player_name() then
nearest:set_hp(0)
end
end
end
minetest.register_craft({
output = "moremesecons_playerkiller:playerkiller 1",
recipe = { {"","default:apple",""},
{"default:apple","mesecons_detector:object_detector_off","default:apple"},
{"","default:apple",""}}
})
minetest.register_node("moremesecons_playerkiller:playerkiller", {
tiles = {"top.png", "top.png", "side.png", "side.png", "side.png", "side.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3},
description="Player Killer",
mesecons = {effector = {
state = mesecon.state.off,
action_on = kill_nearest_player
}},
after_place_node = function(pos, placer)
meta = minetest.get_meta(pos)
if placer then
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", "PlayerKiller owned by " .. meta:get_string("owner"))
end
end,
sounds = default.node_sound_stone_defaults(),
})

@ -0,0 +1,51 @@
local kill_nearest_player = function(pos)
local MAX_DISTANCE = 8 -- Use this number to set maximal distance to kill
-- Search the nearest player
local nearest = nil
local min_distance = math.huge
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player
end
end
-- And kill him
meta = minetest.get_meta(pos)
owner = meta:get_string("owner")
if owner then
if vector.distance(pos, nearest:getpos()) < MAX_DISTANCE and owner ~= nearest:get_player_name() then
nearest:set_hp(0)
end
end
end
minetest.register_craft({
output = "moremesecons_playerkiller:playerkiller 1",
recipe = { {"","default:apple",""},
{"default:apple","mesecons_detector:object_detector_off","default:apple"},
{"","default:apple",""}}
})
minetest.register_node("moremesecons_playerkiller:playerkiller", {
tiles = {"top.png", "top.png", "side.png", "side.png", "side.png", "side.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3},
description="Player Killer",
mesecons = {effector = {
state = mesecon.state.off,
action_on = kill_nearest_player
}},
after_place_node = function(pos, placer)
meta = minetest.get_meta(pos)
if placer then
local meta = minetest.get_meta(pos)
meta:set_string("owner", placer:get_player_name())
meta:set_string("infotext", "PlayerKiller owned by " .. meta:get_string("owner"))
end
end
sounds = default.node_sound_stone_defaults(),
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -0,0 +1 @@
mesecons

@ -0,0 +1,71 @@
local nodebox = {
type = "fixed",
fixed = {{-8/16, -8/16, -8/16, 8/16, -7/16, 8/16 }},
}
local function signalchanger_get_output_rules(node)
local rules = {{x=1, y=0, z=0}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local function signalchanger_get_input_rules(node)
local rules = {{x=0, y=0, z=1, name="input_on"}, {x=0, y=0, z=-1, name="input_off"}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local update = function(pos, node, link, newstate)
local meta = minetest.get_meta(pos)
meta:set_int(link.name, newstate == "on" and 1 or 0)
local input_on = meta:get_int("input_on") == 1
local input_off = meta:get_int("input_off") == 1
if input_on then
mesecon.receptor_on(pos, signalchanger_get_output_rules(node))
minetest.swap_node(pos, {name = "moremesecons_signalchanger:signalchanger_on", param2 = node.param2})
elseif input_off then
mesecon.receptor_off(pos, signalchanger_get_output_rules(node))
minetest.swap_node(pos, {name = "moremesecons_signalchanger:signalchanger_off", param2 = node.param2})
end
end
mesecon.register_node("moremesecons_signalchanger:signalchanger", {
description = "Signal Changer",
inventory_image = "moremesecons_signalchanger_off.png",
groups = {dig_immediate = 2},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
selection_box = nodebox,
node_box = nodebox,
},{
groups = {dig_immediate = 2},
mesecons = {
receptor = {
state = mesecon.state.off,
rules = signalchanger_get_output_rules
},
effector = {
rules = signalchanger_get_input_rules,
action_change = update
},
},
tiles = {"moremesecons_signalchanger_off.png"},
},{
groups = {dig_immediate = 2, not_in_creative_inventory = 1},
mesecons = {
receptor = {
state = mesecon.state.on,
rules = signalchanger_get_output_rules,
},
effector = {
rules = signalchanger_get_input_rules,
action_change = update,
},
},
tiles = {"moremesecons_signalchanger_on.png"},
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 B

@ -0,0 +1 @@
mesecons

@ -0,0 +1,134 @@
--MOREMESECONS SWITCHTORCH
--file copy on mesecons torch by Jeija
local rotate_torch_rules = function (rules, param2)
if param2 == 5 then
return mesecon.rotate_rules_right(rules)
elseif param2 == 2 then
return mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules)) --180 degrees
elseif param2 == 4 then
return mesecon.rotate_rules_left(rules)
elseif param2 == 1 then
return mesecon.rotate_rules_down(rules)
elseif param2 == 0 then
return mesecon.rotate_rules_up(rules)
else
return rules
end
end
local torch_get_output_rules = function(node)
local rules = {
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},
{x = 0, y = 1, z = 0},
{x = 0, y =-1, z = 0}}
return rotate_torch_rules(rules, node.param2)
end
local torch_get_input_rules = function(node)
local rules = {{x = -2, y = 0, z = 0},
{x = -1, y = 1, z = 0}}
return rotate_torch_rules(rules, node.param2)
end
minetest.register_craft({
output = "moremesecons_switchtorch:switchtorch_off 4",
recipe = {
{"default:stick"},
{"group:mesecon_conductor_craftable"},}
})
local torch_selectionbox =
{
type = "wallmounted",
wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
}
minetest.register_node("moremesecons_switchtorch:switchtorch_off", {
drawtype = "torchlike",
tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"},
inventory_image = "jeija_torches_off.png",
paramtype = "light",
walkable = false,
paramtype2 = "wallmounted",
selection_box = torch_selectionbox,
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
drop = "moremesecons_switchtorch:switchtorch_on",
description="MoreMesecons SwitchTorch",
mesecons = {receptor = {
state = mesecon.state.off,
rules = torch_get_output_rules
}},
on_construct = function(pos)-- For EndPower
local meta = minetest.get_meta(pos)
meta:set_int("EndPower", 1) -- 1 for true, 0 for false
end
})
minetest.register_node("moremesecons_switchtorch:switchtorch_on", {
drawtype = "torchlike",
tiles = {"jeija_torches_on.png", "jeija_torches_on_ceiling.png", "jeija_torches_on_side.png"},
inventory_image = "jeija_torches_on.png",
wield_image = "jeija_torches_on.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
paramtype2 = "wallmounted",
selection_box = torch_selectionbox,
groups = {dig_immediate=3},
light_source = LIGHT_MAX-5,
mesecons = {receptor = {
state = mesecon.state.on,
rules = torch_get_output_rules
}},
on_construct = function(pos)-- For EndPower
local meta = minetest.get_meta(pos)
meta:set_int("EndPower", 1) -- 1 for true, 0 for false
end
})
minetest.register_abm({
nodenames = {"moremesecons_switchtorch:switchtorch_off","moremesecons_switchtorch:switchtorch_on"},
interval = 1,
chance = 1,
action = function(pos, node)
local is_powered = false
for _, rule in ipairs(torch_get_input_rules(node)) do
local src = mesecon.addPosRule(pos, rule)
if mesecon.is_power_on(src) then
is_powered = true
end
end
local meta = minetest.get_meta(pos)
if is_powered and meta:get_int("EndPower") == 1 then
if node.name == "moremesecons_switchtorch:switchtorch_on" then
minetest.swap_node(pos, {name = "moremesecons_switchtorch:switchtorch_off", param2 = node.param2})
mesecon.receptor_off(pos, torch_get_output_rules(node))
elseif node.name == "moremesecons_switchtorch:switchtorch_off" then
minetest.swap_node(pos, {name = "moremesecons_switchtorch:switchtorch_on", param2 = node.param2})
mesecon.receptor_on(pos, torch_get_output_rules(node))
end
meta = minetest.get_meta(pos)
meta:set_int("EndPower", 0)
elseif not(is_powered) and meta:get_int("EndPower") == 0 then
meta:set_int("EndPower", 1)
end
end
})
-- Param2 Table (Block Attached To)
-- 5 = z-1
-- 3 = x-1
-- 4 = z+1
-- 2 = x+1
-- 0 = y+1
-- 1 = y-1

@ -0,0 +1,134 @@
--MOREMESECONS SWITCHTORCH
--file copy on mesecons torch by Jeija
local rotate_torch_rules = function (rules, param2)
if param2 == 5 then
return mesecon.rotate_rules_right(rules)
elseif param2 == 2 then
return mesecon.rotate_rules_right(mesecon.rotate_rules_right(rules)) --180 degrees
elseif param2 == 4 then
return mesecon.rotate_rules_left(rules)
elseif param2 == 1 then
return mesecon.rotate_rules_down(rules)
elseif param2 == 0 then
return mesecon.rotate_rules_up(rules)
else
return rules
end
end
local torch_get_output_rules = function(node)
local rules = {
{x = 1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 0, y = 0, z =-1},
{x = 0, y = 1, z = 0},
{x = 0, y =-1, z = 0}}
return rotate_torch_rules(rules, node.param2)
end
local torch_get_input_rules = function(node)
local rules = {{x = -2, y = 0, z = 0},
{x = -1, y = 1, z = 0}}
return rotate_torch_rules(rules, node.param2)
end
minetest.register_craft({
output = "moremesecons_switchtorch:switchtorch_off 4",
recipe = {
{"default:stick"},
{"group:mesecon_conductor_craftable"},}
})
local torch_selectionbox =
{
type = "wallmounted",
wall_top = {-0.1, 0.5-0.6, -0.1, 0.1, 0.5, 0.1},
wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5+0.6, 0.1},
wall_side = {-0.5, -0.1, -0.1, -0.5+0.6, 0.1, 0.1},
}
minetest.register_node("moremesecons_switchtorch:switchtorch_off", {
drawtype = "torchlike",
tiles = {"jeija_torches_off.png", "jeija_torches_off_ceiling.png", "jeija_torches_off_side.png"},
inventory_image = "jeija_torches_off.png",
paramtype = "light",
walkable = false,
paramtype2 = "wallmounted",
selection_box = torch_selectionbox,
groups = {dig_immediate = 3, not_in_creative_inventory = 1},
description="MoreMesecons SwitchTorch",
mesecons = {receptor = {
state = mesecon.state.off,
rules = torch_get_output_rules
}},
on_construct = function(pos)-- For EndPower
local meta = minetest.get_meta(pos)
meta:set_int("EndPower", 1) -- 1 for true, 0 for false
end
})
minetest.register_node("moremesecons_switchtorch:switchtorch_on", {
drawtype = "torchlike",
tiles = {"jeija_torches_on.png", "jeija_torches_on_ceiling.png", "jeija_torches_on_side.png"},
inventory_image = "jeija_torches_on.png",
wield_image = "jeija_torches_on.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
paramtype2 = "wallmounted",
selection_box = torch_selectionbox,
groups = {dig_immediate=3},
light_source = LIGHT_MAX-5,
drop = "moremesecons_switchtorch:switchtorch_off",
mesecons = {receptor = {
state = mesecon.state.on,
rules = torch_get_output_rules
}},
on_construct = function(pos)-- For EndPower
local meta = minetest.get_meta(pos)
meta:set_int("EndPower", 1) -- 1 for true, 0 for false
end
})
minetest.register_abm({
nodenames = {"moremesecons_switchtorch:switch_off","moremesecons_switchtorch:switchtorch_on"},
interval = 1,
chance = 1,
action = function(pos, node)
local is_powered = false
for _, rule in ipairs(torch_get_input_rules(node)) do
local src = mesecon.addPosRule(pos, rule)
if mesecon.is_power_on(src) then
is_powered = true
end
end
local meta = minetest.get_meta(pos)
if is_powered and meta:get_int("EndPower") == 1 then
if node.name == "moremesecons_switchtorch:switchtorch_on" then
minetest.swap_node(pos, {name = "moremesecons_switchtorch:switchtorch_off", param2 = node.param2})
mesecon.receptor_off(pos, torch_get_output_rules(node))
elseif node.name == "moremesecons_switchtorch:switchtorch_off" then
minetest.swap_node(pos, {name = "moremesecons_switchtorch:switchtorch_on", param2 = node.param2})
mesecon.receptor_on(pos, torch_get_output_rules(node))
end
meta = minetest.get_meta(pos)
meta:set_int("EndPower", 0)
elseif not(is_powered) and meta:get_int("EndPower") == 0 then
meta:set_int("EndPower", 1)
end
end
})
-- Param2 Table (Block Attached To)
-- 5 = z-1
-- 3 = x-1
-- 4 = z+1
-- 2 = x+1
-- 0 = y+1
-- 1 = y-1

@ -0,0 +1 @@
mesecons

@ -0,0 +1,77 @@
teleporters = {}
local register = function(pos)
local meta = minetest.env:get_meta(pos)
local RID = meta:get_int("RID")
if teleporters[RID] == nil then
table.insert(teleporters, pos)
meta:set_int("RID", #teleporters)
end
end
local teleport_nearest = function(pos)
local MAX_DISTANCE = 8
-- Search the nearest player
local nearest = nil
local min_distance = math.huge
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player
end
end
-- Search other teleporter and teleport
if not minetest.registered_nodes["moremesecons_teleporter:teleporter"] then return end
for i = 1, #teleporters do
if minetest.get_node(teleporters[i]).name == "moremesecons_teleporter:teleporter" then
if teleporters[i].y == pos.y and teleporters[i].x == pos.x and teleporters[i].z ~= pos.z then
nearest:setpos({x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z})
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
return
elseif teleporters[i].z == pos.z and teleporters[i].x == pos.x and teleporters[i].y ~= pos.y then
nearest:setpos({x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z})
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
return
elseif teleporters[i].z == pos.z and teleporters[i].y == pos.y and teleporters[i].x ~= pos.x then
nearest:setpos({x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z})
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
return
end
end
end
end
minetest.register_craft({
output = "moremesecons_teleporter:teleporter 1",
recipe = {{"default:mese_cristal_fragment","default:stick","default:mese_cristal_fragment"}}
})
minetest.register_node("moremesecons_teleporter:teleporter", {
tiles = {"teleporter.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3},
description="Teleporter",
mesecons = {effector = {
state = mesecon.state.off,
action_on = teleport_nearest
}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
register(pos)
end
})
minetest.register_abm({
nodenames = {"moremesecons_teleporter:teleporter"},
interval=1,
chance=1,
action = function(pos)
register(pos)
end
})

@ -0,0 +1,77 @@
teleporters = {}
local register = function(pos)
local meta = minetest.env:get_meta(pos)
local RID = meta:get_int("RID")
if teleporters[RID] == nil then
table.insert(teleporters, pos)
meta:set_int("RID", #teleporters)
end
end
local teleport_nearest = function(pos)
local MAX_DISTANCE = 8
-- Search the nearest player
local nearest = nil
local min_distance = math.huge
local players = minetest.get_connected_players()
for index, player in pairs(players) do
local distance = vector.distance(pos, player:getpos())
if distance < min_distance then
min_distance = distance
nearest = player
end
end
-- Search other teleporter and teleport
if not minetest.registered_nodes["moremesecons_teleporter:teleporter"] then return end
for i = 1, #teleporters do
if minetest.get_node(teleporters[i]).name == "moremesecons_teleporter:teleporter" then
if teleporters[i].y == pos.y and teleporters[i].x == pos.x and teleporters[i].z ~= pos.z then
nearest:setpos({x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z})
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
return
elseif teleporters[i].z == pos.z and teleporters[i].x == pos.x and teleporters[i].y ~= pos.y then
nearest:setpos({x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z})
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
return
elseif teleporters[i].z == pos.z and teleporters[i].y == pos.y and teleporters[i].x ~= pos.x then
nearest:setpos({x=teleporters[i].x, y=teleporters[i].y+1, z=teleporters[i].z})
minetest.log("action", "Player "..nearest:get_player_name().." was teleport with a MoreMesecons Teleporter.")
return
end
end
end
end
minetest.register_craft({
output = "moremesecons_teleporter:teleporter 1",
recipe = {{"default:mese_cristal_fragment","default:stick","default:mese_cristal_fragment"}}
})
minetest.register_node("moremesecons_teleporter:teleporter", {
tiles = {"default_steel_block.png", "default_steel_block.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png", "jeija_object_detector_on.png"},
paramtype = "light",
walkable = true,
groups = {cracky=3},
description="Teleporter",
mesecons = {effector = {
state = mesecon.state.off,
action_on = teleport_nearest
}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
register(pos)
end
})
minetest.register_abm({
nodenames = {"moremesecons_teleporter:teleporter"},
interval=1,
chance=1,
action = function(pos)
register(pos)
end
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 550 B

@ -0,0 +1 @@
mesecons

@ -0,0 +1,115 @@
-- MOREMESECONS TEMPORARY GATE
local temporarygate_get_output_rules = function(node)
local rules = {{x = 0, y = 0, z = 1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local temporarygate_get_input_rules = function(node)
local rules = {{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
-- Functions that are called after the delay time
local temporarygate_activate = function(pos, node)
local def = minetest.registered_nodes[node.name]
local meta = minetest.get_meta(pos)
local time = tonumber(meta:get_string("time"))
if time ~= nil then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_on", param2 = node.param2})
mesecon.receptor_on(pos)
minetest.after(time, function(pos, node)
mesecon.receptor_off(pos)
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_off", param2 = node.param2})
end, pos, node)
end
end
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
{ -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator
{ -3/16, -7/16, -3/16, 3/16, -26/64, -2/16 },
{ -4/16, -7/16, -2/16, 4/16, -26/64, 2/16 },
{ -3/16, -7/16, 2/16, 3/16, -26/64, 3/16 },
{ -2/16, -7/16, 3/16, 2/16, -26/64, 4/16 },
{ -6/16, -7/16, -6/16, -4/16, -27/64, -4/16 }, -- the timer indicator
{ -8/16, -8/16, -1/16, -6/16, -7/16, 1/16 }, -- the two wire stubs
{ 6/16, -8/16, -1/16, 8/16, -7/16, 1/16 }}
mesecon.register_node("moremesecons_temporarygate:temporarygate", {
description = "Temporary Gate",
drawtype = "nodebox",
inventory_image = "moremesecons_temporarygate_off.png",
wield_image = "moremesecons_temporarygate_off.png",
walkable = true,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = boxes
},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[time;time;${time}]")
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
meta:set_string("time", fields.time)
end
},{
tiles = {
"moremesecons_temporarygate_off.png",
"moremesecons_temporarygate_bottom.png",
"moremesecons_temporarygate_ends_off.png",
"moremesecons_temporarygate_ends_off.png",
"moremesecons_temporarygate_sides_off.png",
"moremesecons_temporarygate_sides_off.png"
},
groups = {bendy=2,snappy=1,dig_immediate=2},
mesecons = {
receptor =
{
state = mesecon.state.off,
rules = temporarygate_get_output_rules
},
effector =
{
rules = temporarygate_get_input_rules,
action_on = temporarygate_activate
}
},
},{
tiles = {
"moremesecons_temporarygate_on.png",
"moremesecons_temporarygate_bottom.png",
"moremesecons_temporarygate_ends_on.png",
"moremesecons_temporarygate_ends_on.png",
"moremesecons_temporarygate_sides_on.png",
"moremesecons_temporarygate_sides_on.png"
},
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1},
mesecons = {receptor = {state = mesecon.state.on, rules = temporarygate_get_output_rules}},
})
minetest.register_craft({
output = "moremesecons_temporarygate:temporarygate_off",
recipe = {
{"mesecons_torch:mesecon_torch_on", "group:mesecon_conductor_craftable", "mesecons_torch:mesecon_torch_on"},
{"default:wood","default:wood", "default:wood"},
}
})

@ -0,0 +1,184 @@
--MOREMESECONS TEMPORARYGATE
--file copy on mesecons delayer
-- Function that get the input/output rules of the temporarygate
local temporarygate_get_output_rules = function(node)
local rules = {{x = 0, y = 0, z = 1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
local temporarygate_get_input_rules = function(node)
local rules = {{x = 0, y = 0, z = -1}}
for i = 0, node.param2 do
rules = mesecon.rotate_rules_left(rules)
end
return rules
end
-- Functions that are called after the delay time
local temporarygate_activate = function(pos, node)
local timer = minetest.get_node_timer(pos)
print(node)
local def = minetest.registered_nodes[node.name]
local time = def.temporarygate_time
local meta = minetest.get_meta(pos)
if timer:is_started() then
timer:stop()
--On...
minetest.swap_node(pos, {name = def.temporarygate_onstate, param2=node.param2})
mesecon.receptor_on(pos, temporarygate_get_output_rules(node))
--...And off.
mesecon.receptor_off(pos, temporarygate_get_output_rules(node))
minetest.swap_node(pos, {name = def.temporarygate_offstate, param2=node.param2})
else
timer:start(time)
end
end
-- Register the 2 (states) x 4 (delay times) temporarygates
for i = 1, 4 do
local groups = {}
if i == 1 then
groups = {bendy=2,snappy=1,dig_immediate=2}
else
groups = {bendy=2,snappy=1,dig_immediate=2, not_in_creative_inventory=1}
end
local delaytime
delaytime = i
boxes = {{ -6/16, -8/16, -6/16, 6/16, -7/16, 6/16 }, -- the main slab
{ -2/16, -7/16, -4/16, 2/16, -26/64, -3/16 }, -- the jeweled "on" indicator
{ -3/16, -7/16, -3/16, 3/16, -26/64, -2/16 },
{ -4/16, -7/16, -2/16, 4/16, -26/64, 2/16 },
{ -3/16, -7/16, 2/16, 3/16, -26/64, 3/16 },
{ -2/16, -7/16, 3/16, 2/16, -26/64, 4/16 },
{ -6/16, -7/16, -6/16, -4/16, -27/64, -4/16 }, -- the timer indicator
{ -8/16, -8/16, -1/16, -6/16, -7/16, 1/16 }, -- the two wire stubs
{ 6/16, -8/16, -1/16, 8/16, -7/16, 1/16 }}
minetest.register_node("moremesecons_temporarygate:temporarygate_off_"..tostring(i), {
description = "temporarygate",
drawtype = "nodebox",
tiles = {
"mesecons_temporarygate_off_"..tostring(i)..".png",
"mesecons_temporarygate_bottom.png",
"mesecons_temporarygate_ends_off.png",
"mesecons_temporarygate_ends_off.png",
"mesecons_temporarygate_sides_off.png",
"mesecons_temporarygate_sides_off.png"
},
inventory_image = "mesecons_temporarygate_off_1.png",
wield_image = "mesecons_temporarygate_off_1.png",
walkable = true,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = boxes
},
groups = groups,
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
drop = 'moremesecons_temporarygate:temporarygate_off_1',
on_punch = function (pos, node)
if node.name=="moremesecons_temporarygate:temporarygate_off_1" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_off_2", param2=node.param2})
elseif node.name=="moremesecons_temporarygate:temporarygate_off_2" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_off_3", param2=node.param2})
elseif node.name=="moremesecons_temporarygate:temporarygate_off_3" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_off_4", param2=node.param2})
elseif node.name=="moremesecons_temporarygate:temporarygate_off_4" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_off_1", param2=node.param2})
end
end,
temporarygate_time = delaytime,
temporarygate_onstate = "moremesecons_temporarygate:temporarygate_on_"..tostring(i),
sounds = default.node_sound_stone_defaults(),
mesecons = {
receptor =
{
state = mesecon.state.off,
rules = temporarygate_get_output_rules
},
effector =
{
rules = temporarygate_get_input_rules,
action_on = temporarygate_activate
}
},
on_timer = temporarygate_activate
})
minetest.register_node("moremesecons_temporarygate:temporarygate_on_"..tostring(i), {
description = "MoreMesecons TemporaryGate",
drawtype = "nodebox",
tiles = {
"mesecons_temporarygate_on_"..tostring(i)..".png",
"mesecons_temporarygate_bottom.png",
"mesecons_temporarygate_ends_on.png",
"mesecons_temporarygate_ends_on.png",
"mesecons_temporarygate_sides_on.png",
"mesecons_temporarygate_sides_on.png"
},
walkable = true,
selection_box = {
type = "fixed",
fixed = { -8/16, -8/16, -8/16, 8/16, -6/16, 8/16 },
},
node_box = {
type = "fixed",
fixed = boxes
},
groups = {bendy = 2, snappy = 1, dig_immediate = 2, not_in_creative_inventory = 1},
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
is_ground_content = true,
drop = 'moremesecons_temporarygate:temporarygate_off_1',
on_punch = function (pos, node)
if node.name=="moremesecons_temporarygate:temporarygate_on_1" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_on_2", param2=node.param2})
elseif node.name=="moremesecons_temporarygate:temporarygate_on_2" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_on_3", param2=node.param2})
elseif node.name=="moremesecons_temporarygate:temporarygate_on_3" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_on_4", param2=node.param2})
elseif node.name=="moremesecons_temporarygate:temporarygate_on_4" then
minetest.swap_node(pos, {name = "moremesecons_temporarygate:temporarygate_on_1", param2=node.param2})
end
end,
temporarygate_time = delaytime,
temporarygate_offstate = "moremesecons_temporarygate:temporarygate_off_"..tostring(i),
mesecons = {
receptor =
{
state = mesecon.state.on,
rules = temporarygate_get_output_rules
},
effector =
{
rules = temporarygate_get_input_rules,
}
}
})
end
minetest.register_craft({
output = "moremesecons_temporarygate:temporarygate_off_1",
recipe = {
{"mesecons_torch:mesecon_torch_on", "group:mesecon_conductor_craftable", "mesecons_torch:mesecon_torch_on"},
{"default:wood","default:wood", "default:wood"},
}
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 438 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 635 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 B

@ -0,0 +1 @@
mesecons

@ -0,0 +1,79 @@
wireless = {}
local register = function(pos)
local meta = minetest.env:get_meta(pos)
local RID = meta:get_int("RID")
if wireless[RID] == nil then
table.insert(wireless, pos)
meta:set_int("RID", #wireless)
end
end
local wireless_activate = function(pos)
if not minetest.registered_nodes["moremesecons_wireless:wireless"] then return end
local meta = minetest.get_meta(pos)
local channel_first_wireless = nil
for i = 1, #wireless do
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
mesecon.receptor_on(wireless[i])
end
end
end
local wireless_deactivate = function(pos)
if not minetest.registered_nodes["moremesecons_wireless:wireless"] then return end
local meta = minetest.get_meta(pos)
local channel_first_wireless = nil
for i = 1, #wireless do
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
mesecon.receptor_off(wireless[i])
end
end
end
minetest.register_node("moremesecons_wireless:wireless", {
tiles = {"wireless.png"},
paramtype = "light",
paramtype2 = "facedir",
description = "Wireless",
walkable = true,
groups = {cracky=3,not_in_creative_inventory=1},
mesecons = {effector = {
action_on = wireless_activate,
action_off = wireless_deactivate
}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;channel;${channel}]")
register(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
meta:set_string("channel", fields.channel)
end,
})
minetest.register_craft({
output = "moremesecons_wireless:wireless 2",
recipe = {
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
{"", "mesecons_torch:torch_on", ""},
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
}
})
minetest.register_abm({
nodenames = {"moremesecons_wireless:wireless"},
interval=1,
chance=1,
action = register
})

@ -0,0 +1,81 @@
wireless = {}
local register = function(pos)
local meta = minetest.env:get_meta(pos)
local RID = meta:get_int("RID")
if wireless[RID] == nil then
table.insert(wireless, pos)
meta:set_int("RID", #wireless)
end
end
local wireless_activate = function(pos)
if not minetest.registered_nodes["moremesecons_wireless:wireless"] then return end
local meta = minetest.get_meta(pos)
local channel_first_wireless = nil
for i = 1, #wireless do
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
mesecon.receptor_on(wireless[i])
end
end
end
local wireless_deactivate = function(pos)
if not minetest.registered_nodes["moremesecons_wireless:wireless"] then return end
local meta = minetest.get_meta(pos)
local channel_first_wireless = nil
for i = 1, #wireless do
if minetest.get_node(wireless[i]).name == "moremesecons_wireless:wireless" then
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
mesecon.receptor_off(wireless[i])
end
end
end
end
minetest.register_node("moremesecons_wireless:wireless", {
tiles = {"wireless.png"},
paramtype = "light",
paramtype2 = "facedir",
description = "Wireless",
walkable = true,
groups = {cracky=3,not_in_creative_inventory=1},
mesecons = {effector = {
action_on = wireless_activate,
action_off = wireless_deactivate
}},
sounds = default.node_sound_stone_defaults(),
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;channel;${channel}]")
register(pos)
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
meta:set_string("channel", fields.channel)
end,
})
minetest.register_craft({
output = "moremesecons_wireless:wireless 2",
recipe = {
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
{"", "mesecons_torch:torch_on", ""},
{"group:mesecon_conductor_craftable", "", "group:mesecon_conductor_craftable"},
}
})
minetest.register_abm({
nodenames = {"moremesecons_wireless:wireless"},
interval=1,
chance=1,
action = register
})

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 B