From 45bbd9f7e3c48bccd89d1db5715e7ef3348c5d36 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Mon, 29 Oct 2018 23:58:07 +0300 Subject: [PATCH 1/7] =?UTF-8?q?Don=E2=80=99t=20damage=20unloaded=20blocks?= =?UTF-8?q?=20(#435)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mesecons_mvps/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 428c78a..b8abdd7 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -55,8 +55,6 @@ end -- tests if the node can be pushed into, e.g. air, water, grass local function node_replaceable(name) - if name == "ignore" then return true end - if minetest.registered_nodes[name] then return minetest.registered_nodes[name].buildable_to or false end @@ -260,6 +258,10 @@ function mesecon.mvps_move_objects(pos, dir, nodestack, movefactor) end end +-- Never push into unloaded blocks. Don’t try to pull from them, either. +-- TODO: load blocks instead, as with wires. +mesecon.register_mvps_stopper("ignore") + mesecon.register_mvps_stopper("doors:door_steel_b_1") mesecon.register_mvps_stopper("doors:door_steel_t_1") mesecon.register_mvps_stopper("doors:door_steel_b_2") From df4e880d8be157896e45753e27fa929c80664749 Mon Sep 17 00:00:00 2001 From: ne-vlezay80 Date: Tue, 6 Nov 2018 11:48:44 +0300 Subject: [PATCH 2/7] Fix crash in microcontroller (#439) Add check nil var with bug from crash server. fixes #438 --- mesecons_microcontroller/init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua index 9b1bf3b..f9ba979 100644 --- a/mesecons_microcontroller/init.lua +++ b/mesecons_microcontroller/init.lua @@ -571,6 +571,7 @@ yc.command_parsecondition = function(cond, L, eeprom) if cond:sub(i+1, i+1) == nil then break end if s == "&" then if a==nil then return nil end + if b==nil then return nil end local buf = ((a==1) and (b==1)) if buf == true then buf = "1" end if buf == false then buf = "0" end @@ -580,6 +581,7 @@ yc.command_parsecondition = function(cond, L, eeprom) end if s == "|" then if a==nil then return nil end + if b==nil then return nil end local buf = ((a == 1) or (b == 1)) if buf == true then buf = "1" end if buf == false then buf = "0" end @@ -589,6 +591,7 @@ yc.command_parsecondition = function(cond, L, eeprom) end if s == "~" then if a==nil then return nil end + if b==nil then return nil end local buf = (((a == 1) or (b == 1)) and not((a==1) and (b==1))) if buf == true then buf = "1" end if buf == false then buf = "0" end From d3cabedbb08d4edb632fbbec77fb0ae0fd680379 Mon Sep 17 00:00:00 2001 From: number Zero Date: Sun, 9 Dec 2018 15:50:02 +0300 Subject: [PATCH 3/7] Prevent long error message from covering the button --- mesecons_luacontroller/init.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index e91d460..19b6479 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -619,12 +619,13 @@ local function reset_formspec(meta, code, errmsg) meta:mark_as_private("code") code = minetest.formspec_escape(code or "") errmsg = minetest.formspec_escape(tostring(errmsg or "")) - meta:set_string("formspec", "size[12,10]".. - "background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]".. - "textarea[0.2,0.2;12.2,9.5;code;;"..code.."]".. - "image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]".. - "image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]".. - "label[0.1,9;"..errmsg.."]") + meta:set_string("formspec", "size[12,10]" + .."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]" + .."label[0.1,8.3;"..errmsg.."]" + .."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]" + .."image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]" + .."image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]" + ) end local function reset_meta(pos, code, errmsg) From 9d239cbfff5db2780dacd0d67479eed194ec340d Mon Sep 17 00:00:00 2001 From: Christopher Head Date: Sun, 9 Dec 2018 05:38:23 -0800 Subject: [PATCH 4/7] Fix typos (#442) --- mesecons_fpga/doc/fpga/description.html | 2 +- mesecons_powerplant/doc/powerplant/description.html | 2 +- .../doc/pressureplate_stone/description.html | 2 +- mesecons_pressureplates/doc/pressureplate_wood/description.html | 2 +- mesecons_random/doc/ghoststone/description.html | 2 +- mesecons_random/doc/removestone/description.html | 2 +- mesecons_solarpanel/doc/solarpanel/description.html | 2 +- mesecons_switch/doc/switch/description.html | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mesecons_fpga/doc/fpga/description.html b/mesecons_fpga/doc/fpga/description.html index be6bd65..95177b2 100644 --- a/mesecons_fpga/doc/fpga/description.html +++ b/mesecons_fpga/doc/fpga/description.html @@ -1,5 +1,5 @@ FPGAs can be used to chain multiple logic gates together in a compact manner. They come with 4 I/O ports and 10 internal registers, -which can then be connected with eachother to form logic circuits.
+which can then be connected with each other to form logic circuits.
Supported gate types: AND, OR, NOT, XOR, NAND, XNOR, Buffer (=)
I/O ports: A B C D; Registers: numbered 0 to 9 diff --git a/mesecons_powerplant/doc/powerplant/description.html b/mesecons_powerplant/doc/powerplant/description.html index 12abbbb..4ed8f33 100644 --- a/mesecons_powerplant/doc/powerplant/description.html +++ b/mesecons_powerplant/doc/powerplant/description.html @@ -1 +1 @@ -A power plant is a receptor that is always turned on: It provides energy. +A power plant is a receptor that is always turned on: it provides energy. diff --git a/mesecons_pressureplates/doc/pressureplate_stone/description.html b/mesecons_pressureplates/doc/pressureplate_stone/description.html index 3edc95b..35e3fc0 100644 --- a/mesecons_pressureplates/doc/pressureplate_stone/description.html +++ b/mesecons_pressureplates/doc/pressureplate_stone/description.html @@ -1 +1 @@ -This receptor turns on if there's an object above it. And object can be a player, an item, a mob... +This receptor turns on if there's an object above it. An object can be a player, an item, a mob... diff --git a/mesecons_pressureplates/doc/pressureplate_wood/description.html b/mesecons_pressureplates/doc/pressureplate_wood/description.html index 3edc95b..35e3fc0 100644 --- a/mesecons_pressureplates/doc/pressureplate_wood/description.html +++ b/mesecons_pressureplates/doc/pressureplate_wood/description.html @@ -1 +1 @@ -This receptor turns on if there's an object above it. And object can be a player, an item, a mob... +This receptor turns on if there's an object above it. An object can be a player, an item, a mob... diff --git a/mesecons_random/doc/ghoststone/description.html b/mesecons_random/doc/ghoststone/description.html index 138a2b3..395430e 100644 --- a/mesecons_random/doc/ghoststone/description.html +++ b/mesecons_random/doc/ghoststone/description.html @@ -1 +1 @@ -Ghoststones disappear when powered, just like Removestones. But in contrast to Removestones, they Reappear again when not powered anymore and they are also conductive. +Ghoststones disappear when powered, just like Removestones. But in contrast to Removestones, they reappear again when not powered anymore and they are also conductive. diff --git a/mesecons_random/doc/removestone/description.html b/mesecons_random/doc/removestone/description.html index d540fe9..6947441 100644 --- a/mesecons_random/doc/removestone/description.html +++ b/mesecons_random/doc/removestone/description.html @@ -1 +1 @@ -Removestones are propably the simplest effectors possible. They simply disappear when powered. +Removestones are probably the simplest effectors possible. They simply disappear when powered. diff --git a/mesecons_solarpanel/doc/solarpanel/description.html b/mesecons_solarpanel/doc/solarpanel/description.html index f8e7450..add6213 100644 --- a/mesecons_solarpanel/doc/solarpanel/description.html +++ b/mesecons_solarpanel/doc/solarpanel/description.html @@ -1 +1 @@ -Solar Panel are light receptors: they turn on if there is enough light. +Solar panels are light receptors: they turn on if there is enough light. diff --git a/mesecons_switch/doc/switch/description.html b/mesecons_switch/doc/switch/description.html index 3ef4ace..0c8f607 100644 --- a/mesecons_switch/doc/switch/description.html +++ b/mesecons_switch/doc/switch/description.html @@ -1 +1 @@ -The switch is a receptor. It changes its state as when punched. +The switch is a receptor. It changes its state when punched. From 6e767a6c7654748b376df22988ad656528b44911 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 21 Dec 2018 22:02:57 +0300 Subject: [PATCH 5/7] Make sticky piston stick falling things as well (#436) --- mesecons_pistons/init.lua | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index 386cffa..56a3f73 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -55,7 +55,7 @@ local function piston_get_rules(node) return rules end -local function piston_remove_pusher(pos, node) +local function piston_remove_pusher(pos, node, check_falling) local pistonspec = get_pistonspec(node.name, "onname") local dir = vector.multiply(minetest.facedir_to_dir(node.param2), -1) local pusherpos = vector.add(pos, dir) @@ -72,7 +72,14 @@ local function piston_remove_pusher(pos, node) max_hear_distance = 20, gain = 0.3, }) - minetest.check_for_falling(pusherpos) + + if check_falling then + minetest.check_for_falling(pusherpos) + end +end + +local function piston_after_dig(pos, node) + piston_remove_pusher(pos, node, true) end local piston_on = function(pos, node) @@ -97,7 +104,7 @@ end local function piston_off(pos, node) local pistonspec = get_pistonspec(node.name, "onname") minetest.set_node(pos, {param2 = node.param2, name = pistonspec.offname}) - piston_remove_pusher(pos, node) + piston_remove_pusher(pos, node, not pistonspec.sticky) if not pistonspec.sticky then return @@ -293,7 +300,7 @@ minetest.register_node("mesecons_pistons:piston_normal_on", { paramtype2 = "facedir", is_ground_content = false, drop = "mesecons_pistons:piston_normal_off", - after_dig_node = piston_remove_pusher, + after_dig_node = piston_after_dig, node_box = piston_on_box, selection_box = piston_on_box, sounds = default.node_sound_wood_defaults(), @@ -371,7 +378,7 @@ minetest.register_node("mesecons_pistons:piston_sticky_on", { paramtype2 = "facedir", is_ground_content = false, drop = "mesecons_pistons:piston_sticky_off", - after_dig_node = piston_remove_pusher, + after_dig_node = piston_after_dig, node_box = piston_on_box, selection_box = piston_on_box, sounds = default.node_sound_wood_defaults(), From 302a28934d75a2a29f7f060eea12cb19966f3e5a Mon Sep 17 00:00:00 2001 From: Christopher Head Date: Fri, 21 Dec 2018 11:10:08 -0800 Subject: [PATCH 6/7] Document inactive block behaviour (#447) --- mesecons_blinkyplant/doc/blinkyplant/description.html | 1 + mesecons_commandblock/doc/commandblock/description.html | 1 + mesecons_delayer/doc/delayer/description.html | 2 +- mesecons_detector/doc/nodedetector/description.html | 1 + mesecons_detector/doc/objectdetector/description.html | 1 + mesecons_extrawires/doc/corner/description.html | 2 +- mesecons_extrawires/doc/crossing/description.html | 2 +- mesecons_extrawires/doc/mese/description.html | 2 +- mesecons_extrawires/doc/tjunction/description.html | 2 +- mesecons_extrawires/doc/vertical/description.html | 2 +- mesecons_fpga/doc/fpga/description.html | 3 ++- mesecons_gates/doc/and/description.html | 1 + mesecons_gates/doc/diode/description.html | 1 + mesecons_gates/doc/nand/description.html | 1 + mesecons_gates/doc/nor/description.html | 1 + mesecons_gates/doc/not/description.html | 1 + mesecons_gates/doc/or/description.html | 1 + mesecons_gates/doc/xor/description.html | 1 + mesecons_hydroturbine/doc/waterturbine/description.html | 1 + mesecons_insulated/doc/insulated/description.html | 2 +- mesecons_lightstone/doc/lightstone_blue/description.html | 1 + mesecons_lightstone/doc/lightstone_darkgrey/description.html | 1 + mesecons_lightstone/doc/lightstone_green/description.html | 1 + mesecons_lightstone/doc/lightstone_lightgrey/description.html | 1 + mesecons_lightstone/doc/lightstone_red/description.html | 1 + mesecons_lightstone/doc/lightstone_yellow/description.html | 1 + mesecons_luacontroller/doc/luacontroller/description.html | 2 ++ mesecons_movestones/doc/movestone/description.html | 1 + mesecons_movestones/doc/movestone_sticky/description.html | 2 ++ mesecons_pistons/doc/piston/description.html | 2 ++ mesecons_pistons/doc/piston_sticky/description.html | 3 +++ mesecons_powerplant/doc/powerplant/description.html | 1 + mesecons_random/doc/ghoststone/description.html | 1 + mesecons_random/doc/removestone/description.html | 1 + mesecons_solarpanel/doc/solarpanel/description.html | 1 + mesecons_torch/doc/torch/description.html | 1 + mesecons_wires/doc/mesecon/description.html | 2 +- 37 files changed, 43 insertions(+), 9 deletions(-) diff --git a/mesecons_blinkyplant/doc/blinkyplant/description.html b/mesecons_blinkyplant/doc/blinkyplant/description.html index 2a7db48..0d987a5 100644 --- a/mesecons_blinkyplant/doc/blinkyplant/description.html +++ b/mesecons_blinkyplant/doc/blinkyplant/description.html @@ -1 +1,2 @@ The blinky plants toggles between on and off state every three seconds. Can be used to make clocks. Also works after having restarted the game. +It stops blinking in an inactive block, then starts again when the block becomes active. diff --git a/mesecons_commandblock/doc/commandblock/description.html b/mesecons_commandblock/doc/commandblock/description.html index 405b7e5..9ba7ce5 100644 --- a/mesecons_commandblock/doc/commandblock/description.html +++ b/mesecons_commandblock/doc/commandblock/description.html @@ -1 +1,2 @@ There is no crafting recipe as this should only be available for server admins. Quite similar to the Minecraft counterpart. Executes server commands. +It works in inactive blocks. diff --git a/mesecons_delayer/doc/delayer/description.html b/mesecons_delayer/doc/delayer/description.html index f3a5280..966d729 100644 --- a/mesecons_delayer/doc/delayer/description.html +++ b/mesecons_delayer/doc/delayer/description.html @@ -1 +1 @@ -The delayer delays the signal from the input for a determined time. The time can be set by punching the delayer. Possible delays are: 0.1 seconds, 0.3 seconds, 0.5 seconds and 1 second. You may try to use it for creating songs with the noteblock. +The delayer delays the signal from the input for a determined time. The time can be set by punching the delayer. Possible delays are: 0.1 seconds, 0.3 seconds, 0.5 seconds and 1 second. You may try to use it for creating songs with the noteblock. It works in unloaded blocks. diff --git a/mesecons_detector/doc/nodedetector/description.html b/mesecons_detector/doc/nodedetector/description.html index be1582e..ee8c09d 100644 --- a/mesecons_detector/doc/nodedetector/description.html +++ b/mesecons_detector/doc/nodedetector/description.html @@ -5,3 +5,4 @@ respond with the detected nodename or you can send any other string and it will set this string as the node to scan for. Nodenames must include the mod they reside in, so for instance default:dirt, not just dirt. The distance parameter specifies how many blocks are between the node detector and the node to detect. +Automatic scanning with Mesecons output only works when the detector is in an active block, but Digilines queries always work. diff --git a/mesecons_detector/doc/objectdetector/description.html b/mesecons_detector/doc/objectdetector/description.html index bb88856..a928434 100644 --- a/mesecons_detector/doc/objectdetector/description.html +++ b/mesecons_detector/doc/objectdetector/description.html @@ -2,3 +2,4 @@ The object detector is a receptor. It changes its state when a player approaches Right-click it to set a name to scan for. You can also search for comma-separated lists of players where the detector gets activated if any of the names in the list are found. It can also receive digiline signals which are the name to scan for on the specified channel in the right-click menu. +Automatic scanning with Mesecons output only works when the detector is in an active block, but Digilines queries always work. diff --git a/mesecons_extrawires/doc/corner/description.html b/mesecons_extrawires/doc/corner/description.html index 92de8b0..fc420d1 100644 --- a/mesecons_extrawires/doc/corner/description.html +++ b/mesecons_extrawires/doc/corner/description.html @@ -1 +1 @@ -Insulated corners are conductors that only conduct between the inputs (also not up or down). When placing they always point to the left in direction of your vision. +Insulated corners are conductors that only conduct between the inputs (also not up or down). When placing they always point to the left in direction of your vision. Like uninsulated wires, they work through unloaded blocks. diff --git a/mesecons_extrawires/doc/crossing/description.html b/mesecons_extrawires/doc/crossing/description.html index aa4cf25..5f02382 100644 --- a/mesecons_extrawires/doc/crossing/description.html +++ b/mesecons_extrawires/doc/crossing/description.html @@ -1 +1 @@ -Insulated crossing are conductors that conduct two signals between the opposing sides, the signals are insulated to each other. +Insulated crossing are conductors that conduct two signals between the opposing sides, the signals are insulated to each other. Like uninsulated wires, they work through unloaded blocks. diff --git a/mesecons_extrawires/doc/mese/description.html b/mesecons_extrawires/doc/mese/description.html index 1a14864..b29e92c 100644 --- a/mesecons_extrawires/doc/mese/description.html +++ b/mesecons_extrawires/doc/mese/description.html @@ -1 +1 @@ -The basic prerequesite for mesecons, can be crafted into wires and other stuff. Have a look at the Minetest Wiki for more information. Mese is a conductor. It conducts in all six directions: Up/Down/Left/Right/Forward/Backward +The basic prerequesite for mesecons, can be crafted into wires and other stuff. Have a look at the Minetest Wiki for more information. Mese is a conductor. It conducts in all six directions: Up/Down/Left/Right/Forward/Backward. Like horizontal wires, Mese conduction works through unloaded blocks. diff --git a/mesecons_extrawires/doc/tjunction/description.html b/mesecons_extrawires/doc/tjunction/description.html index f655a5d..647bba6 100644 --- a/mesecons_extrawires/doc/tjunction/description.html +++ b/mesecons_extrawires/doc/tjunction/description.html @@ -1 +1 @@ -Insulated T-Junctions are conductors that only conduct between the inputs (also not up or down). +Insulated T-Junctions are conductors that only conduct between the inputs (also not up or down). Like uninsulated wires, they work through unloaded blocks. diff --git a/mesecons_extrawires/doc/vertical/description.html b/mesecons_extrawires/doc/vertical/description.html index df09b94..8508542 100644 --- a/mesecons_extrawires/doc/vertical/description.html +++ b/mesecons_extrawires/doc/vertical/description.html @@ -1 +1 @@ -Vertical Mesecons only conduct up and down. Plates appear at the ends, at that place they also conduct to the side. +Vertical Mesecons only conduct up and down. Plates appear at the ends, at that place they also conduct to the side. Like horizontal wires, they work through unloaded blocks. diff --git a/mesecons_fpga/doc/fpga/description.html b/mesecons_fpga/doc/fpga/description.html index 95177b2..a4cbeed 100644 --- a/mesecons_fpga/doc/fpga/description.html +++ b/mesecons_fpga/doc/fpga/description.html @@ -1,5 +1,6 @@ FPGAs can be used to chain multiple logic gates together in a compact manner. They come with 4 I/O ports and 10 internal registers, -which can then be connected with each other to form logic circuits.
+which can then be connected with each other to form logic circuits. +They work fine in unloaded blocks.
Supported gate types: AND, OR, NOT, XOR, NAND, XNOR, Buffer (=)
I/O ports: A B C D; Registers: numbered 0 to 9 diff --git a/mesecons_gates/doc/and/description.html b/mesecons_gates/doc/and/description.html index 528839c..e8aff91 100644 --- a/mesecons_gates/doc/and/description.html +++ b/mesecons_gates/doc/and/description.html @@ -1 +1,2 @@ AND gates power their output if both inputs (from left and right) are powered. +They work in unloaded blocks. diff --git a/mesecons_gates/doc/diode/description.html b/mesecons_gates/doc/diode/description.html index 5f82706..b96aced 100644 --- a/mesecons_gates/doc/diode/description.html +++ b/mesecons_gates/doc/diode/description.html @@ -1 +1,2 @@ Diodes conduct signals in one direction only. +They work in unloaded blocks. diff --git a/mesecons_gates/doc/nand/description.html b/mesecons_gates/doc/nand/description.html index 69c1d4f..c46a7e1 100644 --- a/mesecons_gates/doc/nand/description.html +++ b/mesecons_gates/doc/nand/description.html @@ -1 +1,2 @@ NAND gates do not power their output if both inputs (from left and right) are powered, but power it in every other case. +They work in unloaded blocks. diff --git a/mesecons_gates/doc/nor/description.html b/mesecons_gates/doc/nor/description.html index 28d66a4..7d53953 100644 --- a/mesecons_gates/doc/nor/description.html +++ b/mesecons_gates/doc/nor/description.html @@ -1 +1,2 @@ NOR gates only power their output if none of their two inputs is powered. They are basically OR gates with a NOT gate at their output. +They work in unloaded blocks. diff --git a/mesecons_gates/doc/not/description.html b/mesecons_gates/doc/not/description.html index 7538dc9..5a08423 100644 --- a/mesecons_gates/doc/not/description.html +++ b/mesecons_gates/doc/not/description.html @@ -1 +1,2 @@ NOT gates invert signals, just like a mesecon torch does, but faster. The input is at the opposite side of the output. +They work in unloaded blocks. diff --git a/mesecons_gates/doc/or/description.html b/mesecons_gates/doc/or/description.html index f7f5539..15d598f 100644 --- a/mesecons_gates/doc/or/description.html +++ b/mesecons_gates/doc/or/description.html @@ -1 +1,2 @@ OR gates power their output if either of their inputs (or both) are powered. You could basically get the same behaviour with two diodes, but OR gates save some space. +They work in unloaded blocks. diff --git a/mesecons_gates/doc/xor/description.html b/mesecons_gates/doc/xor/description.html index f52f3fc..74f8b5f 100644 --- a/mesecons_gates/doc/xor/description.html +++ b/mesecons_gates/doc/xor/description.html @@ -1 +1,2 @@ XOR gates power their output if only one input is powered, they're off if either both or none of the inputs is powered. +They work in unloaded blocks. diff --git a/mesecons_hydroturbine/doc/waterturbine/description.html b/mesecons_hydroturbine/doc/waterturbine/description.html index 4b4e5a0..6153d51 100644 --- a/mesecons_hydroturbine/doc/waterturbine/description.html +++ b/mesecons_hydroturbine/doc/waterturbine/description.html @@ -1 +1,2 @@ Water turbines are receptors that turn on if flowing water is above them. +They only work in active blocks; in inactive blocks they keep their old state. diff --git a/mesecons_insulated/doc/insulated/description.html b/mesecons_insulated/doc/insulated/description.html index df2a6df..deb344d 100644 --- a/mesecons_insulated/doc/insulated/description.html +++ b/mesecons_insulated/doc/insulated/description.html @@ -1 +1 @@ - Insulated mesecons are conductors that only conduct in one direction (and also not up or down). + Insulated mesecons are conductors that only conduct in one direction (and also not up or down). Like uninsulated wires, they work through unloaded blocks. diff --git a/mesecons_lightstone/doc/lightstone_blue/description.html b/mesecons_lightstone/doc/lightstone_blue/description.html index 813e6ea..5397a96 100644 --- a/mesecons_lightstone/doc/lightstone_blue/description.html +++ b/mesecons_lightstone/doc/lightstone_blue/description.html @@ -1 +1,2 @@ Effector, glows blue when powered. +It works in an inactive block. diff --git a/mesecons_lightstone/doc/lightstone_darkgrey/description.html b/mesecons_lightstone/doc/lightstone_darkgrey/description.html index 826ca0f..aad59ea 100644 --- a/mesecons_lightstone/doc/lightstone_darkgrey/description.html +++ b/mesecons_lightstone/doc/lightstone_darkgrey/description.html @@ -1 +1,2 @@ Effector, glows dark grey when powered. +It works in an inactive block. diff --git a/mesecons_lightstone/doc/lightstone_green/description.html b/mesecons_lightstone/doc/lightstone_green/description.html index cb5b515..1191334 100644 --- a/mesecons_lightstone/doc/lightstone_green/description.html +++ b/mesecons_lightstone/doc/lightstone_green/description.html @@ -1 +1,2 @@ Effector, glows green when powered. +It works in an inactive block. diff --git a/mesecons_lightstone/doc/lightstone_lightgrey/description.html b/mesecons_lightstone/doc/lightstone_lightgrey/description.html index 990b501..b3003d2 100644 --- a/mesecons_lightstone/doc/lightstone_lightgrey/description.html +++ b/mesecons_lightstone/doc/lightstone_lightgrey/description.html @@ -1 +1,2 @@ Effector, glows light grey when powered. +It works in an inactive block. diff --git a/mesecons_lightstone/doc/lightstone_red/description.html b/mesecons_lightstone/doc/lightstone_red/description.html index 699b1ee..f49aeac 100644 --- a/mesecons_lightstone/doc/lightstone_red/description.html +++ b/mesecons_lightstone/doc/lightstone_red/description.html @@ -1 +1,2 @@ Effector, glows red when powered. +It works in an inactive block. diff --git a/mesecons_lightstone/doc/lightstone_yellow/description.html b/mesecons_lightstone/doc/lightstone_yellow/description.html index 2bed7f2..a97839b 100644 --- a/mesecons_lightstone/doc/lightstone_yellow/description.html +++ b/mesecons_lightstone/doc/lightstone_yellow/description.html @@ -1 +1,2 @@ Effector, glows yellow when powered. +It works in an inactive block. diff --git a/mesecons_luacontroller/doc/luacontroller/description.html b/mesecons_luacontroller/doc/luacontroller/description.html index e549ffe..8c5d023 100644 --- a/mesecons_luacontroller/doc/luacontroller/description.html +++ b/mesecons_luacontroller/doc/luacontroller/description.html @@ -1,5 +1,7 @@ The Luacontroller is an advanced programmable component. You can simply code it in the language Mesecons uses itself: Lua! All the code runs in a sandbox, so it's completely safe (but I won't guarantee that for absolute certainty!). +It works fine in an unloaded block, loading the block when the program needs to run. +Events are properly delivered after a server restart. Documentation is available here! diff --git a/mesecons_movestones/doc/movestone/description.html b/mesecons_movestones/doc/movestone/description.html index 8555a9e..b7138a0 100644 --- a/mesecons_movestones/doc/movestone/description.html +++ b/mesecons_movestones/doc/movestone/description.html @@ -1 +1,2 @@ Movestones are effectors that push the blocks in front of them. They move along on the right side of a mesecon wire track. +A movestone trying to move into, or push other nodes into, an unloaded block doesn't move. diff --git a/mesecons_movestones/doc/movestone_sticky/description.html b/mesecons_movestones/doc/movestone_sticky/description.html index 460c277..f19d6a5 100644 --- a/mesecons_movestones/doc/movestone_sticky/description.html +++ b/mesecons_movestones/doc/movestone_sticky/description.html @@ -1 +1,3 @@ Movestones are effectors that push the blocks in front of them. They move along on the right side of a mesecon wire track. Sticky ones also pull blocks. +A sticky movestone trying to move into, or push other nodes into, an unloaded block doesn't move. +A sticky movestone trying to pull nodes from an unloaded block moves but leaves them behind. diff --git a/mesecons_pistons/doc/piston/description.html b/mesecons_pistons/doc/piston/description.html index d95dfb9..b9dffaa 100644 --- a/mesecons_pistons/doc/piston/description.html +++ b/mesecons_pistons/doc/piston/description.html @@ -1 +1,3 @@ Pistons are effectors, they push up to 20 blocks in front of them. The push direction can be set by placing them from different angles. +A piston pointing into an unloaded block won't extend. +A piston retracting from an unloaded block works, but gravity-sensitive nodes above the empty space may not fall. diff --git a/mesecons_pistons/doc/piston_sticky/description.html b/mesecons_pistons/doc/piston_sticky/description.html index 3974097..580b76f 100644 --- a/mesecons_pistons/doc/piston_sticky/description.html +++ b/mesecons_pistons/doc/piston_sticky/description.html @@ -1 +1,4 @@ Sticky pistons are effectors, they push up to 20 blocks in front of them. The push direction can be set by placing them from different angles. Sticky ones also pull 1 block. +A sticky piston pointing into an unloaded block won't extend. +A sticky piston retracting from within an unloaded block works and pulls a node, but if it doesn't pull anything, then gravity-sensitive nodes above the empty space may not fall. +An extended sticky piston that touches the surface of an unloaded block and loses signal retracts but doesn't pull anything. diff --git a/mesecons_powerplant/doc/powerplant/description.html b/mesecons_powerplant/doc/powerplant/description.html index 4ed8f33..22be496 100644 --- a/mesecons_powerplant/doc/powerplant/description.html +++ b/mesecons_powerplant/doc/powerplant/description.html @@ -1 +1,2 @@ A power plant is a receptor that is always turned on: it provides energy. +It continues to work in an unloaded block. diff --git a/mesecons_random/doc/ghoststone/description.html b/mesecons_random/doc/ghoststone/description.html index 395430e..d54ef63 100644 --- a/mesecons_random/doc/ghoststone/description.html +++ b/mesecons_random/doc/ghoststone/description.html @@ -1 +1,2 @@ Ghoststones disappear when powered, just like Removestones. But in contrast to Removestones, they reappear again when not powered anymore and they are also conductive. +They work in inactive blocks. diff --git a/mesecons_random/doc/removestone/description.html b/mesecons_random/doc/removestone/description.html index 6947441..ccd3c14 100644 --- a/mesecons_random/doc/removestone/description.html +++ b/mesecons_random/doc/removestone/description.html @@ -1 +1,2 @@ Removestones are probably the simplest effectors possible. They simply disappear when powered. +They work in inactive blocks. diff --git a/mesecons_solarpanel/doc/solarpanel/description.html b/mesecons_solarpanel/doc/solarpanel/description.html index add6213..53570ca 100644 --- a/mesecons_solarpanel/doc/solarpanel/description.html +++ b/mesecons_solarpanel/doc/solarpanel/description.html @@ -1 +1,2 @@ Solar panels are light receptors: they turn on if there is enough light. +They only work in active blocks; in inactive blocks they keep their old state. diff --git a/mesecons_torch/doc/torch/description.html b/mesecons_torch/doc/torch/description.html index da7f19c..60a6713 100644 --- a/mesecons_torch/doc/torch/description.html +++ b/mesecons_torch/doc/torch/description.html @@ -1 +1,2 @@ The torch is an inverter, it may take up to 1 second until the signal has passed through. The input is 2 blocks away in the direction of the stick, outputs are around the mesecon glow. +It doesn't work in an inactive block; it just retains its state until the block becomes active. diff --git a/mesecons_wires/doc/mesecon/description.html b/mesecons_wires/doc/mesecon/description.html index f217be9..b20606b 100644 --- a/mesecons_wires/doc/mesecon/description.html +++ b/mesecons_wires/doc/mesecon/description.html @@ -1 +1 @@ -Mesecons are the wires, use them to connect effectors with receptors. +Mesecons are the wires, use them to connect effectors with receptors. Wiring works through unloaded blocks; they’re loaded when the signal level changes. From 737f366741f54659b17bd9c96e2232eedb9735ee Mon Sep 17 00:00:00 2001 From: Thomas Rudin Date: Sat, 29 Dec 2018 21:48:32 +0100 Subject: [PATCH 7/7] LuaC: add lightweight interrupts (#449) --- mesecons_luacontroller/init.lua | 67 ++++++++++++++++++++++----------- settingtypes.txt | 4 ++ 2 files changed, 48 insertions(+), 23 deletions(-) diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua index 19b6479..1c93e48 100644 --- a/mesecons_luacontroller/init.lua +++ b/mesecons_luacontroller/init.lua @@ -266,32 +266,45 @@ local function remove_functions(x) return x end --- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards -local function get_interrupt(pos, itbl, send_warning) - -- iid = interrupt id - local function interrupt(time, iid) - -- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y - -- Hence the values get moved out. Should take less time than original, so totally compatible - if type(time) ~= "number" then return end - table.insert(itbl, function () - -- Outside string metatable sandbox, can safely run this now - local luac_id = minetest.get_meta(pos):get_int("luac_id") - -- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data. - -- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended. - -- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place - iid = remove_functions(iid) - local msg_ser = minetest.serialize(iid) - if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then - mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1) - else - send_warning("An interrupt ID was too large!") - end +-- The setting affects API so is not intended to be changeable at runtime +local get_interrupt +if mesecon.setting("luacontroller_lightweight_interrupts", false) then + -- use node timer + get_interrupt = function(pos, itbl, send_warning) + return (function(time, iid) + if type(time) ~= "number" then error("Delay must be a number") end + if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end + table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end) end) end - return interrupt +else + -- use global action queue + -- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards + get_interrupt = function(pos, itbl, send_warning) + -- iid = interrupt id + local function interrupt(time, iid) + -- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y + -- Hence the values get moved out. Should take less time than original, so totally compatible + if type(time) ~= "number" then error("Delay must be a number") end + table.insert(itbl, function () + -- Outside string metatable sandbox, can safely run this now + local luac_id = minetest.get_meta(pos):get_int("luac_id") + -- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data. + -- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended. + -- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place + iid = remove_functions(iid) + local msg_ser = minetest.serialize(iid) + if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then + mesecon.queue:add_action(pos, "lc_interrupt", {luac_id, iid}, time, iid, 1) + else + send_warning("An interrupt ID was too large!") + end + end) + end + return interrupt + end end - -- Given a message object passed to digiline_send, clean it up into a form -- which is safe to transmit over the network and compute its "cost" (a very -- rough estimate of its memory usage). @@ -414,7 +427,6 @@ local function get_digiline_send(pos, itbl, send_warning) end end - local safe_globals = { -- Don't add pcall/xpcall unless willing to deal with the consequences (unless very careful, incredibly likely to allow killing server indirectly) "assert", "error", "ipairs", "next", "pairs", "select", @@ -651,6 +663,14 @@ local function reset(pos) set_port_states(pos, {a=false, b=false, c=false, d=false}) end +local function node_timer(pos) + if minetest.registered_nodes[minetest.get_node(pos).name].is_burnt then + return false + end + run(pos, {type="interrupt"}) + return false +end + ----------------------- -- A.Queue callbacks -- ----------------------- @@ -823,6 +843,7 @@ for d = 0, 1 do mesecon.receptor_off(pos, output_rules) end, is_luacontroller = true, + on_timer = node_timer, on_blast = mesecon.on_blastnode, }) end diff --git a/settingtypes.txt b/settingtypes.txt index 8be7be6..9259a83 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -24,6 +24,10 @@ mesecon.luacontroller_digiline_maxlen (Digiline message size limit) int 50000 10 mesecon.luacontroller_maxevents (Controller execution time limit) int 10000 1000 100000 mesecon.luacontroller_memsize (Controller memory limit) int 100000 10000 1000000 +# Use node timer for interrupts (runs in active blocks only). +# IID is ignored and at most one interrupt may be queued if this setting is enabled. +mesecon.luacontroller_lightweight_interrupts (Lightweight interrupts) bool false + [mesecons_movestones]