From a673ceb374e65cf46ecec04b2a1ea32fb3120828 Mon Sep 17 00:00:00 2001 From: palige Date: Fri, 28 Aug 2015 12:24:33 +0200 Subject: [PATCH] Fix a bug for temporarygate and add Signalchanger --- README.txt | 15 ++ modpack.txt | 1 + moremesecons/depends.txt | 1 + moremesecons/init.lua | 1 + moremesecons/init.lua~ | 0 .../depends.txt | 1 + moremesecons_adjustable_blinkyplant/init.lua | 61 ++++++ moremesecons_adjustable_blinkyplant/init.lua~ | 62 ++++++ .../textures/jeija_blinky_plant_off.png | Bin 0 -> 454 bytes .../textures/jeija_blinky_plant_on.png | Bin 0 -> 463 bytes moremesecons_commandblock/depends.txt | 1 + moremesecons_commandblock/init.lua | 174 +++++++++++++++++ moremesecons_commandblock/init.lua~ | 174 +++++++++++++++++ .../textures/jeija_close_window.png | Bin 0 -> 323 bytes .../textures/jeija_commandblock_off.png | Bin 0 -> 282 bytes .../textures/jeija_commandblock_on.png | Bin 0 -> 278 bytes moremesecons_playerkiller/depends.txt | 2 + moremesecons_playerkiller/init.lua | 51 +++++ moremesecons_playerkiller/init.lua~ | 51 +++++ moremesecons_playerkiller/textures/side.png | Bin 0 -> 727 bytes moremesecons_playerkiller/textures/top.png | Bin 0 -> 1162 bytes moremesecons_signalchanger/depends.txt | 1 + moremesecons_signalchanger/init.lua | 71 +++++++ .../moremesecons_signalchanger_off.png | Bin 0 -> 166 bytes .../moremesecons_signalchanger_on.png | Bin 0 -> 165 bytes moremesecons_switchtorch/depends.txt | 1 + moremesecons_switchtorch/init.lua | 134 +++++++++++++ moremesecons_switchtorch/init.lua~ | 134 +++++++++++++ .../textures/jeija_torches_off.png.gz | Bin 0 -> 256 bytes .../textures/jeija_torches_off_ceiling.png.gz | Bin 0 -> 264 bytes .../textures/jeija_torches_off_side.png.gz | Bin 0 -> 247 bytes .../textures/jeija_torches_on.png.gz | Bin 0 -> 244 bytes .../textures/jeija_torches_on_ceiling.png.gz | Bin 0 -> 264 bytes .../textures/jeija_torches_on_side.png.gz | Bin 0 -> 236 bytes moremesecons_teleporter/depends.txt | 1 + moremesecons_teleporter/init.lua | 77 ++++++++ moremesecons_teleporter/init.lua~ | 77 ++++++++ .../textures/jeija_object_detector_on.png | Bin 0 -> 735 bytes .../textures/teleporter.png | Bin 0 -> 550 bytes moremesecons_temporarygate/depends.txt | 1 + moremesecons_temporarygate/init.lua | 115 +++++++++++ moremesecons_temporarygate/init.lua~ | 184 ++++++++++++++++++ .../moremesecons_temporarygate_bottom.png | Bin 0 -> 438 bytes .../moremesecons_temporarygate_ends_off.png | Bin 0 -> 226 bytes .../moremesecons_temporarygate_ends_on.png | Bin 0 -> 228 bytes .../moremesecons_temporarygate_off.png | Bin 0 -> 562 bytes .../moremesecons_temporarygate_on.png | Bin 0 -> 635 bytes .../moremesecons_temporarygate_sides_off.png | Bin 0 -> 229 bytes .../moremesecons_temporarygate_sides_on.png | Bin 0 -> 234 bytes moremesecons_wireless/depends.txt | 1 + moremesecons_wireless/init.lua | 79 ++++++++ moremesecons_wireless/init.lua~ | 81 ++++++++ moremesecons_wireless/textures/wireless.png | Bin 0 -> 206 bytes 53 files changed, 1552 insertions(+) create mode 100644 README.txt create mode 100644 modpack.txt create mode 100644 moremesecons/depends.txt create mode 100644 moremesecons/init.lua create mode 100644 moremesecons/init.lua~ create mode 100644 moremesecons_adjustable_blinkyplant/depends.txt create mode 100644 moremesecons_adjustable_blinkyplant/init.lua create mode 100644 moremesecons_adjustable_blinkyplant/init.lua~ create mode 100644 moremesecons_adjustable_blinkyplant/textures/jeija_blinky_plant_off.png create mode 100644 moremesecons_adjustable_blinkyplant/textures/jeija_blinky_plant_on.png create mode 100644 moremesecons_commandblock/depends.txt create mode 100644 moremesecons_commandblock/init.lua create mode 100644 moremesecons_commandblock/init.lua~ create mode 100644 moremesecons_commandblock/textures/jeija_close_window.png create mode 100644 moremesecons_commandblock/textures/jeija_commandblock_off.png create mode 100644 moremesecons_commandblock/textures/jeija_commandblock_on.png create mode 100644 moremesecons_playerkiller/depends.txt create mode 100644 moremesecons_playerkiller/init.lua create mode 100644 moremesecons_playerkiller/init.lua~ create mode 100644 moremesecons_playerkiller/textures/side.png create mode 100644 moremesecons_playerkiller/textures/top.png create mode 100644 moremesecons_signalchanger/depends.txt create mode 100644 moremesecons_signalchanger/init.lua create mode 100644 moremesecons_signalchanger/textures/moremesecons_signalchanger_off.png create mode 100644 moremesecons_signalchanger/textures/moremesecons_signalchanger_on.png create mode 100644 moremesecons_switchtorch/depends.txt create mode 100644 moremesecons_switchtorch/init.lua create mode 100644 moremesecons_switchtorch/init.lua~ create mode 100644 moremesecons_switchtorch/textures/jeija_torches_off.png.gz create mode 100644 moremesecons_switchtorch/textures/jeija_torches_off_ceiling.png.gz create mode 100644 moremesecons_switchtorch/textures/jeija_torches_off_side.png.gz create mode 100644 moremesecons_switchtorch/textures/jeija_torches_on.png.gz create mode 100644 moremesecons_switchtorch/textures/jeija_torches_on_ceiling.png.gz create mode 100644 moremesecons_switchtorch/textures/jeija_torches_on_side.png.gz create mode 100644 moremesecons_teleporter/depends.txt create mode 100644 moremesecons_teleporter/init.lua create mode 100644 moremesecons_teleporter/init.lua~ create mode 100644 moremesecons_teleporter/textures/jeija_object_detector_on.png create mode 100644 moremesecons_teleporter/textures/teleporter.png create mode 100644 moremesecons_temporarygate/depends.txt create mode 100644 moremesecons_temporarygate/init.lua create mode 100644 moremesecons_temporarygate/init.lua~ create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_bottom.png create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_ends_off.png create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_ends_on.png create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_off.png create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_on.png create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_sides_off.png create mode 100644 moremesecons_temporarygate/textures/moremesecons_temporarygate_sides_on.png create mode 100644 moremesecons_wireless/depends.txt create mode 100644 moremesecons_wireless/init.lua create mode 100644 moremesecons_wireless/init.lua~ create mode 100644 moremesecons_wireless/textures/wireless.png diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..e2efdce --- /dev/null +++ b/README.txt @@ -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. \ No newline at end of file diff --git a/modpack.txt b/modpack.txt new file mode 100644 index 0000000..33d91f5 --- /dev/null +++ b/modpack.txt @@ -0,0 +1 @@ +The presence of this file indicates that the current folder is a modpack. \ No newline at end of file diff --git a/moremesecons/depends.txt b/moremesecons/depends.txt new file mode 100644 index 0000000..7ebf50c --- /dev/null +++ b/moremesecons/depends.txt @@ -0,0 +1 @@ +mesecons \ No newline at end of file diff --git a/moremesecons/init.lua b/moremesecons/init.lua new file mode 100644 index 0000000..359b8b3 --- /dev/null +++ b/moremesecons/init.lua @@ -0,0 +1 @@ +print("[OK] MoreMesecons") diff --git a/moremesecons/init.lua~ b/moremesecons/init.lua~ new file mode 100644 index 0000000..e69de29 diff --git a/moremesecons_adjustable_blinkyplant/depends.txt b/moremesecons_adjustable_blinkyplant/depends.txt new file mode 100644 index 0000000..acaa924 --- /dev/null +++ b/moremesecons_adjustable_blinkyplant/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/moremesecons_adjustable_blinkyplant/init.lua b/moremesecons_adjustable_blinkyplant/init.lua new file mode 100644 index 0000000..65b73e0 --- /dev/null +++ b/moremesecons_adjustable_blinkyplant/init.lua @@ -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"},} +}) diff --git a/moremesecons_adjustable_blinkyplant/init.lua~ b/moremesecons_adjustable_blinkyplant/init.lua~ new file mode 100644 index 0000000..7039836 --- /dev/null +++ b/moremesecons_adjustable_blinkyplant/init.lua~ @@ -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"},} +}) diff --git a/moremesecons_adjustable_blinkyplant/textures/jeija_blinky_plant_off.png b/moremesecons_adjustable_blinkyplant/textures/jeija_blinky_plant_off.png new file mode 100644 index 0000000000000000000000000000000000000000..4f507da15b5f3d634cc9aa6036e3cbfa8b71c27a GIT binary patch literal 454 zcmV;%0XhDOP)5=+w{q++F9Hv$k#0jzeTUOK1_?(^e6327$ w71nk$Bw0lE@g0>94pWN)vqeL6fM&|qOvh7A=oL~^4R#~L$I literal 0 HcmV?d00001 diff --git a/moremesecons_commandblock/depends.txt b/moremesecons_commandblock/depends.txt new file mode 100644 index 0000000..acaa924 --- /dev/null +++ b/moremesecons_commandblock/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/moremesecons_commandblock/init.lua b/moremesecons_commandblock/init.lua new file mode 100644 index 0000000..69c2803 --- /dev/null +++ b/moremesecons_commandblock/init.lua @@ -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"} + } +}) diff --git a/moremesecons_commandblock/init.lua~ b/moremesecons_commandblock/init.lua~ new file mode 100644 index 0000000..bac5e76 --- /dev/null +++ b/moremesecons_commandblock/init.lua~ @@ -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"} + } +}) diff --git a/moremesecons_commandblock/textures/jeija_close_window.png b/moremesecons_commandblock/textures/jeija_close_window.png new file mode 100644 index 0000000000000000000000000000000000000000..5c27c6c33c8d45f501f5b2fa9ac5a431c81f85c7 GIT binary patch literal 323 zcmeAS@N?(olHy`uVBq!ia0vp^azHH0!3HGvF1f=4q}Y!<&F2oCO|{ z#Xud`L734=V|E2lkiEpy*OmP)qcE4Ox|gShAyDXor;B5V$MLt*V)>d31X`B!s()eo zv9A3gL)?KEg5CU1OucW<ZLtv4_G{-*VC>kv`0x?Qi!9sA zcvV`yJz(8vD-nPFcmscNPNV$vgR(a+9b0*^+lhb9#kPN;aSA&>{MzTO*ZqC+#8)v9 z#S8u|xf#O~(>iPAI>u)Y_U{ucUelQUa@j(k-pB@)uX+N@j?HfVT%|X6Rl%xbVb@Q^ zp1m@IbJdyM+2PmctoV?$D)#fqtn8KZSmy;MZu!J?^95_uXV#*o|NMU#bNsVAYV-1a QfqrA~boFyt=akR{00h2;qyPW_ literal 0 HcmV?d00001 diff --git a/moremesecons_commandblock/textures/jeija_commandblock_off.png b/moremesecons_commandblock/textures/jeija_commandblock_off.png new file mode 100644 index 0000000000000000000000000000000000000000..c05b616a9f69c7bcc162820a8510ce2409bb00d1 GIT binary patch literal 282 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|oCO|{#S9GG!XV7ZFl&wkQ1FbW zi(`n!`QD&|yoU^UY!-R^Tu`&iNj;HOPC@KJzr+IO4Ghi(%&ClF8v1S>BB7lXEU|OV zT7L=7O}4g+-&3_!TF30ZJMV$@iw(INzDq7REq$GpRpIEehNDJHE;AonkzPJ4Ice?M z)yE{B3Yb_kRc!g5bTF@8;o79CO>aN?)a;IH>-6mW(^a{}#q;9N^(*@srj*pBFL$3_ zCUM&8)q$N)4Q8&{F<-}RSx>_5tb6bO+iq8R0SCh+ d&&AsB?GLhdgtPkYXa)L=~c-*cp@m(ml zs5s~N^X~BT#mz^b{a(TN!`H-(@q-<6N#)~R3m80dxFY7XZLvw{*;TgOQtjHUU0J<> ze2$xy8y+u=DX3r5S?U%0=G#5t_uHl?CIu<&Pm=T1(6st*`c<&OYwrDWFU8GbZ8()Nlj2>E@cM*00KKnL_t(|+U;7)vBMw? zR6Oa4cDTACuCzl{@12-Y2w))kU;~%Ljz`ums}GPD0Q|wiRrPlHZ-+Oa#oJg16R-XUQKs1om1$NbWuHE*Tzg z$(WBMq1Ew@_} zkkIj)c;497N!Q5mo}O0M)KJRUk@0Phyh_ z0dWFKpjz)ef`HbtCXxIw0itUGjoF@VF_bDnYac*uF%)MVAGB!h5gZ!e@yw63%eN$; zRO5TwDmYF4N31E{+`?>&SNz!=jV%14Xw zQFf)`IfMWJ03iejA$0kBv>5L-dZ*Ex17;)v&wd=n7@82s8UH2OaDz9-bc3%ZL2E4- zV?JIIzmFsvZt$bNRI5NFAteA4Ax#1$_@*+5jpr00sRnBB-HlLGM5+pj1jzw@s1b@U zt*L=h5s_F9@IQ5eI6tJhfyzmWGRN8qV>P4%L`94`D*>KtF_d#kqe7^z2Gf#BWiQ&~ zB9wGBh)JMu7Ka#@n#h;K9FB5^(*BRoCSdXLu`9e4unAai`~#-Ay0Y%y%ZC5}002ov JPDHLkV1l6NF2n!; literal 0 HcmV?d00001 diff --git a/moremesecons_playerkiller/textures/top.png b/moremesecons_playerkiller/textures/top.png new file mode 100644 index 0000000000000000000000000000000000000000..bc22e2509edb788109d9547dc732a90ea15c91dc GIT binary patch literal 1162 zcmV;51a00009a7bBm000XU z000XU0RWnu7ytkO2XskIMF-yn2oN?c@(s{*5$GTZY-sTV0%VeN?zOM)IYiBw&zM=PLUBK%rgpdwKFo~SH@-dc7!ceM z0gr#>^*i5<#Xj=5WO+V;QF2vNcdyob`NvUF)zm-uVH7GL2nY=3jxr#y6-smGV<1a21us8jQgR%7CDz_IP0u5-wSe zMZ*ja{0ARv)(!NKP@~&xQr?T|sHpbrSF9}dndcd^fgA??xT1RFZN(}h3kYIjgAtu^ z;$}J|Oh^I($;KOR71iI#fXBb{zGj`1M?|0C?$VGH<>YJDz*oNZ&Vw1aaxO*Ry0HO- zgGTpWOFelz+z|8)hlofxINa?r;PE?l4rj5a(0hE_Vo<1~0X7(Mcy{di6(!Rz{8H>s z*qzGax-eH&hjsp#R0MjI7xM z4p&e#A5+qUwIoR>DLwwWRmkJ_>}%>SdXFzCa`G+PHu@$x8QGR?PVR7Bpc*YL;H4b& zrQ3JIrljodT`49xc{|wWPf)0ma>M4*dU_cFS>>mSPeJj*i>&*jqokAxT>{N2I^W;@ zFD0cy8B8O!4n{~gXC4xMa`eiCZURM4bPLqT1T1#RQjX6qH;avkj^g{{ghse^tMixy zG&&|$sH0^hB#ej_EE19fhzgaEELcQDM@z8BD^yH;^@B{K4MqgO!Oa4KghZ0lKFFkx zSg@Ee6ESdf{Uju}=!HVUC!SWUDyoC~$qq?L6)Ge=vz3q&P~`F_`)AAyh@3r|1c5HE z1%)(cpEq+&_*2pwb)y#BBtfCN5fwRau_>vrI@M0M!++`a?N6Ycgyzq-?woTjRZibexnPK;5Et)b4G^5vf2RCP}yw=oWEeiCQ z_#d(srAo%cQZyTLx1^NDTU3M;)`a9=Gi_@% literal 0 HcmV?d00001 diff --git a/moremesecons_signalchanger/depends.txt b/moremesecons_signalchanger/depends.txt new file mode 100644 index 0000000..acaa924 --- /dev/null +++ b/moremesecons_signalchanger/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/moremesecons_signalchanger/init.lua b/moremesecons_signalchanger/init.lua new file mode 100644 index 0000000..f86fdb0 --- /dev/null +++ b/moremesecons_signalchanger/init.lua @@ -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"}, +}) diff --git a/moremesecons_signalchanger/textures/moremesecons_signalchanger_off.png b/moremesecons_signalchanger/textures/moremesecons_signalchanger_off.png new file mode 100644 index 0000000000000000000000000000000000000000..723b08922649c53e3b7b928fed2d1e35fa90f866 GIT binary patch literal 166 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf%#$B!Qid~_OCw(d@Nc&PQs?gok3C(IfqEKHGXcoQp@vrH)4 z`VK=7lR&I4H(#lS*})q(bPh?fz33|3DU`2p$mHQ?rGpU)B6bXVa*C|#oHd_;7BP6b L`njxgN@xNAPc$_0 literal 0 HcmV?d00001 diff --git a/moremesecons_signalchanger/textures/moremesecons_signalchanger_on.png b/moremesecons_signalchanger/textures/moremesecons_signalchanger_on.png new file mode 100644 index 0000000000000000000000000000000000000000..d7ac107dabeb27bc24b64ccda0298efe6afb0e05 GIT binary patch literal 165 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf6(pyRg+*g@({0?NM-#Udt&d-acG9QIx)-(q?5 zT5HC6-z8;>6QTPWbkzLb6Mw<&;$SvHGFMGaVsZNIgoC^d20YAjO)iu%Uwgo4 z&G^|NG3b|LVl&%CaiQF~ob$+YPGz8=hCh>%VNjI7LK!dG6IY z{w)HAXSw%gIq4{f#YEMGcSYY^_*GCT=zGmA{-fvHcQW2E=6(5BeMJ?}QU*^~KbLh* O2~7ZQ^$ZEz0002#7<~@_ literal 0 HcmV?d00001 diff --git a/moremesecons_switchtorch/textures/jeija_torches_off_side.png.gz b/moremesecons_switchtorch/textures/jeija_torches_off_side.png.gz new file mode 100644 index 0000000000000000000000000000000000000000..f51ead1a9fd7c13fe7fadaaa1827d7232e0c5fc0 GIT binary patch literal 247 zcmVkRO7=jD>( zVqjq4_4IHF0@4CNEXctIB(JR3IRd2ElDyqr82*Fcg1yTp14TFsJR*x37`TNQ721s-{D~7XBAs49a9MuiuQDI46!)<_S{C!1_K6{i}F2-wJatI9yQF# zb=8^UW-@V(u*8O`d%ivRG2w56XYXGFEf)XCj#YVQmN#E3oy7CcDu5^F^O1deKVGvO xls(A4lzYzWr4`A#>sfE=+bpqASNrVQq5`yr!PC{xWt~$(699846J^c-008Y`bQAyp literal 0 HcmV?d00001 diff --git a/moremesecons_switchtorch/textures/jeija_torches_on.png.gz b/moremesecons_switchtorch/textures/jeija_torches_on.png.gz new file mode 100644 index 0000000000000000000000000000000000000000..632cf1dbd6dd36b881b8620b6e04541300a47941 GIT binary patch literal 244 zcmVkvfV1<<5Wa`oH(RzF@0ggovb<9| zxmP5|e}<30VKOp1>{pUN`pYM0r=BRScf4elF{r5}E)c(N{9k0001iPj)l_ literal 0 HcmV?d00001 diff --git a/moremesecons_switchtorch/textures/jeija_torches_on_ceiling.png.gz b/moremesecons_switchtorch/textures/jeija_torches_on_ceiling.png.gz new file mode 100644 index 0000000000000000000000000000000000000000..ebd6f29a21c8f38bf8f49ef645537b534bb11a1f GIT binary patch literal 264 zcmV+j0r&nNiwFqVQ885j18QYyYGGe=Z*pU3WpiI|ZeL?%X>4h3XD)DVX8`LA@N?(o zlHy`uVBq!ia0vp^fT^vI!PQUFx$k|{Zz+#@QG)r&IA)%ZL zR%;Gc{o&ZhEZ- z4y~dEC literal 0 HcmV?d00001 diff --git a/moremesecons_teleporter/depends.txt b/moremesecons_teleporter/depends.txt new file mode 100644 index 0000000..acaa924 --- /dev/null +++ b/moremesecons_teleporter/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/moremesecons_teleporter/init.lua b/moremesecons_teleporter/init.lua new file mode 100644 index 0000000..30a7c02 --- /dev/null +++ b/moremesecons_teleporter/init.lua @@ -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 +}) diff --git a/moremesecons_teleporter/init.lua~ b/moremesecons_teleporter/init.lua~ new file mode 100644 index 0000000..b8aa160 --- /dev/null +++ b/moremesecons_teleporter/init.lua~ @@ -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 +}) diff --git a/moremesecons_teleporter/textures/jeija_object_detector_on.png b/moremesecons_teleporter/textures/jeija_object_detector_on.png new file mode 100644 index 0000000000000000000000000000000000000000..96f8ba3260da4c3d303e91e1c175591d420ccebf GIT binary patch literal 735 zcmV<50wDc~P)E0007hNkl@40sD z2Bo+}5S6G3E#e~+OOY5WHg^673licFG4uy8AfOXM2q}mHQd>kxX@C$Xt>ZM5_V#wT6vij<>gClR;~%1>b+NVA--{ZNh>R!W)#mE);Mj<1t+WpI4ru;+ zJ{S#PQ4EVTPi@VnKhx9lG@s>;UEzvyQcjC0G37t=Njjm0Ta>E2vUX)5i@K?c5eK*2 zTz2dLaK++eC0dbEeC6+d*{6-G8;8R~WtC4p8)nU@LTtGxwd@2bN~DB`z)Qo;b?M1;Zj(bf;`$e+j+A21R78n ze;Y&LS^F7)lldeGno0J21y-uHK@dA{ito+W!{ z{Z4<}?@@2soWcSM02*ivXTvPZJn{k?v@f=)9@Njuv%m&o#P|L9G~UNP0LVXwnSJ9| zrs9gDa}iCFi4&)wM1&M2S@MtmJAqXe3fgGTc!OU9T5GMvY3vz~6+;0fz}UhTfHt=w zsHqxjcG}f+?biA&iYIZBB~c?%P!M#pZjXB=H~$L+fmp&{{MzYtf+>8a8Sak47h>3o93#IDuGeOIHHWTIXf1p%v6ToBPJkvTT}6 z&DPy5V@&U3FAT%o&%6C$zaG|~_nxQoG?^u@KD;t8uiw2s_;TQB@5Rd(e*jjFQ|;53 RT>}6B002ovPDHLkV1nDLPm%xt literal 0 HcmV?d00001 diff --git a/moremesecons_teleporter/textures/teleporter.png b/moremesecons_teleporter/textures/teleporter.png new file mode 100644 index 0000000000000000000000000000000000000000..f038093a363259979b552d2b9cf983149b505350 GIT binary patch literal 550 zcmV+>0@?kEP)e zSad^gZEa<4bO1wgWnpw>WFU8GbZ8()Nlj2!fese{00E9kL_t(2&t;NJavL!WL>mAp zaHvsMK1}X^8!udP>B|`sKo%oQN`fV;8}-;|`u+Kdp9wR#1Bl+Y7s{D(#@nQqy7%ZE z5#j!>h~D3A>0KRWe!qvAuPXq~nN`8eK=jVFJ`7K_T`u05x3(dLs`t)017Ouy7E(=N z_EO(&<8<=YVp#wnC8mC6duw4P(-emT05FpXRAX5Z zfN=L^@z(5m?O$L0c=XE!fX#C@BUM(7QoMHtQuH2UguAyEt@*mz`8>YAL6pq66uDl# zR$o`1roUo+o+8G;7~vkJ#2Ehw9tL8jlpw;poy;@F2!LyqQXm3mA_6mjL^*SWi*PA& zIQaDnGggHe@Ao{V{4!v8wF%Tq~=R2<4mraIJp3Z5|TwQnqSHDO?JeS#?|g`t;L78{SVik1Z)Z o`}c~KYxUM>w<7>g!v7ln2T5r6KFFZZ*Z=?k07*qoM6N<$g2RaAMF0Q* literal 0 HcmV?d00001 diff --git a/moremesecons_temporarygate/depends.txt b/moremesecons_temporarygate/depends.txt new file mode 100644 index 0000000..acaa924 --- /dev/null +++ b/moremesecons_temporarygate/depends.txt @@ -0,0 +1 @@ +mesecons diff --git a/moremesecons_temporarygate/init.lua b/moremesecons_temporarygate/init.lua new file mode 100644 index 0000000..33168bb --- /dev/null +++ b/moremesecons_temporarygate/init.lua @@ -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"}, + } +}) diff --git a/moremesecons_temporarygate/init.lua~ b/moremesecons_temporarygate/init.lua~ new file mode 100644 index 0000000..132b340 --- /dev/null +++ b/moremesecons_temporarygate/init.lua~ @@ -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"}, + } +}) diff --git a/moremesecons_temporarygate/textures/moremesecons_temporarygate_bottom.png b/moremesecons_temporarygate/textures/moremesecons_temporarygate_bottom.png new file mode 100644 index 0000000000000000000000000000000000000000..2e49d31100a4f2542ae8e853ab77b57df5371b93 GIT binary patch literal 438 zcmV;n0ZIOeP)^R{h7 zq^jNB-4TI>nSoro+ucuWZ(D91i)G=Gw}#3sVbby%nMXiMTCgV4EG?tsuE-mfQW!D5uq!h6OrpnF|*8M z=FAk4&*#&>#mqPa+V4!!zN#=(B!e}sg~?hAs^7Qtzd+U9b558*z};orHVhk)BX0t<8 literal 0 HcmV?d00001 diff --git a/moremesecons_temporarygate/textures/moremesecons_temporarygate_ends_off.png b/moremesecons_temporarygate/textures/moremesecons_temporarygate_ends_off.png new file mode 100644 index 0000000000000000000000000000000000000000..0242deb02538c485faf5c88ed29abcadbc46e1f5 GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9EQehduU!i=T5JNE+x z*-JcqUD@w&@G$Tit^2;#0Vvey>Eak-ar*7Sy}XAE1R5@$FZ1)`I>aSnvgQz5OzmDkBpv(If^>-X24A-u1Y zEoAt`U0Q;;4i~6RxqImK9fN%H69V;DSL{an^LB{Ts5z^_iw literal 0 HcmV?d00001 diff --git a/moremesecons_temporarygate/textures/moremesecons_temporarygate_ends_on.png b/moremesecons_temporarygate/textures/moremesecons_temporarygate_ends_on.png new file mode 100644 index 0000000000000000000000000000000000000000..19ae0cba2b4d3d8b1a1c7c40f39639942709cc53 GIT binary patch literal 228 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9EQehduU!i=T5JNE+x z*-JcqUD@w&@G$W4-`%un5>Tkw)5S5w;`G~tv0P0KA`KVw+1f8&NZr!Xw5G-ELD-!M zt2LVH?m2mE7k=b?_g${EZ3W+%w9Wq?&#Bod%MU2N|oO8ts3P2pk3(` z7ptp^ZdO0WH9Kbn; zQVQ=q$-Qj?PqFqsM@J7x(??XR+jDtY$idaY0fQgV_|O92;l>N3ln5d4-lO%jE2WT9 zE&>3mPhj|ZNEAgFV~R+J5U|!FrNkIBXXD-1Utv|u(^vAg@c;k-07*qoM6N<$g559k A2LJ#7 literal 0 HcmV?d00001 diff --git a/moremesecons_temporarygate/textures/moremesecons_temporarygate_on.png b/moremesecons_temporarygate/textures/moremesecons_temporarygate_on.png new file mode 100644 index 0000000000000000000000000000000000000000..61f52f262978733ff8dd0c104651062a20344558 GIT binary patch literal 635 zcmV->0)+jEP)dO-miL!8@AEwHzeik%YPA|0V~|p!l)`mgT-P0FV+=tM;QKy82o@I? z1%P`2u-2lKLP|*-$K-NjWV4Dm&d_dK&dxNR=V7g-)9DN@7y@XmNvG4~^JyNJ_8A`s ztqterg3p`NoSue6QG}Fo02rt^j`4k;Lg5nk?tfq^U#H*y!L_S5nY`Sf_-KbhAwwdO zAc~?yJ$pqDE)dO&smv6+LCs|*& zcwQIbY;*h8^O0{)UoUd-?Jeo_3{hm5n|r0!)@E=gCmo_F#u$T_fNa+Pt7X=PNJk>2 zL+88X?YAb}n6y0tHAq174fM)9x#u~P_o^X27K`BMKT-HN2N+}6~fV1yOb~c}qE4(A0 zZ_?j=gVuTWcIP=h{=Mut&S(zaS1PpjVE*+>n(Y)g&*=Q@5^0MuV>Fu~VHlE1rReo~ zqX2;MyU;85&|1@O$9P@>V+@XSj#7#^j)zh>)P+B1X=%xGT^At))>Eak-ar*7qjl4|`5^WE^@3&SIlyci(P$-fep1|O{ z#aQnE&zgmocd!_WE6({Ixub>kJQKf;Soi;gvQ=6BHE&N^Dt9i@nBd~oxhzwnjnQ+)&3x0tcji{g a{bahsZ6y6SjYS#g9tKZWKbLh*2~7YD>r-<8 literal 0 HcmV?d00001 diff --git a/moremesecons_temporarygate/textures/moremesecons_temporarygate_sides_on.png b/moremesecons_temporarygate/textures/moremesecons_temporarygate_sides_on.png new file mode 100644 index 0000000000000000000000000000000000000000..1c8edaab9d4cc227cbe58729466711c26e8488dc GIT binary patch literal 234 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9EQehduU!i=T5JNE+x z*-JcqUD@w&@G$W4-`%un5>Tkq)5S5w;`H0IhI|JDWR8D)zyD$DkqhOl<{P>XIy4=W zty&xBkRvhUh>qTc=sg!iYJVB;XjwR)yJo@FtiSBHWtZ)mxjjs_y?}(iAo=GKsF90(2CEr>mdKI;Vst0JMBsb^rhX literal 0 HcmV?d00001 diff --git a/moremesecons_wireless/depends.txt b/moremesecons_wireless/depends.txt new file mode 100644 index 0000000..7ebf50c --- /dev/null +++ b/moremesecons_wireless/depends.txt @@ -0,0 +1 @@ +mesecons \ No newline at end of file diff --git a/moremesecons_wireless/init.lua b/moremesecons_wireless/init.lua new file mode 100644 index 0000000..98fcbf6 --- /dev/null +++ b/moremesecons_wireless/init.lua @@ -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 +}) diff --git a/moremesecons_wireless/init.lua~ b/moremesecons_wireless/init.lua~ new file mode 100644 index 0000000..c54cefd --- /dev/null +++ b/moremesecons_wireless/init.lua~ @@ -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 +}) diff --git a/moremesecons_wireless/textures/wireless.png b/moremesecons_wireless/textures/wireless.png new file mode 100644 index 0000000000000000000000000000000000000000..e16d40cff54c1e2d88bfb2257248d6d44be5ec5f GIT binary patch literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61SBU+%rFB|Y)RhkE)4%caKYZ?lYt_f1s;*b z3=G`DAk4@xYmNj^kiEpy*OmP~E4P5S+V8LH41hwCC9V-A&iT2ysd*&~&PAz-C8;S2 z<(VZJ3hti10pX2&;y^`ao-U3d8t0P}6a)>73=CpU{qtXvwRdHY&yrgP9Htu*xL*2+ sw{6x>-zPh%?m)?Rh40KKr99XeqMA88*%|UhfF>|_y85}Sb4q9e0Ie-LSO5S3 literal 0 HcmV?d00001