Add -c switch to /placeschem to clean area first

This commit is contained in:
Wuzzy 2021-04-04 22:22:54 +02:00
parent a56b2d431f
commit 98b3ae87ea
3 changed files with 25 additions and 8 deletions

View File

@ -1299,11 +1299,16 @@ end
-- [chatcommand] Place schematic
minetest.register_chatcommand("placeschem", {
description = S("Place schematic at the position specified or the current player position (loaded from @1)", export_path_trunc),
description = S("Place schematic at the position specified or the current player position (loaded from @1). “-c” will clear the area first", export_path_trunc),
privs = {server = true},
params = S("<schematic name>[.mts] [<x> <y> <z>]"),
params = S("<schematic name>[.mts] [-c] [<x> <y> <z>]"),
func = function(name, param)
local schem, p = string.match(param, "^([^ ]+) *(.*)$")
local schem, clear, p = string.match(param, "^([^ ]+) (%-c) *(.*)$")
if not schem then
schem, p = string.match(param, "^([^ ]+) *(.*)$")
end
clear = clear == "-c"
local pos = minetest.string_to_pos(p)
if not schem then
@ -1323,10 +1328,22 @@ minetest.register_chatcommand("placeschem", {
-- files when we reload. minetest.read_schematic circumvents that.
local schematic = minetest.read_schematic(schem_path, {})
if schematic then
if clear then
local posses = {}
for z=pos.z, pos.z+schematic.size.z-1 do
for y=pos.y, pos.y+schematic.size.y-1 do
for x=pos.x, pos.x+schematic.size.x-1 do
table.insert(posses, {x=x,y=y,z=z})
end
end
end
minetest.bulk_set_node(posses, {name="air"})
end
success = minetest.place_schematic(pos, schematic, "random", nil, false)
end
else
-- Legacy support for Minetest versions that do not have minetest.read_schematic
-- Legacy support for Minetest versions that do not have minetest.read_schematic.
-- Note: "-c" is ignored here.
success = minetest.place_schematic(schem_path, schematic, "random", nil, false)
end

View File

@ -71,8 +71,8 @@ The node HUD is not updated automatically and may be outdated. The node HUD only
Schematic Void=Schematic-Lücke
This is an utility block used in the creation of schematic files. It should be used together with a schematic creator. When saving a schematic, all nodes with a schematic void will be left unchanged when the schematic is placed again. Technically, this is equivalent to a block with the node probability set to 0.=Dies ist ein Hilfsblock, der bei der Erstellung von Schematic-Dateien benutzt wird. Er sollte zusammen mit einem Schematic-Macher benutzt werden. Wenn ein Schematic gespeichert wird, werden alle Nodes mit einer Schematic-Lücke unverändert gelassen, wenn das Schematic erneut platziert wird. Technisch gesehen ist dieses Verhalten identisch mit einem Block, der eine Node-Wahrscheinlichkeit von 0 hat.
Just place the schematic void like any other block and use the schematic creator to save a portion of the world.=Platzieren Sie einfach die Schematic-Lücke wie jeden anderen Block und benutzen Sie den Schematic-Macher, um einen Teil der Welt zu speichern.
Place schematic at the position specified or the current player position (loaded from @1)=Schematic an der angegebenen Position oder der aktuellen Spielerposition platzieren (geladen von @1)
<schematic name>[.mts] [<x> <y> <z>]=<Schematic-Name>[.mts] [<x> <y> <z>]
Place schematic at the position specified or the current player position (loaded from @1). “-c” will clear the area first=Schematic an der angegebenen Position oder der aktuellen Spielerposition platzieren (geladen von @1). Mit „-c“ wird das Gebiet zuerst geleert
<schematic name>[.mts] [-c] [<x> <y> <z>]=<Schematic-Name>[.mts] [-c] [<x> <y> <z>]
No schematic file specified.=Keinen Schematic-Namen angegeben.
Schematic file could not be loaded!=Schematic-Datei konnte nicht geladen werden!
Convert .mts schematic file to .lua file (loaded from @1)=„.mts“-Schematicdatei zu „.lua“-Datei konvertieren (geladen von @1)

View File

@ -71,8 +71,8 @@ The node HUD is not updated automatically and may be outdated. The node HUD only
Schematic Void=
This is an utility block used in the creation of schematic files. It should be used together with a schematic creator. When saving a schematic, all nodes with a schematic void will be left unchanged when the schematic is placed again. Technically, this is equivalent to a block with the node probability set to 0.=
Just place the schematic void like any other block and use the schematic creator to save a portion of the world.=
Place schematic at the position specified or the current player position (loaded from @1)=
<schematic name>[.mts] [<x> <y> <z>]=
Place schematic at the position specified or the current player position (loaded from @1). “-c” will clear the area first=
<schematic name>[.mts] [-c] [<x> <y> <z>]=
No schematic file specified.=
Schematic file could not be loaded!=
Convert .mts schematic file to .lua file (loaded from @1)=