Page 2 of 35

Posted: Sun Jan 15, 2012 03:49
by IPushButton2653
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 :(

Posted: Sun Jan 15, 2012 08:41
by sfan5
weperms.txt must be inside your bin folder not in the mod folder

Posted: Thu Jan 19, 2012 00:13
by IPushButton2653
That explains all my problems. Thanks, and sorry for not replying sooner

Posted: Sun Jan 22, 2012 14:21
by copypaste
A //drain function for lava and water would really help a lot when fighting griefers.

Posted: Sun Jan 22, 2012 18:53
by sfan5
copypaste wrote:A //drain function for lava and water would really help a lot when fighting griefers.
I'll add that

Posted: Mon Jan 23, 2012 02:32
by Temperest
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?

Posted: Mon Jan 23, 2012 03:19
by Temperest
I have gotten the duplicate command to work:

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)
Use it with //duplicate offsetx,offsety,offsetz.

Posted: Mon Jan 23, 2012 06:23
by sfan5
I'll merge your Code, but I'll probably make a //stack direction,amount too

Posted: Sun Feb 12, 2012 20:40
by dannydark
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 :D 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.

Posted: Sun Feb 12, 2012 22:14
by RAPHAEL
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.

Posted: Sun Feb 12, 2012 23:32
by dannydark
@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.

Posted: Sun Feb 12, 2012 23:43
by RAPHAEL
dannydark 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.
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/bin

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.

Posted: Mon Feb 13, 2012 06:00
by sfan5
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 :D 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.
I'll add a //stack Command, so you don't need to type //duplicate 10 Times.

Posted: Sun Feb 19, 2012 16:57
by sfan5
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]
Download: http://ubuntuone.com/4JAj3d46ywX65a605wgDPm

Posted: Mon Feb 20, 2012 16:18
by dannydark
sfan5 wrote: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]
Download: http://ubuntuone.com/4JAj3d46ywX65a605wgDPm
Awesome thanks for the update ^_^

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
I believe the above commands could be useful for moving buildings to a new spawn point or whatever ^_^

Also Thanks for the Save & Load functionality :D 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 ^_^

Posted: Mon Feb 20, 2012 18:01
by sfan5
dannydark wrote:
sfan5 wrote: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]
Download: http://ubuntuone.com/4JAj3d46ywX65a605wgDPm
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?
Yes, i'll change that in the next Version

Posted: Tue Feb 21, 2012 01:02
by dannydark
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:

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))
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)

Posted: Tue Feb 21, 2012 01:22
by Temperest
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.

Posted: Tue Feb 21, 2012 15:21
by sfan5
dannydark 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:

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))
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)
WorldEdit can only paste into loaded chunks and it can only save loaded chunks

Posted: Tue Mar 13, 2012 13:42
by sfan5
I'll release an Update soon!!

Posted: Tue Mar 13, 2012 15:54
by Jordach
AWESOME, ALL YOU NEED IS SOME ADMIN TOOLS AND WE ARE AWAY!

Posted: Sat Mar 17, 2012 09:30
by sfan5
Update!
Changelog:
  • Fixed annoying "You havent got the Permission for that"-Bug when punching Blocks
  • Each Player now has his/her own P1 and P2
    e.g. sfan5 has selected his house while jordan4ibanez has selected a tnt cannon
Download in first Post!

Posted: Sat Mar 17, 2012 09:35
by Jordach
Nice one. How's snow coming along?

Posted: Sat Mar 17, 2012 09:39
by sfan5
Image

Posted: Wed Mar 21, 2012 21:23
by Utilisatrice
Hi,

Sfan5, can you add the cut command please :D ?

Where found this mod (Snow) ?