From 01a3a970d2b555e414102d3726ec595f73150157 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 3 Jun 2020 15:40:28 +0200 Subject: [PATCH] Add buttons to convert air to void to air --- init.lua | 22 ++++++++++++++++++++-- locale/schemedit.de.tr | 5 +++++ locale/template.txt | 4 ++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/init.lua b/init.lua index 021d249..162f12c 100644 --- a/init.lua +++ b/init.lua @@ -300,15 +300,18 @@ schemedit.add_form("main", { button[0.5,3.5;6,1;export;]]..F(S("Export schematic")).."]".. import_btn..[[ - textarea[0.8,4.5;6.2,2;;]]..F(S("Export/import path:\n@1", + textarea[0.8,4.5;6.2,1;;]]..F(S("Export/import path:\n@1", export_path_trunc .. DIR_DELIM .. F(S(""))..".mts"))..[[;] + button[0.5,5.5;3,1;air2void;]]..F(S("Air to voids"))..[[] + button[3.5,5.5;3,1;void2air;]]..F(S("Voids to air"))..[[] + tooltip[air2void;]]..F(S("Turn all air nodes into schematic void nodes"))..[[] + tooltip[void2air;]]..F(S("Turn all schematic void nodes into air nodes"))..[[] field[0.8,7;2,1;x;]]..F(S("X size:"))..[[;]]..xs..[[] field[2.8,7;2,1;y;]]..F(S("Y size:"))..[[;]]..ys..[[] field[4.8,7;2,1;z;]]..F(S("Z size:"))..[[;]]..zs..[[] field_close_on_enter[x;false] field_close_on_enter[y;false] field_close_on_enter[z;false] - button[0.5,7.5;3,1;save;]]..F(S("Save size"))..[[] ]].. border_button @@ -357,6 +360,21 @@ schemedit.add_form("main", { meta.schem_name = fields.name end + -- Node conversion + if (fields.air2void) then + local pos1, pos2 = schemedit.size(pos) + pos1, pos2 = schemedit.sort_pos(pos1, pos2) + local nodes = minetest.find_nodes_in_area(pos1, pos2, {"air"}) + minetest.bulk_set_node(nodes, {name="schemedit:void"}) + return + elseif (fields.void2air) then + local pos1, pos2 = schemedit.size(pos) + pos1, pos2 = schemedit.sort_pos(pos1, pos2) + local nodes = minetest.find_nodes_in_area(pos1, pos2, {"schemedit:void"}) + minetest.bulk_set_node(nodes, {name="air"}) + return + end + -- Toggle border if fields.border then if meta.schem_border == "true" and schemedit.markers[hashpos] then diff --git a/locale/schemedit.de.tr b/locale/schemedit.de.tr index 32003c1..5bffe90 100644 --- a/locale/schemedit.de.tr +++ b/locale/schemedit.de.tr @@ -74,3 +74,8 @@ Insufficient privileges! You need the “@1” privilege to use this.=Unzureiche Convert .mts schematic file to .lua file (loaded from @1)=„.mts“-Schematicdatei zu „.lua“-Datei konvertieren (geladen von @1) [.mts] [comments]=[.mts] [comments] Failed.=Fehlgeschlagen. +Air to voids=Luft zu Lücken +Voids to air=Lücken zu Luft +Turn all air nodes into schematic void nodes=Alle Luft-Nodes zu Schematic-Lücken umwandeln +Turn all schematic void nodes into air nodes=Alle Schematic-Lücken zu Luft-Nodes umwandeln + diff --git a/locale/template.txt b/locale/template.txt index 0a07d1a..decd90a 100644 --- a/locale/template.txt +++ b/locale/template.txt @@ -72,3 +72,7 @@ Insufficient privileges! You need the “@1” privilege to use this.= Convert .mts schematic file to .lua file (loaded from @1)= [.mts] [comments]= Failed.= +Air to voids= +Voids to air= +Turn all air nodes into schematic void nodes= +Turn all schematic void nodes into air nodes=