mirror of
https://github.com/sys4-fr/server-nalc.git
synced 2024-11-05 01:50:25 +01:00
Updated worldedit
This commit is contained in:
parent
962fb7b64a
commit
09ca7fb48a
|
@ -41,3 +41,4 @@ load_module(path .. "/compatibility.lua")
|
|||
if minetest.setting_getbool("log_mods") then
|
||||
print("[WorldEdit] Loaded!")
|
||||
end
|
||||
|
||||
|
|
|
@ -594,3 +594,4 @@ function worldedit.clear_objects(pos1, pos2)
|
|||
end
|
||||
return count
|
||||
end
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ function worldedit.player_axis(name)
|
|||
return "z", dir.z > 0 and 1 or -1
|
||||
end
|
||||
|
||||
function worldedit.mkdir(path)
|
||||
local function mkdir(path)
|
||||
if minetest.mkdir then
|
||||
minetest.mkdir(path)
|
||||
else
|
||||
|
@ -78,6 +78,10 @@ function worldedit.mkdir(path)
|
|||
end
|
||||
end
|
||||
|
||||
local function check_filename(name)
|
||||
return name:find("^[%w%s%^&'@{}%[%],%$=!%-#%(%)%%%.%+~_]+$") ~= nil
|
||||
end
|
||||
|
||||
|
||||
minetest.register_chatcommand("/about", {
|
||||
params = "",
|
||||
|
@ -885,17 +889,16 @@ minetest.register_chatcommand("/save", {
|
|||
worldedit.player_notify(name, "invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
if not param:find("^[a-zA-Z0-9_%-.]+$") then
|
||||
if not check_filename(param) then
|
||||
worldedit.player_notify(name, "Disallowed file name: " .. param)
|
||||
return
|
||||
end
|
||||
|
||||
local result, count = worldedit.serialize(worldedit.pos1[name],
|
||||
worldedit.pos2[name])
|
||||
|
||||
local path = minetest.get_worldpath() .. "/schems"
|
||||
-- Create directory if it does not already exist
|
||||
worldedit.mkdir(path)
|
||||
mkdir(path)
|
||||
|
||||
local filename = path .. "/" .. param .. ".we"
|
||||
local file, err = io.open(filename, "wb")
|
||||
|
@ -923,8 +926,8 @@ minetest.register_chatcommand("/allocate", {
|
|||
worldedit.player_notify(name, "invalid usage: " .. param)
|
||||
return
|
||||
end
|
||||
if not string.find(param, "^[%w \t.,+-_=!@#$%%^&*()%[%]{};'\"]+$") then
|
||||
worldedit.player_notify(name, "invalid file name: " .. param)
|
||||
if not check_filename(param) then
|
||||
worldedit.player_notify(name, "Disallowed file name: " .. param)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -1056,14 +1059,14 @@ minetest.register_chatcommand("/mtschemcreate", {
|
|||
worldedit.player_notify(name, "No filename specified")
|
||||
return
|
||||
end
|
||||
if not param:find("^[a-zA-Z0-9_%-.]+$") then
|
||||
if not check_filename(param) then
|
||||
worldedit.player_notify(name, "Disallowed file name: " .. param)
|
||||
return
|
||||
end
|
||||
|
||||
local path = minetest.get_worldpath() .. "/schems"
|
||||
-- Create directory if it does not already exist
|
||||
worldedit.mkdir(path)
|
||||
mkdir(path)
|
||||
|
||||
local filename = path .. "/" .. param .. ".mts"
|
||||
local ret = minetest.create_schematic(worldedit.pos1[name],
|
||||
|
@ -1083,10 +1086,14 @@ minetest.register_chatcommand("/mtschemplace", {
|
|||
description = "Load nodes from \"(world folder)/schems/<file>.mts\" with position 1 of the current WorldEdit region as the origin",
|
||||
privs = {worldedit=true},
|
||||
func = function(name, param)
|
||||
if param == nil then
|
||||
if param == "" then
|
||||
worldedit.player_notify(name, "no filename specified")
|
||||
return
|
||||
end
|
||||
if not check_filename(param) then
|
||||
worldedit.player_notify(name, "Disallowed file name: " .. param)
|
||||
return
|
||||
end
|
||||
|
||||
local pos = get_position(name)
|
||||
if pos == nil then return end
|
||||
|
|
|
@ -65,3 +65,4 @@ minetest.register_chatcommand("/n", {
|
|||
})
|
||||
|
||||
return safe_region, check_region
|
||||
|
||||
|
|
|
@ -488,7 +488,7 @@ worldedit.register_gui_function("worldedit_gui_orient", {
|
|||
get_formspec = function(name)
|
||||
local angle = gui_angle[name]
|
||||
return "size[5,3]" .. worldedit.get_formspec_header("worldedit_gui_orient") ..
|
||||
string.format("dropdown[0,1;2.5;worldedit_gui_rotate_angle;90 degrees,180 degrees,270 degrees;%s]", angle) ..
|
||||
string.format("dropdown[0,1;2.5;worldedit_gui_orient_angle;90 degrees,180 degrees,270 degrees;%s]", angle) ..
|
||||
"button_exit[0,2.5;3,0.8;worldedit_gui_orient_submit;Orient]"
|
||||
end,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user