[Modpack] WorldEdit [worldedit]
- IPushButton2653
- Member
- Posts: 666
- Joined: Wed Nov 16, 2011 22:47
- Location: Mississippi
- Contact:
- IPushButton2653
- Member
- Posts: 666
- Joined: Wed Nov 16, 2011 22:47
- Location: Mississippi
- Contact:
One thing I'd love to see would be a /duplicate and a /move command, which would be extremely helpful if working with things like mesecons.
I've tried to implement it myself, but I can't seem to get it quite right yet. Would this be difficult to implement?
I've tried to implement it myself, but I can't seem to get it quite right yet. Would this be difficult to implement?
WorldEdit 1.0 released
The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
I have gotten the duplicate command to work:
Use it with //duplicate offsetx,offsety,offsetz.
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)
WorldEdit 1.0 released
The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
EDIT: Found the issue. Basically for proper functioning run WorldEdit with a "runinplace" minetest. Using the Ubuntu packages for minetest just doesn't work due to permission issues.
Ok so I finally got around to trying WorldEdit but it fails. I tried both methods listed in first post and all I ever get is "1 blocks changed".
EDIT: And that appears to be at -1,-1,-1 or very close to it.
Ok so I finally got around to trying WorldEdit but it fails. I tried both methods listed in first post and all I ever get is "1 blocks changed".
EDIT: And that appears to be at -1,-1,-1 or very close to it.
Last edited by RAPHAEL on Sun Feb 12, 2012 22:48, edited 1 time in total.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
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.
Compiling a run in place minetest and putting it somewhere under /home/username fixes that and allows it to work. After some playing around I find WorldEdit rather useful.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)
-
- Moderator
- Posts: 4095
- Joined: Wed Aug 24, 2011 09:44
- GitHub: sfan5
- IRC: sfan5
- Location: Germany
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.
-
- Moderator
- Posts: 4095
- Joined: Wed Aug 24, 2011 09:44
- GitHub: sfan5
- IRC: sfan5
- Location: Germany
Update!
- 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]
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]
If someone punches a block and //p set was typed before, it will be ignored if the User has no WorldEdit-Priv <-- Does this fix: me and a moderator on my server were both using worldedit at the same time and I used //p set and punched one block then went to the other block and punched it but when I did //set stone it create a massive stone cube from my position (about 400 blocks into the air) straight down into a cave at -560ish where a 3rd player was mining.
So I'm guessing when I did //p set and punched the first block before I had chance to punch the next block the player mining hit something which made the selection box huge lol.
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?
Because if it isn't stored per-player this could also cause quite a few problems ^_^ Also could I make a few feature suggestions for some extra commands
- //copy - Copies the selected area
- //cut - Cuts the selected area
- //paste - Pastes the Cut or Copied area
Also Thanks for the Save & Load functionality its made a lot of people happy on my server as I've been able to bring over buildings from the old 0.3 server ^_^
-
- Moderator
- Posts: 4095
- Joined: Wed Aug 24, 2011 09:44
- GitHub: sfan5
- IRC: sfan5
- Location: Germany
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]
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))
I'm pretty sure that means it's trying to place a node in an unloaded chunk. I'm not sure if it's possible to load a chunk using Lua, but this would be fixed if it was possible to.
WorldEdit 1.0 released
The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
-
- Moderator
- Posts: 4095
- Joined: Wed Aug 24, 2011 09:44
- GitHub: sfan5
- IRC: sfan5
- Location: Germany
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))
-
- Member
- Posts: 103
- Joined: Thu Feb 16, 2012 18:04
Who is online
Users browsing this forum: SkyBuilder1717 and 25 guests