[Mod] WorldEdit [1.0] [worldedit]

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Jun 28, 2012 15:02

AFAIK theres to no Way to recalculate the light
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
Stef
Member
 
Posts: 394
Joined: Wed Apr 04, 2012 10:46

by Stef » Fri Jun 29, 2012 07:53

Sfan the light command won't work for me too
Sorry for my crappy english, im dutch :D
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Jun 29, 2012 12:21

The light Command is experimantal, and may have no effect
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
kotolegokot
Member
 
Posts: 131
Joined: Mon Jul 02, 2012 17:03

by kotolegokot » Tue Jul 03, 2012 13:22

Why you don't use minetest.register_chatcommand?
I'm creator of these mods: Locked sign, Locked furnace, Money. And I'm a developer of The RealTest Game.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Tue Jul 03, 2012 13:34

I created WorldEdit before that Feature got added, and i'm too lazy to change it
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
redcrab
Member
 
Posts: 831
Joined: Tue Dec 13, 2011 13:45

by redcrab » Tue Jul 03, 2012 17:28

sfan5 wrote:I created WorldEdit before that Feature got added, and i'm too lazy to change it


I understand ....

The mod source is open so ... if someone would to modernize the code I guess he can do it ;)
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.
 

User avatar
kotolegokot
Member
 
Posts: 131
Joined: Mon Jul 02, 2012 17:03

by kotolegokot » Sat Jul 07, 2012 12:28

If you want I can help you in the development of this mod.
I'm creator of these mods: Locked sign, Locked furnace, Money. And I'm a developer of The RealTest Game.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sat Jul 07, 2012 19:45

You can change the Files and send them to me
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
kotolegokot
Member
 
Posts: 131
Joined: Mon Jul 02, 2012 17:03

by kotolegokot » Sun Jul 08, 2012 07:55

Ok. I corrected //pos1 and //pos2 and added //p get1, //p get2, //p set1, //p set2, //expand, //contract, //shift, //volume.
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
-- 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!")
Last edited by kotolegokot on Sun Jul 08, 2012 09:30, edited 1 time in total.
I'm creator of these mods: Locked sign, Locked furnace, Money. And I'm a developer of The RealTest Game.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Sun Jul 08, 2012 10:22

I'll merge that later
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
kotolegokot
Member
 
Posts: 131
Joined: Mon Jul 02, 2012 17:03

by kotolegokot » Sun Jul 08, 2012 12:23

I think the files wetemp_* must be in the world folder. And why are you using "wepos" instead of "mtpos"? Usage "mtpos" is more comfortable because you can use minetest.string_to_pos and minetest.pos_to_string.
Last edited by kotolegokot on Sun Jul 08, 2012 15:10, edited 1 time in total.
I'm creator of these mods: Locked sign, Locked furnace, Money. And I'm a developer of The RealTest Game.
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Wed Jul 11, 2012 15:49

I found the way to recalculate light and destroy those shadows, but for now it's too slow, so I thought you could implement it in the light command (to make it automatic).
Well, the way I found is the following:
If we have the following map (viewed from a side):
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
AAAAA
AAAAA
AAAAA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
GGGGG
GGGGG


A=Air
S=Unknown shadow
G=Ground
(you can know if you are inside a shadow looking at your hand/tool)

Then all you have to do is make a this (with worldedit):
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
AAAAA
BBBBB
AAAAA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
ASSSA
GGGGG
GGGGG

B = Block (cobble, for example)

And then destroy the cobble (or what you placed in the air) with a tool.
Then go to the ground so the light recalculates.
I hope there's a way to do this with worldedit :)
Last edited by cosarara97 on Wed Jul 11, 2012 15:49, edited 1 time in total.
:D
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Wed Jul 11, 2012 16:13

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.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Wed Jul 11, 2012 16:15

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.

IMO those shadows shouldn't exist :)
:D
 

User avatar
Stef
Member
 
Posts: 394
Joined: Wed Apr 04, 2012 10:46

by Stef » Thu Jul 12, 2012 06:08

we need a voxelsniper World Edit for adventure maps.
Sorry for my crappy english, im dutch :D
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Thu Jul 12, 2012 08:54

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
Stef wrote:we need a voxelsniper World Edit for adventure maps.

That would require CPU-intense Math, but is possible
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

User avatar
Stef
Member
 
Posts: 394
Joined: Wed Apr 04, 2012 10:46

by Stef » Thu Jul 12, 2012 09:02

