mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-28 19:50:35 +01:00
parent
002dc462d6
commit
5914eab20b
@ -20,6 +20,21 @@ end
|
|||||||
|
|
||||||
worldedit.registered_commands = {}
|
worldedit.registered_commands = {}
|
||||||
|
|
||||||
|
local function copy_state(which, name)
|
||||||
|
if which == 0 then
|
||||||
|
return {}
|
||||||
|
elseif which == 1 then
|
||||||
|
return {
|
||||||
|
worldedit.pos1[name] and vector.copy(worldedit.pos1[name])
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return {
|
||||||
|
worldedit.pos1[name] and vector.copy(worldedit.pos1[name]),
|
||||||
|
worldedit.pos2[name] and vector.copy(worldedit.pos2[name])
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local function chatcommand_handler(cmd_name, name, param)
|
local function chatcommand_handler(cmd_name, name, param)
|
||||||
local def = assert(worldedit.registered_commands[cmd_name])
|
local def = assert(worldedit.registered_commands[cmd_name])
|
||||||
|
|
||||||
@ -44,21 +59,34 @@ local function chatcommand_handler(cmd_name, name, param)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if def.nodes_needed then
|
local run = function()
|
||||||
|
local _, msg = def.func(name, unpack(parsed))
|
||||||
|
if msg then
|
||||||
|
minetest.chat_send_player(name, msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if not def.nodes_needed then
|
||||||
|
-- no safe region check
|
||||||
|
run()
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local count = def.nodes_needed(name, unpack(parsed))
|
local count = def.nodes_needed(name, unpack(parsed))
|
||||||
|
local old_state = copy_state(def.require_pos, name)
|
||||||
safe_region(name, count, function()
|
safe_region(name, count, function()
|
||||||
local _, msg = def.func(name, unpack(parsed))
|
local state = copy_state(def.require_pos, name)
|
||||||
if msg then
|
local ok = true
|
||||||
minetest.chat_send_player(name, msg)
|
for i, v in ipairs(state) do
|
||||||
|
ok = ok and ( (v == nil and old_state[i] == nil) or vector.equals(v, old_state[i]) )
|
||||||
end
|
end
|
||||||
|
if not ok then
|
||||||
|
worldedit.player_notify(name, S("ERROR: the operation was cancelled because the region has changed."))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
run()
|
||||||
end)
|
end)
|
||||||
else
|
|
||||||
-- no "safe region" check
|
|
||||||
local _, msg = def.func(name, unpack(parsed))
|
|
||||||
if msg then
|
|
||||||
minetest.chat_send_player(name, msg)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Registers a chatcommand for WorldEdit
|
-- Registers a chatcommand for WorldEdit
|
||||||
@ -66,7 +94,7 @@ end
|
|||||||
-- def = {
|
-- def = {
|
||||||
-- privs = {}, -- Privileges needed
|
-- privs = {}, -- Privileges needed
|
||||||
-- params = "", -- Human readable parameter list (optional)
|
-- params = "", -- Human readable parameter list (optional)
|
||||||
-- -- setting params = "" will automatically provide a parse() if not given
|
-- -- if params = "" then a parse() implementation will automatically be provided
|
||||||
-- description = "", -- Description
|
-- description = "", -- Description
|
||||||
-- require_pos = 0, -- Number of positions required to be set (optional)
|
-- require_pos = 0, -- Number of positions required to be set (optional)
|
||||||
-- parse = function(param)
|
-- parse = function(param)
|
||||||
|
@ -19,6 +19,7 @@ Can use WorldEdit commands=
|
|||||||
no region selected=
|
no region selected=
|
||||||
no position 1 selected=
|
no position 1 selected=
|
||||||
invalid usage=
|
invalid usage=
|
||||||
|
ERROR: the operation was cancelled because the region has changed.=
|
||||||
Could not open file "@1"=
|
Could not open file "@1"=
|
||||||
Invalid file format!=
|
Invalid file format!=
|
||||||
Schematic was created with a newer version of WorldEdit.=
|
Schematic was created with a newer version of WorldEdit.=
|
||||||
|
@ -30,6 +30,7 @@ Can use WorldEdit commands=Kann WorldEdit-Befehle benutzen
|
|||||||
no region selected=Kein Gebiet ausgewählt
|
no region selected=Kein Gebiet ausgewählt
|
||||||
no position 1 selected=Keine Position 1 ausgewählt
|
no position 1 selected=Keine Position 1 ausgewählt
|
||||||
invalid usage=Ungültige Verwendung
|
invalid usage=Ungültige Verwendung
|
||||||
|
ERROR: the operation was cancelled because the region has changed.=FEHLER: Der Vorgang wurde abgebrochen, weil das Gebiet verändert wurde.
|
||||||
Could not open file "@1"=Konnte die Datei „@1“ nicht öffnen
|
Could not open file "@1"=Konnte die Datei „@1“ nicht öffnen
|
||||||
Invalid file format!=Ungültiges Dateiformat!
|
Invalid file format!=Ungültiges Dateiformat!
|
||||||
Schematic was created with a newer version of WorldEdit.=Schematic wurde mit einer neueren Version von WorldEdit erstellt.
|
Schematic was created with a newer version of WorldEdit.=Schematic wurde mit einer neueren Version von WorldEdit erstellt.
|
||||||
|
Loading…
Reference in New Issue
Block a user