Compare commits
6 Commits
469c3bf70b
...
41d53180b1
Author | SHA1 | Date |
---|---|---|
sfan5 | 41d53180b1 | |
sfan5 | 602f175cc0 | |
sfan5 | e6fac23c53 | |
sfan5 | 5914eab20b | |
sfan5 | 002dc462d6 | |
sfan5 | a713efe051 |
|
@ -47,10 +47,15 @@ end
|
|||
|
||||
function worldedit.keep_loaded(pos1, pos2)
|
||||
-- Create a vmanip and read the area from map, this
|
||||
-- causes all MapBlocks to be loaded into memory.
|
||||
-- causes all MapBlocks to be loaded into memory synchronously.
|
||||
-- This doesn't actually *keep* them loaded, unlike the name implies.
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
if minetest.load_area then
|
||||
-- same effect but without unnecessary data copying
|
||||
minetest.load_area(pos1, pos2)
|
||||
else
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ worldedit.cuboid_shift = function(name, axis, amount)
|
|||
return false, "undefined cuboid"
|
||||
end
|
||||
|
||||
assert(not rawequal(pos1, pos2)) -- vectors must not alias
|
||||
|
||||
if axis == 'x' then
|
||||
worldedit.pos1[name].x = pos1.x + amount
|
||||
worldedit.pos2[name].x = pos2.x + amount
|
||||
|
|
|
@ -101,7 +101,7 @@ worldedit.register_command("brush", {
|
|||
else
|
||||
local cmddef = worldedit.registered_commands[cmd]
|
||||
if cmddef == nil or cmddef.require_pos ~= 1 then
|
||||
worldedit.player_notify(name, "//" .. cmd .. " cannot be used with brushes")
|
||||
worldedit.player_notify(name, minetest.colorize("#00ffff", "//"..cmd) .. " cannot be used with brushes")
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -232,7 +232,8 @@ worldedit.register_command("cubeapply", {
|
|||
end
|
||||
local cmddef = worldedit.registered_commands[cmd]
|
||||
if cmddef == nil or cmddef.require_pos ~= 2 then
|
||||
return false, S("invalid usage: //@1 cannot be used with cubeapply", cmd)
|
||||
return false, S("invalid usage: @1 cannot be used with cubeapply",
|
||||
minetest.colorize("#00ffff", "//"..cmd))
|
||||
end
|
||||
-- run parsing of target command
|
||||
local parsed = {cmddef.parse(args)}
|
||||
|
|
|
@ -20,6 +20,21 @@ end
|
|||
|
||||
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 def = assert(worldedit.registered_commands[cmd_name])
|
||||
|
||||
|
@ -44,21 +59,34 @@ local function chatcommand_handler(cmd_name, name, param)
|
|||
return
|
||||
end
|
||||
|
||||
if def.nodes_needed then
|
||||
local count = def.nodes_needed(name, unpack(parsed))
|
||||
safe_region(name, count, function()
|
||||
local _, msg = def.func(name, unpack(parsed))
|
||||
if msg then
|
||||
minetest.chat_send_player(name, msg)
|
||||
end
|
||||
end)
|
||||
else
|
||||
-- no "safe region" check
|
||||
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 old_state = copy_state(def.require_pos, name)
|
||||
safe_region(name, count, function()
|
||||
local state = copy_state(def.require_pos, name)
|
||||
local ok = true
|
||||
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
|
||||
if not ok then
|
||||
worldedit.player_notify(name, S("ERROR: the operation was cancelled because the region has changed."))
|
||||
return
|
||||
end
|
||||
|
||||
run()
|
||||
end)
|
||||
end
|
||||
|
||||
-- Registers a chatcommand for WorldEdit
|
||||
|
@ -66,7 +94,7 @@ end
|
|||
-- def = {
|
||||
-- privs = {}, -- Privileges needed
|
||||
-- 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
|
||||
-- require_pos = 0, -- Number of positions required to be set (optional)
|
||||
-- parse = function(param)
|
||||
|
@ -268,9 +296,9 @@ worldedit.register_command("about", {
|
|||
description = S("Get information about the WorldEdit mod"),
|
||||
func = function(name)
|
||||
worldedit.player_notify(name, S("WorldEdit @1"..
|
||||
" is available on this server. Type //help to get a list of "..
|
||||
"commands, or get more information at @2",
|
||||
worldedit.version_string,
|
||||
" is available on this server. Type @2 to get a list of "..
|
||||
"commands, or find more information at @3",
|
||||
worldedit.version_string, minetest.colorize("#00ffff", "//help"),
|
||||
"https://github.com/Uberi/Minetest-WorldEdit"
|
||||
))
|
||||
end,
|
||||
|
@ -307,9 +335,11 @@ worldedit.register_command("help", {
|
|||
end
|
||||
end
|
||||
table.sort(cmds)
|
||||
local help = minetest.colorize("#00ffff", "//help")
|
||||
return true, S("Available commands: @1@n"
|
||||
.. "Use '//help <cmd>' to get more information,"
|
||||
.. " or '//help all' to list everything.", table.concat(cmds, " "))
|
||||
.. "Use '@2' to get more information,"
|
||||
.. " or '@3' to list everything.",
|
||||
table.concat(cmds, " "), help .. " <cmd>", help .. " all")
|
||||
elseif param == "all" then
|
||||
local cmds = {}
|
||||
for cmd, def in pairs(worldedit.registered_commands) do
|
||||
|
|
|
@ -13,20 +13,21 @@ Region expanded by @1 nodes=
|
|||
Contracts the selection in the selected absolute or relative axis=
|
||||
Region contracted by @1 nodes=
|
||||
Select a cube with side length <size> around position 1 and run <command> on region=
|
||||
invalid usage: //@1 cannot be used with cubeapply=
|
||||
invalid usage: @1 cannot be used with cubeapply=
|
||||
Missing privileges: @1=
|
||||
Can use WorldEdit commands=
|
||||
no region selected=
|
||||
no position 1 selected=
|
||||
invalid usage=
|
||||
ERROR: the operation was cancelled because the region has changed.=
|
||||
Could not open file "@1"=
|
||||
Invalid file format!=
|
||||
Schematic was created with a newer version of WorldEdit.=
|
||||
Get information about the WorldEdit mod=
|
||||
WorldEdit @1 is available on this server. Type //help to get a list of commands, or get more information at @2=
|
||||
WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3=
|
||||
Get help for WorldEdit commands=
|
||||
You are not allowed to use any WorldEdit commands.=
|
||||
Available commands: @1@nUse '//help <cmd>' to get more information, or '//help all' to list everything.=
|
||||
Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=
|
||||
Available commands:@n=
|
||||
Command not available: =
|
||||
Enable or disable node inspection=
|
||||
|
@ -138,7 +139,7 @@ currently set node probabilities:=
|
|||
invalid node probability given, not saved=
|
||||
Clears all objects within the WorldEdit region=
|
||||
@1 objects cleared=
|
||||
WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel=
|
||||
WARNING: this operation could affect up to @1 nodes; type @2 to continue or @3 to cancel=
|
||||
Confirm a pending operation=
|
||||
no operation pending=
|
||||
Abort a pending operation=
|
||||
|
|
|
@ -24,20 +24,21 @@ Region expanded by @1 nodes=Gebiet um @1 Blöcke erweitert
|
|||
Contracts the selection in the selected absolute or relative axis=Schrumpft das Gebiet in Richtung einer absoluten oder relativen Achse
|
||||
Region contracted by @1 nodes=Gebiet um @1 Blöcke geschrumpft
|
||||
Select a cube with side length <size> around position 1 and run <command> on region=Wähle einen Würfel mit Seitenlänge <size> um Position 1 und führe <command> auf diesem Gebiet aus
|
||||
invalid usage: //@1 cannot be used with cubeapply=Ungültige Verwendung: //@1 kann nicht mit cubeapply verwendet werden
|
||||
invalid usage: @1 cannot be used with cubeapply=Ungültige Verwendung: @1 kann nicht mit cubeapply verwendet werden
|
||||
Missing privileges: @1=Fehlende Privilegien: @1
|
||||
Can use WorldEdit commands=Kann WorldEdit-Befehle benutzen
|
||||
no region selected=Kein Gebiet ausgewählt
|
||||
no position 1 selected=Keine Position 1 ausgewählt
|
||||
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
|
||||
Invalid file format!=Ungültiges Dateiformat!
|
||||
Schematic was created with a newer version of WorldEdit.=Schematic wurde mit einer neueren Version von WorldEdit erstellt.
|
||||
Get information about the WorldEdit mod=Informationen über den WorldEdit-Mod erhalten.
|
||||
WorldEdit @1 is available on this server. Type //help to get a list of commands, or get more information at @2=WorldEdit @1 ist auf diesem Server verfügbar. Nutzen Sie //help, um eine Liste der Befehle zu erhalten, oder finden Sie weitere Informationen unter @2
|
||||
WorldEdit @1 is available on this server. Type @2 to get a list of commands, or find more information at @3=WorldEdit @1 ist auf diesem Server verfügbar. Nutzen Sie @2, um eine Liste der Befehle zu erhalten, oder finden Sie weitere Informationen unter @3
|
||||
Get help for WorldEdit commands=Hilfe für WorldEdit-Befehle erhalten
|
||||
You are not allowed to use any WorldEdit commands.=Ihnen ist nicht erlaubt WorldEdit-Befehle zu nutzen.
|
||||
Available commands: @1@nUse '//help <cmd>' to get more information, or '//help all' to list everything.=Verfügbare Befehle: @1@n„//help <Befehl>“ benutzen, um mehr Informationen zu erhalten, oder „//help all“, um alles aufzulisten.
|
||||
Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=Verfügbare Befehle: @1@n„@2“ benutzen, um mehr Informationen zu erhalten, oder „@3“, um alles aufzulisten.
|
||||
Available commands:@n=Verfügbare Befehle:@n
|
||||
Command not available: =Befehl nicht verfügbar:
|
||||
Enable or disable node inspection=Inspizieren von Blöcken ein- oder ausschalten
|
||||
|
@ -149,7 +150,7 @@ currently set node probabilities:=
|
|||
invalid node probability given, not saved=
|
||||
Clears all objects within the WorldEdit region=Löscht alle Objekte innerhalb des WorldEdit-Gebiets
|
||||
@1 objects cleared=@1 Objekte gelöscht
|
||||
WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel=WARNUNG: Dieser Vorgang könnte bis zu @1 Blöcke betreffen; //y zum Fortfahren oder //n zum Abbrechen
|
||||
WARNING: this operation could affect up to @1 nodes; type @2 to continue or @3 to cancel=WARNUNG: Dieser Vorgang könnte bis zu @1 Blöcke betreffen; @2 zum Fortfahren oder @3 zum Abbrechen
|
||||
Confirm a pending operation=Einen ausstehenden Vorgang bestätigen
|
||||
no operation pending=Kein Vorgang ausstehend
|
||||
Abort a pending operation=Einen ausstehenden Vorgang abbrechen
|
||||
|
|
|
@ -11,10 +11,10 @@ Invalid file format!=Не верный формат файла!
|
|||
Schematic was created with a newer version of WorldEdit.=Схема была создана с использованием более новой версии WorldEdit.
|
||||
|
||||
Get information about the WorldEdit mod=Вывести информацию о WorldEdit
|
||||
WorldEdit @1 is available on this server. Type //help to get a list of commands, or get more information at @2=WorldEdit @1 доступен на этом сервере. Наберите команду //help чтобы увидеть список команд, больше информации по ссылке @2
|
||||
WorldEdit @1 is available on this server. Type @2 to get a list of commands, or get more information at @3=WorldEdit @1 доступен на этом сервере. Наберите команду @2 чтобы увидеть список команд, больше информации по ссылке @3
|
||||
Get help for WorldEdit commands=Вывести информацию об использовании команд WorldEdit
|
||||
You are not allowed to use any WorldEdit commands.=У вас нет привилегий, чтобы использовать команды WorldEdit.
|
||||
Available commands: @1@nUse '//help <cmd>' to get more information, or '//help all' to list everything.=Доступные команды: @1@nИспользуйте '//help <cmd>' для получения информации по команде или '//help all' для вывода подсказок по всем командам.
|
||||
Available commands: @1@nUse '@2' to get more information, or '@3' to list everything.=Доступные команды: @1@nИспользуйте '@2' для получения информации по команде или '@3' для вывода подсказок по всем командам.
|
||||
Available commands:@n=Доступные команды:@n
|
||||
Command not available: =Команда не найдена:
|
||||
Enable or disable node inspection=Включить/отключить инспекцию блоков
|
||||
|
@ -128,7 +128,7 @@ Clears all objects within the WorldEdit region=Очистить все объе
|
|||
@1 objects cleared=очищено @1 объектов
|
||||
|
||||
### safe.lua ###
|
||||
WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel=ПРЕДУПРЕЖДЕНИЕ: эта операция может затронуть до @1 нод; введите //y для продолжения или //n для отмены
|
||||
WARNING: this operation could affect up to @1 nodes; type @2 to continue or @3 to cancel=ПРЕДУПРЕЖДЕНИЕ: эта операция может затронуть до @1 нод; введите @2 для продолжения или @3 для отмены
|
||||
Confirm a pending operation=Подтвердить отложенную операцию
|
||||
no operation pending=нет ожидающей операции
|
||||
Abort a pending operation=Отклонить отложенную операцию
|
||||
|
@ -148,7 +148,7 @@ Region expanded by @1 nodes=Регион увеличен на @1 нод(у/ы)
|
|||
Contracts the selection in the selected absolute or relative axis=Уменьшить выделение региона по выбранной абсолютной или относительной оси
|
||||
Region contracted by @1 nodes=Регион уменьшен на @1 нод(у/ы)
|
||||
Select a cube with side length <size> around position 1 and run <command> on region=Выделить куб с длиной стороны <size> вокруг позиции 1 и запустите <команду> в области
|
||||
invalid usage: //@1 cannot be used with cubeapply=недопустимое использование: //@1 не может быть применено в cubeapply
|
||||
invalid usage: @1 cannot be used with cubeapply=недопустимое использование: @1 не может быть применено в cubeapply
|
||||
Missing privileges: @1=Отсутствуют привилегии: @1
|
||||
|
||||
### wand.lua ###
|
||||
|
|
|
@ -13,9 +13,7 @@ worldedit.mark_pos1 = function(name, region_too)
|
|||
worldedit.marker1[name] = nil
|
||||
end
|
||||
if pos1 ~= nil then
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos1)
|
||||
worldedit.keep_loaded(pos1, pos1)
|
||||
|
||||
--add marker
|
||||
worldedit.marker1[name] = minetest.add_entity(pos1, "worldedit:pos1", init_sentinel)
|
||||
|
@ -37,9 +35,7 @@ worldedit.mark_pos2 = function(name, region_too)
|
|||
worldedit.marker2[name] = nil
|
||||
end
|
||||
if pos2 ~= nil then
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos2, pos2)
|
||||
worldedit.keep_loaded(pos2, pos2)
|
||||
|
||||
--add marker
|
||||
worldedit.marker2[name] = minetest.add_entity(pos2, "worldedit:pos2", init_sentinel)
|
||||
|
@ -77,9 +73,8 @@ worldedit.mark_region = function(name)
|
|||
local thickness = 0.2
|
||||
local sizex, sizey, sizez = (1 + pos2.x - pos1.x) / 2, (1 + pos2.y - pos1.y) / 2, (1 + pos2.z - pos1.z) / 2
|
||||
|
||||
--make area stay loaded
|
||||
local manip = minetest.get_voxel_manip()
|
||||
manip:read_from_map(pos1, pos2)
|
||||
-- TODO maybe we could skip this actually?
|
||||
worldedit.keep_loaded(pos1, pos2)
|
||||
|
||||
local markers = {}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ local function safe_region(name, count, callback)
|
|||
|
||||
--save callback to call later
|
||||
safe_region_callback[name] = callback
|
||||
worldedit.player_notify(name, S("WARNING: this operation could affect up to @1 nodes; type //y to continue or //n to cancel", count))
|
||||
worldedit.player_notify(name, S("WARNING: this operation could affect up to @1 nodes; type @2 to continue or @3 to cancel",
|
||||
count, minetest.colorize("#00ffff", "//y"), minetest.colorize("#00ffff", "//n")))
|
||||
end
|
||||
|
||||
local function reset_pending(name)
|
||||
|
|
|
@ -16,6 +16,13 @@ minetest.register_tool(":worldedit:wand", {
|
|||
stack_max = 1, -- there is no need to have more than one
|
||||
liquids_pointable = true, -- ground with only water on can be selected as well
|
||||
|
||||
-- ignore marker cube so the clicking on the position markers works reliably
|
||||
pointabilities = {
|
||||
objects = {
|
||||
["worldedit:region_cube"] = false
|
||||
}
|
||||
},
|
||||
|
||||
on_use = function(itemstack, placer, pointed_thing)
|
||||
if placer == nil or pointed_thing == nil then return end
|
||||
local name = placer:get_player_name()
|
||||
|
@ -34,7 +41,7 @@ minetest.register_tool(":worldedit:wand", {
|
|||
local entity = pointed_thing.ref:get_luaentity()
|
||||
if entity and entity.name == "worldedit:pos2" then
|
||||
-- set pos1 = pos2
|
||||
worldedit.pos1[name] = worldedit.pos2[name]
|
||||
worldedit.pos1[name] = vector.copy(worldedit.pos2[name])
|
||||
worldedit.mark_pos1(name)
|
||||
end
|
||||
end
|
||||
|
@ -59,7 +66,7 @@ minetest.register_tool(":worldedit:wand", {
|
|||
local entity = pointed_thing.ref:get_luaentity()
|
||||
if entity and entity.name == "worldedit:pos1" then
|
||||
-- set pos2 = pos1
|
||||
worldedit.pos2[name] = worldedit.pos1[name]
|
||||
worldedit.pos2[name] = vector.copy(worldedit.pos1[name])
|
||||
worldedit.mark_pos2(name)
|
||||
end
|
||||
return itemstack -- nothing consumed, nothing changed
|
||||
|
|
Loading…
Reference in New Issue