Posted: Sun Jan 15, 2012 03:49
This still isn't working for me!!! I put {John_Lennon} in the weperms.txt file inside the mod. And I still can't use the // commands
The official Minetest discussion board
https://forum.minetest.net/
I'll add thatcopypaste wrote:A //drain function for lava and water would really help a lot when fighting griefers.
Code: Select all
-- Functions
function get_tmp(name)
local f = io.open("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("wetemp_" .. name .. ".txt", "w")
if f == nil then
return false
else
f:write(text)
f:close()
return true
end
end
function to_pos(s)
local pos = {-1,-1,-1}
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)
local fi = ""
local f = io.open("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
-- Other Code
set_tmp("pos1", to_pos_str(0,0,0))
set_tmp("pos2", to_pos_str(0,0,0))
set_tmp("postoset", "-1")
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()
set_tmp("pos1", 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()
set_tmp("pos2", 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/set]')
return true
end
if ope == "get" then
local pos1 = to_pos(get_tmp("pos1"))
local pos2 = to_pos(get_tmp("pos2"))
minetest.chat_send_player(name, "P1: ("..pos1[1]..","..pos1[2]..","..pos1[3]..")")
minetest.chat_send_player(name, "P2: ("..pos2[1]..","..pos2[2]..","..pos2[3]..")")
return true
end
if ope == "set" then
set_tmp("postoset", "0")
minetest.chat_send_player(name, "Please select P1 and P2")
return true
end
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
local pos1 = to_pos(get_tmp("pos1"))
local pos2 = to_pos(get_tmp("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
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
print("nn: "..dump(nn))
if nn[2] == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [nodename],[nodename2]')
return true
end
local pos1 = to_pos(get_tmp("pos1"))
local pos2 = to_pos(get_tmp("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
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 = "//duplicate"
if message:sub(0, #cmd) == cmd then
if check_player_we_perms(name) then
local offset = {}
local tmp = message:gsub(cmd.." ","")
offset = tmp:split(",")
tmp = nil
print("offset: "..dump(offset))
if offset[1] == nil or offset[2] == nil or offset[3] == nil then
minetest.chat_send_player(name, 'usage: '..cmd..' [x],[y],[z]')
return true
end
local pos1 = to_pos(get_tmp("pos1"))
local pos2 = to_pos(get_tmp("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
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 n = minetest.env:get_node({x=x, y=y, z=z})
minetest.env:add_node({x=x+offset[1], y=y+offset[2], z=z+offset[3]}, n)
bc = bc + 1
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
return true
end
end)
minetest.register_on_punchnode(function(p, node)
if get_tmp("postoset") == "1" then
set_tmp("pos2", to_pos_str(p.x,p.y,p.z))
set_tmp("postoset", "-1")
end
if get_tmp("postoset") == "0" then
set_tmp("pos1", to_pos_str(p.x,p.y,p.z))
set_tmp("postoset", "1")
end
end)
The issue was that minetest was under /usr/bin and after compiling a run in place minetest I noticed files created in the same folder as minetest. Due to permissions that couldn't be done with minetest in /usr/bindannydark wrote:@Raphael works fine for me on with or without RUN_IN_PLACE active, try doing "//p set" then punch 2 nodes then use "//p get" to see if the location params have changed.
I'll add a //stack Command, so you don't need to type //duplicate 10 Times.dannydark wrote:Any news on an update? I'm not waiting for any specific feature was just curious ^_^
By the way, I saw that you had added the //replace command excellent! thanks for that, also it might be worth adding the //replace command to the original post. I only noticed it because I saw your commit log lol.
Awesome thanks for the update ^_^sfan5 wrote:Update!Download: http://ubuntuone.com/4JAj3d46ywX65a605wgDPm
- If someone punches a block and //p set was typed before, it will be ignored if the User has no WorldEdit-Priv
- Save the Selection with //save [filename]
- Paste File relative to P1 with //load [filename]
- Stack things with //stack [direction],[amount]
Yes, i'll change that in the next Versiondannydark wrote:Also quick question are the selected coordinates set when using "//p set" per-player? i.e. If I do "//p set" then hit 2 positions to make a selection and then someone else did "//p set" and hit 2 positions elsewhere would the positions I had selected be overwritten?sfan5 wrote:Update!Download: http://ubuntuone.com/4JAj3d46ywX65a605wgDPm
- If someone punches a block and //p set was typed before, it will be ignored if the User has no WorldEdit-Priv
- Save the Selection with //save [filename]
- Paste File relative to P1 with //load [filename]
- Stack things with //stack [direction],[amount]
Code: Select all
00:35:50: INFO[ServerThread]: Debug stacks:
00:35:50: INFO[ServerThread]: DEBUG STACK FOR THREAD 140273843414784:
00:35:50: INFO[ServerThread]: #0 virtual void* ServerThread::Thread()
00:35:50: INFO[ServerThread]: #1 void Server::Receive()
00:35:50: INFO[ServerThread]: #2 void Server::ProcessData(irr::u8*, irr::u32, irr::u16)
00:35:50: INFO[ServerThread]: DEBUG STACK FOR THREAD 140273874904864:
00:35:50: INFO[ServerThread]: #0 int main(int, char**)
00:35:50: INFO[ServerThread]: #1 void dedicated_server_loop(Server&, bool&)
00:35:50: INFO[ServerThread]: #2 irr::core::list<PlayerInfo> Server::getPlayerInfo()
00:35:50: ERROR[ServerThread]: Map::setNode(): Not allowing to place CONTENT_IGNORE while trying to replace "air" at (274,42,207) (block (17,2,12))
WorldEdit can only paste into loaded chunks and it can only save loaded chunksdannydark wrote:hmmmm is there a size limit when pasting regions? I'm trying to paste a large building but every time I try it gets to 54642 blocks and then floods the terminal with these errors:
Meaning I end up with half a building lol, I've tried to make the region copy as close to the building as possible (i.e. no unnecessary air blocks etc)Code: Select all
00:35:50: INFO[ServerThread]: Debug stacks: 00:35:50: INFO[ServerThread]: DEBUG STACK FOR THREAD 140273843414784: 00:35:50: INFO[ServerThread]: #0 virtual void* ServerThread::Thread() 00:35:50: INFO[ServerThread]: #1 void Server::Receive() 00:35:50: INFO[ServerThread]: #2 void Server::ProcessData(irr::u8*, irr::u32, irr::u16) 00:35:50: INFO[ServerThread]: DEBUG STACK FOR THREAD 140273874904864: 00:35:50: INFO[ServerThread]: #0 int main(int, char**) 00:35:50: INFO[ServerThread]: #1 void dedicated_server_loop(Server&, bool&) 00:35:50: INFO[ServerThread]: #2 irr::core::list<PlayerInfo> Server::getPlayerInfo() 00:35:50: ERROR[ServerThread]: Map::setNode(): Not allowing to place CONTENT_IGNORE while trying to replace "air" at (274,42,207) (block (17,2,12))