nice who will make it i cant make mods
Sorry for my crappy english, im dutch :D
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Thu Jul 12, 2012 10:24

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"? If there isn't, I'll see if with my very low level of c++ I can understand something about the source code and add one, or one which just calls the function which regenerates light when you break a block with your hand...
:D
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Thu Jul 12, 2012 15:24

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"?


Yes, that's the place_node() and dig_node() functions I mentioned. I'll make a test mod for this in a bit.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Thu Jul 12, 2012 18:06

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.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Thu Jul 12, 2012 18:43

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.

yes please temperest.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
Nexdah
Member
 
Posts: 42
Joined: Fri Jul 06, 2012 22:35

by Nexdah » Thu Jul 12, 2012 21:38

Can I use this to edit the landscape?
This is a Signature.


First ever Astronaut in Minetest.
 

User avatar
Jordach
Member
 
Posts: 4412
Joined: Mon Oct 03, 2011 17:58
GitHub: Jordach
IRC: Jordach
In-game: Jordach

by Jordach » Thu Jul 12, 2012 21:41

yes. you can.

( ͡° ͜ʖ ͡°) ( ͡o ͜ʖ ͡o) [$ ( ͡° ͜ʖ ͡°) $] ( ͡$ ͜ʖ ͡$) ヽ༼ຈل͜ຈ༽ノ



My image and media server is back online and is functioning as normal.
 

User avatar
NakedFury
Member
 
Posts: 151
Joined: Thu Dec 08, 2011 03:55

by NakedFury » Fri Jul 13, 2012 01:32

When using this and having 2 selected positions, am I supposed to see a red selection square in the positions?

The second picture in the first post shows them and I can't see them in my game.
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Fri Jul 13, 2012 03:18

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.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
sfan5
Member
 
Posts: 3636
Joined: Wed Aug 24, 2011 09:44
GitHub: sfan5
IRC: sfan5

by sfan5 » Fri Jul 13, 2012 10:11

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.

Will get merged but i'm not at home now
Mods: Mesecons | WorldEdit | Nuke
Minetest builds for Windows (32-bit & 64-bit)
 

cosarara97
Member
 
Posts: 180
Joined: Tue Nov 01, 2011 18:53

by cosarara97 » Fri Jul 13, 2012 14:44

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.


How can I apply this patch?
I tried this (after saving the patch to patch.txt):
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
patch init.lua patch.txt

but it says it's just garbage :(
:D
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Sat Jul 14, 2012 02:02

I've rewritten WorldEdit from scratch! Here's a link: https://github.com/Uberi/MineTest-WorldEdit

Changes:

  • License is now AGPLv3. Most server side programs can't benefit from the protections the GPL provides, although the AGPL variants can.
  • Full help and parameter descriptions for every command.
  • A new README that describes every command and gives examples, as well as help setting everything up.
  • Everything has been rewritten from scratch with performance in mind, big operations are significantly faster in my tests.
  • New .we format that's more compact and human-readable. Plus, it's faster to save and load!
  • A couple of new commands, such as //copy, //move, and //dig.
  • New syntax for certain commands: //stack <direction>,<count> becomes //stack <axis> <count>. This also affects a few others.
  • No more temp files. As a side effect, the positions of each player are not saved past server restarts. I did not make use of this feature, personally, but I can add it back if there is a need for it.
  • Version number bump to 1.0. I think WorldEdit's come a long way and it's ready to make the big jump!
  • A new WorldEdit API. Mods can now make use of the functions that drive WorldEdit! It's as simple as adding "worldedit" to your depends.txt and calling the worldedit.* functions. For example, to copy a region use worldedit.copy(pos1, pos2, axis, amount).

sfan5, if you're willing to merge this I'll be glad to assist you with it. If you're not, I can understand, in that case I will publish it separately. If you want to discuss the license change, I'm willing to talk about it.

Edit: and now the WorldEdit API is fully documented! See README.md for more info.
Last edited by Temperest on Sat Jul 14, 2012 02:17, edited 1 time in total.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
NakedFury
Member
 
Posts: 151
Joined: Thu Dec 08, 2011 03:55

by NakedFury » Sat Jul 14, 2012 02:54

holy frak wow. some lua geniuses on this community.

AND OH MY GOD!

Full help and parameter descriptions for every command.

This is so useful for those new to lua.

Do you have more plans for it? Like maybe adding visual colored boxes to selected positions, pos1 and pos 2?
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Sat Jul 14, 2012 03:35

Yep, that's up next and I've got some really ugly code I'll be polishing off in the next few days. I'll be posting here when it's done, of course.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

PreviousNext

Return to Mod Releases

Who is online

Users browsing this forum: No registered users and 55 guests

cron