Add buttons to convert air to void to air

This commit is contained in:
Wuzzy 2020-06-03 15:40:28 +02:00
parent e389fcc041
commit 01a3a970d2
3 changed files with 29 additions and 2 deletions

View File

@ -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("<name>"))..".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

View File

@ -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)
<schematic name>[.mts] [comments]=<Schematic-Name>[.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

View File

@ -72,3 +72,7 @@ Insufficient privileges! You need the “@1” privilege to use this.=
Convert .mts schematic file to .lua file (loaded from @1)=
<schematic name>[.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=