sfan5 wrote:I created WorldEdit before that Feature got added, and i'm too lazy to change it
-- Load Table-Save/Load Library | http://lua-users.org/wiki/SaveTableToFile
print("[WorldEdit] Loading Table-Save/Load Library...")
dofile(minetest.get_modpath("worldedit").."/table_save-load.lua")
assert(table.save ~= nil)
assert(table.load ~= nil)
minetest.register_privilege("worldedit", "Ability to use WorldEdit")
worldedit = {}
-- Functions
function get_tmp(name)
local f = io.open(minetest.get_modpath("worldedit").."/wetemp_" .. name .. ".txt", "r")
if f == nil then
return ""
else
return f:read("*all")
end
end
function set_tmp(name,text)
local f = io.open(minetest.get_modpath("worldedit").."/wetemp_" .. name .. ".txt", "w")
if f == nil then
return false
else
f:write(text)
f:close()
return true
end
end
function check_if_dir(path)
f = io.open(path, "r")
if f == nil then
return false -- Doesn't exists
end
local ok, err, code = f:read("*a")
f:close()
if code == 21 then
return true
end
return false
end
function check_schematic_dir(worldpath)
if not check_if_dir(worldpath .. "/schems") then
os.execute("mkdir " .. worldpath .. "/schems") --Dirty hack
end
end
function to_pos(s)
local pos = {0,0,0}
i = 1
string.gsub(s,"{(.-)}", function(a)
pos[i] = tonumber(a)
i = i + 1
end)
return pos
end
function to_pos_str(x,y,z)
return "{" .. x .. "}{" .. y .. "}{" .. z .. "}"
end
function to_pos_userstr(p)
return "(" .. p[1] .. "," .. p[2] .. "," .. p[3] .. ")"
end
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end
function check_player_we_perms(pname)
if minetest.get_player_privs(pname).worldedit then
return true
end
local fi = ""
local f = io.open(minetest.get_worldpath().."/weperms.txt", "r")
if f ~= nil then
fi = f:read("*all")
f:close()
else
return false
end
local list = {}
i = 1
string.gsub(fi,"{(.-)}", function(a)
list[i] = a
i = i + 1
end)
for n = 1, table.getn(list), 1 do
if list[n] == pname then
return true
end
end
return false
end
function sort_pos(pos1,pos2)
if pos1[1] >= pos2[1] then
local temp = pos2[1]
pos2[1] = pos1[1]
pos1[1] = temp
temp = nil
end
if pos1[2] >= pos2[2] then
local temp = pos2[2]
pos2[2] = pos1[2]
pos1[2] = temp
temp = nil
end
if pos1[3] >= pos2[3] then
local temp = pos2[3]
pos2[3] = pos1[3]
pos1[3] = temp
temp = nil
end
return {pos1,pos2}
end
function get_we_pos(pname)
return to_pos(get_tmp("pos1_"..pname)),to_pos(get_tmp("pos2_"..pname))
end
local round = function(n)
if n >= 0 then
return math.floor(n + 0.5)
else
return math.ceil(n - 0.5)
end
end
-- API 0.1
worldedit.apiversion = "0.1"
-- mtpos is something like {x=1,y=2,z=3}
-- wepos is something like {1,2,3}
-- Returns the Positions a Player selected
function worldedit.get_selected_positions_of_player(playername)
local pos1,pos2 = get_we_pos(playername)
return pos1,pos2
end
-- Sort 2 Positions, so p1.x < p2.x (same with y and z)
function worldedit.sort_positions(pos1, pos2)
local ps = sort_pos(pos1,pos2)
return ps[1],ps[2]
end
-- Converts a Position used by WorldEdit to a Position used by Minetest
function worldedit.wepos_to_mtpos(wepos)
return {x=wepos[1],y=wepos[2],z=wepos[3]}
end
-- Converts a Position used by Minetest to a Position used by WorldEdit
function worldedit.mtpos_to_wepos(mtpos)
return {mtpos.x,mtpos.y,mtpos.z}
end
-- Returns an Userreadable-String representing a Position used by WorldEdit
function worldedit.wepos_to_user_readable(wepos)
return to_pos_userstr(wepos)
end
-- Returns an Userreadable-String representing a Position used by Minetest
function worldedit.mtpos_to_user_readable(mtpos)
return to_pos_userstr(worldedit.mtpos_to_wepos(mtpos))
end
-- Floors the x,y and z of a Position used by Minetest
function worldedit.floor_mtpos(mtpos)
return {x=math.floor(mtpos.x),y=math.floor(mtpos.y),z=math.floor(mtpos.z)}
end
-- Floors the x,y and z of a Position used by WorldEdit
function worldedit.floor_wepos(wepos)
return {math.floor(wepos[1]),math.floor(wepos[2]),math.floor(wepos[3])}
end
-- Make sure the API works
assert(worldedit.wepos_to_mtpos({1,2,3}).x == 1)
assert(worldedit.mtpos_to_wepos({x=1,y=2,z=3})[3] == 3)
-- Other Code
minetest.register_on_chat_message(function(name, message)
local cmd = "//pos1"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local pl = minetest.env:get_player_by_name(name)
local p = pl:getpos()
p.x = round(p.x)
p.y = round(p.y)
p.z = round(p.z)
set_tmp("pos1_"..name, to_pos_str(p.x,p.y,p.z))
minetest.chat_send_player(name, 'P1 was set to '..to_pos_userstr({p.x,p.y,p.z}))
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
end
return true
end
local cmd = "//pos2"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local pl = minetest.env:get_player_by_name(name)
local p = pl:getpos()
p.x = round(p.x)
p.y = round(p.y)
p.z = round(p.z)
set_tmp("pos2_"..name, to_pos_str(p.x,p.y,p.z))
minetest.chat_send_player(name, 'P2 was set to '..to_pos_userstr({p.x,p.y,p.z}))
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
end
return true
end
local cmd = "//p"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local ope = string.match(message, cmd.." (.*)")
if ope == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [get/get1/get2/set/set1/set2]')
return true
end
if ope == "get" then
local pos1,pos2 = get_we_pos(name)
minetest.chat_send_player(name, "P1: "..to_pos_userstr(pos1))
minetest.chat_send_player(name, "P2: "..to_pos_userstr(pos2))
elseif ope == "get1" then
local pos1,pos2 = get_we_pos(name)
minetest.chat_send_player(name, "P1: "..to_pos_userstr(pos1))
elseif ope == "get2" then
local pos1,pos2 = get_we_pos(name)
minetest.chat_send_player(name, "P2: "..to_pos_userstr(pos2))
elseif ope == "set" then
set_tmp("postoset_"..name, "0")
minetest.chat_send_player(name, "Please select P1 and P2")
elseif ope == "set1" then
set_tmp("postoset_"..name, "2")
minetest.chat_send_player(name, "Please select P1")
elseif ope == "set2" then
set_tmp("postoset_"..name, "3")
minetest.chat_send_player(name, "Please select P2")
end
return true
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
end
local cmd = "//set"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local nn = string.match(message, cmd.." (.*)")
if nn == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [nodename]')
return true
end
pos1,pos2 = get_we_pos(name)
local temp = sort_pos(pos1,pos2)
pos1 = temp[1]
pos2 = temp[2]
temp = nil
local bc = 0
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local np = {x=x, y=y, z=z}
minetest.env:add_node(np, {name=nn})
bc = bc + 1
end
end
end
minetest.chat_send_player(name, bc..' Blocks changed')
return true
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
end
local cmd = "//replace"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local nn = {}
local tmp = message:gsub(cmd.." ","")
nn = tmp:split(",")
tmp = nil
if nn[2] == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [nodename],[nodename2]')
return true
end
pos1,pos2 = get_we_pos(name)
local temp = sort_pos(pos1,pos2)
pos1 = temp[1]
pos2 = temp[2]
temp = nil
local bc = 0
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local np = {x=x, y=y, z=z}
local n = minetest.env:get_node(np)
if n.name == "default:"..nn[1] or n.name == nn[1] then
minetest.env:add_node(np, {name=nn[2]})
bc = bc + 1
end
end
end
end
minetest.chat_send_player(name, bc..' Blocks replaced')
return true
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
return true
end
local cmd = "//stack"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local nn = {}
local tmp = message:gsub(cmd.." ","")
nn = tmp:split(",")
if nn[2] == nil then
minetest.chat_send_player(name, 'Usage: '..cmd..' [direction],[count]')
minetest.chat_send_player(name, 'Valid Directions are: x+ x- y+ y- z+ z-')
return true
end
pos1,pos2 = get_we_pos(name)
local temp = sort_pos(pos1,pos2)
pos1 = temp[1]
pos2 = temp[2]
local bc = 0
if nn[1] == "x+" then
for c = 1, nn[2], 1 do
local offset_x = (pos2[1] - pos1[1] + 1) * c
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x+offset_x, y=y, z=z}, n)
bc = bc + 1
end
end
end
end
end
if nn[1] == "x-" then
for c = 1, nn[2], 1 do
local offset_x = (pos2[1] - pos1[1] + 1) * c
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x-offset_x, y=y, z=z}, n)
bc = bc + 1
end
end
end
end
end
if nn[1] == "y+" then
for c = 1, nn[2], 1 do
local offset_y = (pos2[2] - pos1[2] + 1) * c
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x, y=y+offset_y, z=z}, n)
bc = bc + 1
end
end
end
end
end
if nn[1] == "y-" then
for c = 1, nn[2], 1 do
local offset_y = (pos2[2] - pos1[2] + 1) * c
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x, y=y-offset_y, z=z}, n)
bc = bc + 1
end
end
end
end
end
if nn[1] == "z+" then
for c = 1, nn[2], 1 do
local offset_z = (pos2[3] - pos1[3] + 1) * c
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x, y=y, z=z+offset_z}, n)
bc = bc + 1
end
end
end
end
end
if nn[1] == "z-" then
for c = 1, nn[2], 1 do
local offset_z = (pos2[3] - pos1[3] + 1) * c
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x, y=y, z=z-offset_z}, n)
bc = bc + 1
end
end
end
end
end
minetest.chat_send_player(name, bc..' Blocks duplicated')
return true
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
end
local cmd = "//shift"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) == false then
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
local nn = {}
local tmp = message:gsub(cmd.." ","")
nn = tmp:split(",")
if nn[2] == nil then
minetest.chat_send_player(name, 'Usage: '..cmd..' [direction],[count]')
minetest.chat_send_player(name, 'Valid Directions are: x+ x- y+ y- z+ z-')
return true
end
pos1,pos2 = get_we_pos(name)
if nn[1]:sub(1,1) == "x" then dir = 1 elseif nn[1]:sub(1,1) == "y" then dir = 2 elseif nn[1]:sub(1,1) == "z" then dir = 3 end
local k = tonumber(nn[1]:sub(-1).."1")
pos1[dir] = pos1[dir] + (nn[2] * k)
pos2[dir] = pos2[dir] + (nn[2] * k)
set_tmp("pos1_"..name, to_pos_str(pos1[1], pos1[2], pos1[3]))
set_tmp("pos2_"..name, to_pos_str(pos2[1], pos2[2], pos2[3]))
minetest.chat_send_player(name, "Region shifted")
return true
end
local cmd = "//expand"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) == false then
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
local nn = {}
local tmp = message:gsub(cmd.." ","")
nn = tmp:split(",")
if nn[2] == nil then
minetest.chat_send_player(name, 'Usage: '..cmd..' [direction],[count]')
minetest.chat_send_player(name, 'Valid Directions are: x+ x- y+ y- z+ z-')
return true
end
pos1,pos2 = get_we_pos(name)
if nn[1]:sub(1,1) == "x" then dir = 1 elseif nn[1]:sub(1,1) == "y" then dir = 2 elseif nn[1]:sub(1,1) == "z" then dir = 3 end
if nn[1]:sub(-1) == "+" then
if pos1[dir] >= pos2[dir] then
pos1[dir] = pos1[dir] + nn[2]
set_tmp("pos1_"..name, to_pos_str(pos1[1], pos1[2], pos1[3]))
else
pos2[dir] = pos2[dir] + nn[2]
set_tmp("pos2_"..name, to_pos_str(pos2[1], pos2[2], pos2[3]))
end
else
if pos1[dir] <= pos2[dir] then
pos1[dir] = pos1[dir] - nn[2]
set_tmp("pos1_"..name, to_pos_str(pos1[1], pos1[2], pos1[3]))
else
pos2[dir] = pos2[dir] - nn[2]
set_tmp("pos2_"..name, to_pos_str(pos2[1], pos2[2], pos2[3]))
end
end
minetest.chat_send_player(name, "Region expanded")
return true
end
local cmd = "//contract"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) == false then
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
local nn = {}
local tmp = message:gsub(cmd.." ","")
nn = tmp:split(",")
if nn[2] == nil then
minetest.chat_send_player(name, 'Usage: '..cmd..' [direction],[count]')
minetest.chat_send_player(name, 'Valid Directions are: x+ x- y+ y- z+ z-')
return true
end
pos1,pos2 = get_we_pos(name)
if nn[1]:sub(1,1) == "x" then dir = 1 elseif nn[1]:sub(1,1) == "y" then dir = 2 elseif nn[1]:sub(1,1) == "z" then dir = 3 end
if nn[1]:sub(-1) == "+" then
if pos1[dir] <= pos2[dir] then
pos1[dir] = pos1[dir] + nn[2]
set_tmp("pos1_"..name, to_pos_str(pos1[1], pos1[2], pos1[3]))
else
pos2[dir] = pos2[dir] + nn[2]
set_tmp("pos2_"..name, to_pos_str(pos2[1], pos2[2], pos2[3]))
end
else
if pos1[dir] >= pos2[dir] then
pos1[dir] = pos1[dir] - nn[2]
set_tmp("pos1_"..name, to_pos_str(pos1[1], pos1[2], pos1[3]))
else
pos2[dir] = pos2[dir] - nn[2]
set_tmp("pos2_"..name, to_pos_str(pos2[1], pos2[2], pos2[3]))
end
end
minetest.chat_send_player(name, "Region contracted")
return true
end
local cmd = "//volume"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) == false then
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
pos1,pos2 = get_we_pos(name)
local temp = sort_pos(pos1, pos2)
pos1 = temp[1]
pos2 = temp[2]
local bc = (pos2[1] - pos1[1] + 1) * (pos2[2] - pos1[2] + 1) * (pos2[3] - pos1[3] + 1)
minetest.chat_send_player(name, bc.." blocks")
return true
end
local cmd = "//save"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) == false then
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
local fn = string.match(message, cmd.." (.*)")
if fn == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [filename]')
return true
end
fn = minetest.get_worldpath().."/schems/"..fn..".we"
check_schematic_dir(minetest.get_worldpath()) -- Make sure WORLDDIR/schems exists
data = {}
datai = 1
----------
pos1,pos2 = get_we_pos(name)
local temp = sort_pos(pos1,pos2)
pos1 = temp[1]
pos2 = temp[2]
temp = nil
local bs = 0
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local np = {x=x, y=y, z=z}
local np_rel = {x=pos1[1]-x, y=pos1[2]-y, z=pos1[3]-z} -- Relative Position
local n = minetest.env:get_node(np)
if n.name ~= "air" then -- Don't Save air
if n.param1 == 0 then n.param1 = nil end
if n.param2 == 0 then n.param2 = nil end
data[datai] = {np_rel,n} -- data[index] = {position,node_data}
datai = datai + 1
bs = bs + 1
end
end
end
end
----------
--print(dump(data))
table.save(data, fn)
minetest.chat_send_player(name, bs..' Blocks saved to '..fn)
return true
end
local cmd = "//load"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) == false then
minetest.chat_send_player(name, 'You havent got the Permission for that')
return true
end
local fn = string.match(message, cmd.." (.*)")
if fn == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [filename]')
return true
end
fn = minetest.get_worldpath().."/schems/"..fn
check_schematic_dir(minetest.get_worldpath()) -- Make sure WORLDDIR/schems exists
data = {}
data,err = table.load(fn)
if data == nil then
minetest.chat_send_player(name, "Cound not load '"..fn.."'")
return true
end
--print(dump(data))
----------
pos1 = to_pos(get_tmp("pos1_"..name))
local bp = 0
for i = 1, #data, 1 do
local d = data[i]
local np = {x=pos1[1]-d[1].x,y=pos1[2]-d[1].y,z=pos1[3]-d[1].z}
minetest.env:add_node(np,d[2])
bp = bp + 1
end
----------
minetest.chat_send_player(name, bp..' Blocks pasted at '..to_pos_userstr(pos1))
return true
end
local cmd = "//light"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
pos1,pos2 = get_we_pos(name)
local temp = sort_pos(pos1,pos2)
pos1 = temp[1]
pos2 = temp[2]
temp = nil
local bl = 0
for x = pos1[1], pos2[1], 1 do
for y = pos1[2], pos2[2], 1 do
for z = pos1[3], pos2[3], 1 do
local np = {x=x, y=y, z=z}
local no = minetest.env:get_node(np)
no.param1 = 13
minetest.env:add_node(np, no)
bl = bl + 1
end
end
end
minetest.chat_send_player(name, bl..' Blocks lighted')
return true
else
minetest.chat_send_player(name, 'You havent got the Permission for that')
end
return true
end
end)
minetest.register_on_punchnode(function(p, node, puncher)
if puncher:get_player_name() ~= nil then
local pn = puncher:get_player_name()
if check_player_we_perms(pn) == false then return end
local tmp = get_tmp("postoset_"..pn)
if tmp == "1" or tmp == "3" then
set_tmp("pos2_"..pn, to_pos_str(p.x,p.y,p.z))
set_tmp("postoset_"..pn, "-1")
minetest.chat_send_player(pn, 'P2 was set to '..to_pos_userstr({p.x,p.y,p.z}))
end
if tmp == "0" or tmp == "2" then
set_tmp("pos1_"..pn, to_pos_str(p.x,p.y,p.z))
if tmp == "0" then set_tmp("postoset_"..pn, "1") else set_tmp("postoset_"..pn, "-1") end
minetest.chat_send_player(pn, 'P1 was set to '..to_pos_userstr({p.x,p.y,p.z}))
end
end
end)
print("[WorldEdit] Loaded!")
AAAAA
AAAAA
AAAAA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
GGGGG
GGGGG
AAAAA
BBBBB
AAAAA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
GGGGG
GGGGG
Temperest wrote:Ah, that's great! Thanks for the tip cosarara97, those shadows were really getting annoying.
I suppose WorldEdit could do this with the new place_node() and dig_node() EnvRef functions, but IMO there should be a built-in way to do this.
Temperest wrote:Ah, that's great! Thanks for the tip cosarara97, those shadows were really getting annoying.
I suppose WorldEdit could do this with the new place_node() and dig_node() EnvRef functions, but IMO there should be a built-in way to do this.
Stef wrote:we need a voxelsniper World Edit for adventure maps.
sfan5 wrote:Temperest wrote:Ah, that's great! Thanks for the tip cosarara97, those shadows were really getting annoying.
I suppose WorldEdit could do this with the new place_node() and dig_node() EnvRef functions, but IMO there should be a built-in way to do this.
AFAIK the light only regenrates if you break it with a tool, not with a Lua function
cosarara97 wrote:sfan5 wrote:Temperest wrote:Ah, that's great! Thanks for the tip cosarara97, those shadows were really getting annoying.
I suppose WorldEdit could do this with the new place_node() and dig_node() EnvRef functions, but IMO there should be a built-in way to do this.
AFAIK the light only regenrates if you break it with a tool, not with a Lua function
Isn't there any lua function which breaks blocks "like with a tool"?
Temperest wrote:After some testing, I determined that minetest.env:dig_node does in fact cause the shadows to be recalculated.
Since it's a bit difficult to detect these shadows from Lua, I suggest the "//dig" command be added, which simply causes WorldEdit to do a "//set air", except use minetest.env:dig_node(np) rather than add_node(np, {name="air"}). I've already changed my own copy, I can post it here if necessary.
minetest.chat_send_player(name, bp..' Blocks pasted at '..to_pos_userstr(pos1))
return true
end
+ local cmd = "//dig"
+ if message:sub(0, #cmd) == cmd then
+ if check_player_we_perms(name) then
+ pos1,pos2 = get_we_pos(name)
+ local temp = sort_pos(pos1,pos2)
+ pos1 = temp[1]
+ pos2 = temp[2]
+ temp = nil
+ local bl = 0
+ for x = pos1[1], pos2[1], 1 do
+ for y = pos1[2], pos2[2], 1 do
+ for z = pos1[3], pos2[3], 1 do
+ minetest.env:dig_node({x=x, y=y, z=z})
+ bl = bl + 1
+ end
+ end
+ end
+ minetest.chat_send_player(name, bl..' Blocks dug')
+ return true
+ else
+ minetest.chat_send_player(name, 'You havent got the Permission for that')
+ end
+ return true
+ end
local cmd = "//light"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
Temperest wrote:No, the outline is not supposed to show up. However, I think that would be a nice idea. It would definitely be possible by using a bunch of sprite entities making up the outline of the cube.
Here is the //dig command patch:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.chat_send_player(name, bp..' Blocks pasted at '..to_pos_userstr(pos1))
return true
end
+ local cmd = "//dig"
+ if message:sub(0, #cmd) == cmd then
+ if check_player_we_perms(name) then
+ pos1,pos2 = get_we_pos(name)
+ local temp = sort_pos(pos1,pos2)
+ pos1 = temp[1]
+ pos2 = temp[2]
+ temp = nil
+ local bl = 0
+ for x = pos1[1], pos2[1], 1 do
+ for y = pos1[2], pos2[2], 1 do
+ for z = pos1[3], pos2[3], 1 do
+ minetest.env:dig_node({x=x, y=y, z=z})
+ bl = bl + 1
+ end
+ end
+ end
+ minetest.chat_send_player(name, bl..' Blocks dug')
+ return true
+ else
+ minetest.chat_send_player(name, 'You havent got the Permission for that')
+ end
+ return true
+ end
local cmd = "//light"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
Works pretty well, but the WorldEdit codebase could use some cleanup.
Temperest wrote:No, the outline is not supposed to show up. However, I think that would be a nice idea. It would definitely be possible by using a bunch of sprite entities making up the outline of the cube.
Here is the //dig command patch:Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.chat_send_player(name, bp..' Blocks pasted at '..to_pos_userstr(pos1))
return true
end
+ local cmd = "//dig"
+ if message:sub(0, #cmd) == cmd then
+ if check_player_we_perms(name) then
+ pos1,pos2 = get_we_pos(name)
+ local temp = sort_pos(pos1,pos2)
+ pos1 = temp[1]
+ pos2 = temp[2]
+ temp = nil
+ local bl = 0
+ for x = pos1[1], pos2[1], 1 do
+ for y = pos1[2], pos2[2], 1 do
+ for z = pos1[3], pos2[3], 1 do
+ minetest.env:dig_node({x=x, y=y, z=z})
+ bl = bl + 1
+ end
+ end
+ end
+ minetest.chat_send_player(name, bl..' Blocks dug')
+ return true
+ else
+ minetest.chat_send_player(name, 'You havent got the Permission for that')
+ end
+ return true
+ end
local cmd = "//light"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
Works pretty well, but the WorldEdit codebase could use some cleanup.
patch init.lua patch.txt
Users browsing this forum: No registered users and 55 guests