From 29bac67d3a262e862d8f15a0c3ea70987cf19031 Mon Sep 17 00:00:00 2001 From: hlqkj Date: Thu, 6 May 2021 18:02:19 +0200 Subject: [PATCH 1/2] Skip protection check on formspec close Prevents protector flip/player being hurt/protection violation if the player closes the formspec without attempting any changes (sorting tube and autocrafter). --- autocrafter.lua | 5 ++++- sorting_tubes.lua | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/autocrafter.lua b/autocrafter.lua index 1d99bfe..507328c 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -276,7 +276,10 @@ minetest.register_node("pipeworks:autocrafter", { update_meta(meta, false) end, on_receive_fields = function(pos, formname, fields, sender) - if not pipeworks.may_configure(pos, sender) then return end + if (fields.quit and not fields.key_enter_field) + or not pipeworks.may_configure(pos, sender) then + return + end local meta = minetest.get_meta(pos) if fields.on then update_meta(meta, false) diff --git a/sorting_tubes.lua b/sorting_tubes.lua index 89d72a0..10a81a6 100644 --- a/sorting_tubes.lua +++ b/sorting_tubes.lua @@ -110,9 +110,22 @@ if pipeworks.enable_mese_tube then update_formspec(pos) meta:set_string("infotext", S("Sorting pneumatic tube")) end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + if placer and placer:is_player() and placer:get_player_control().aux1 then + local meta = minetest.get_meta(pos) + for i = 1, 6 do + meta:set_int("l"..tostring(i).."s", 0) + end + update_formspec(pos) + end + return pipeworks.after_place(pos, placer, itemstack, pointed_thing) + end, on_punch = update_formspec, on_receive_fields = function(pos, formname, fields, sender) - if not pipeworks.may_configure(pos, sender) then return end + if (fields.quit and not fields.key_enter_field) + or not pipeworks.may_configure(pos, sender) then + return + end fs_helpers.on_receive_fields(pos, fields) update_formspec(pos) end, From b53a1ee4778674e170a34f66f4a3ba82834b3e44 Mon Sep 17 00:00:00 2001 From: hlqkj Date: Thu, 6 May 2021 18:28:47 +0200 Subject: [PATCH 2/2] Make LUA editor and error label use mono font --- lua_tube.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua_tube.lua b/lua_tube.lua index 8800133..c5fd24c 100644 --- a/lua_tube.lua +++ b/lua_tube.lua @@ -666,6 +666,7 @@ local function reset_formspec(meta, code, errmsg) code = minetest.formspec_escape(code or "") errmsg = minetest.formspec_escape(tostring(errmsg or "")) meta:set_string("formspec", "size[12,10]" + .."style_type[label,textarea;font=mono]" .."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.."]"