[Mod] WorldEdit [1.0] [worldedit]

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Sep 26, 2012 02:11

is there any way i can offset the save position? for example i am saving a structure, but i dont want 0,0,0 to be where pos1 is. i want a new pos (pos3?) that is the relative position for saving.

does that make sense?
 

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

by Temperest » Wed Sep 26, 2012 02:22

I can't seem to get spiral to work either; I will be looking into rewriting it perhaps as per the GitHub issue, since it uses GFDL code from RosettaCode and nobody understands how it works :P

Edit: also to address your other concern, there is no way to do so at the moment, sorry. If you have any suggestions for doing this in an elegant way, I'd be glad to hear them.
WorldEdit 1.0 released

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

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Sep 26, 2012 02:55

used the spiral from RosettaCode in my skyblock game to determine the start positions for new players. i'll take a look at the code in WE and see if i can get it working.
 

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

by Temperest » Wed Sep 26, 2012 03:17

I replaced spirals with pyramids in the API, but I'm going to bed now so commits will be tomorrow.
WorldEdit 1.0 released

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

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Wed Sep 26, 2012 03:35

Image
Image
Last edited by cornernote on Wed Sep 26, 2012 03:50, edited 1 time in total.
 

Gage
Member
 
Posts: 45
Joined: Mon Sep 10, 2012 10:17

by Gage » Wed Sep 26, 2012 17:40

it wont work it says failed to load and run/init.lua
 

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

by Temperest » Wed Sep 26, 2012 22:42

Update:

  • cornernote fixed the //spiral command! Now you can make awesome mazes and similar things!
  • Added the //pyramid command, for making large solid pyramids.
  • Fixes to API documentation and some incorrect code.

Get it from the GitHub link!

Gage: I broke that accidentally yesterday, this new update should fix it.
WorldEdit 1.0 released

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

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Thu Sep 27, 2012 12:03

should transpose work? what is it supposed to do ?

when I did it, it just seemed to move parts of the area, basically screwed it up.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Thu Sep 27, 2012 12:04

can we add maze to worldedit?

if so, did you want me to add it in?

maze - http://minetest.net/forum/viewtopic.php?id=2814
 

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

by Temperest » Thu Sep 27, 2012 12:43

Transpose is broken as per issue #8, for non-square regions. I'll need to figure out a new algorithm for non-square matrix transposition soon.

Feel free to add the maze primitive, or anything else you find useful. Make sure the license is compatible first, though. The mazes are pretty cool and actually somewhat difficult.
WorldEdit 1.0 released

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

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Thu Sep 27, 2012 12:58

with all these shapes, the functions.lua is getting quite large. i propose we break all these functions into their own files, then in the main init.lua do this:

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
-- expose api
worldedit = {}

-- load api files
local path = minetest.get_modpath("worldedit")
local command = 'dir "'..path..'\\api\\*.lua" /b' -- windows
if os.getenv('home')~=nil then
    command = 'ls -a "'..path..'/api/*.lua"' -- linux/mac
end
for filename in io.popen(command):lines() do
    dofile(path..'/api/'..filename)
end


What are your thoughts?
 

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

by Temperest » Thu Sep 27, 2012 13:46

I agree that it is becoming pretty unwieldy. However, I'm thinking init.lua should not be a dependency of the actual API. As it stands, you can just copy functions.lua to your own mod and it would work by itself (with the exception of meta save and metaload, which I suggest should be folded into the API to avoid too many files). That is, init.lua simply contains the chat interface alone.

I'm thinking of splitting the API into parts: the primitives, such as pyramids, cylinders, and spheres; the node modification tools, such as set, replace, and dig; and the serialization stuff, such as save, load, meatspace, and metaload. Each module could be imported independently and individual modules would be removable without affecting others.
Last edited by Temperest on Thu Sep 27, 2012 13:47, edited 1 time in total.
WorldEdit 1.0 released

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

User avatar
jordan4ibanez
Member
 
Posts: 1865
Joined: Tue Sep 27, 2011 18:44
GitHub: jordan4ibanez
IRC: jordan4ibanez
In-game: jordan4ibanez

by jordan4ibanez » Sat Oct 06, 2012 22:47

This should use a for statement instead of a while statement, so that on a multiplayer server the whole thing does not freeze up when people are worldediting
If you can think it, you can make it.
 

Guest2
 

by Guest2 » Sun Oct 07, 2012 23:40

What about changing WorldEdit to a modpack, including submods for each function, a mod for the api, and a mod for the default worldedit interface?

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
mods/
 worldedit/
  worldedit_default/
   depends: worldedit_api
  worldedit_api/
   depends: worldedit_sphere, worldedit_cylinder, worldedit_set, etc.
  worldedit_cylinder/
  ... (etc.) ...
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Oct 08, 2012 01:49

jordan4ibanez wrote:This should use a for statement instead of a while statement, so that on a multiplayer server the whole thing does not freeze up when people are worldediting


I dont think it makes any difference which loop you use. The thread will do the loop until its done.

Perhaps a better way would be to only process X nodes per interval.

For example, when you //load a file, it should read the file into a TODO list, and then it should process 10 lines (and remove those 10 lines from the list). It should then use minetest.after(1,func) to create a callback that will run the next loop.
 

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

by Temperest » Mon Oct 08, 2012 03:23

Guest2: yes, I'm currently in the process of doing exactly that. It's coming along pretty nicely right now. The structure is a bit simpler though, with an API mod, a chat interface mod, and the future Multinode interface for those familiar with that mod.

cornernote: you mean processing the nodes in batches? That could definitely work, though what I think jordan4ibanez meant was that for loops are faster than while loops. Some research tells me that this seems to be true, so I will be investigating that pretty soon.

Offtopic: I've committed your T-FF changes cornernote, but I will need to wait until tomorrow or the day after to push.
WorldEdit 1.0 released

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

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Mon Oct 08, 2012 03:46

i don't think the speed of the loop impacts performance. Its only looping a few thousand times at most. to highlight this, run the loop, but comment out the code that adds the node.

I think the performance hit is when the node has to be added to the world (a few thousand nodes at once).
Last edited by cornernote on Mon Oct 08, 2012 03:46, edited 1 time in total.
 

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

by Temperest » Mon Oct 08, 2012 17:43

My tests indicate that for loops indeed have no noticable performance impact on the WorldEdit API. In fact, it seems a bit slower than the current one.

I guess that means we'll keep it the way it is, then.
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 » Sun Oct 14, 2012 01:53

Update:

  • Chat command interface has been split off of the main WorldEdit API. The WorldEdit API is in the "worldedit" mod, and the chat commands are in the "worldedit_commands" mod.
  • New visualization functions and commands: //hide, //suppress, //find, and //restore all work with nodes non-destructively, so you can peek inside your Mesecon monstrosity and find that one node you're looking for. Also accessible from the WorldEdit API! For maximum ease of use, metadata is supported right out of the box.
  • Everything is documented in relevant categories, and the WorldEdit API and chat commands get their own files.

Grab the latest version from the GitHub download! It's fully backwards compatible with the previous version, although external mods such as worldedit_gui may not be updated yet.
Last edited by Temperest on Sun Oct 14, 2012 02:01, edited 1 time in total.
WorldEdit 1.0 released

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

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Sun Oct 14, 2012 02:38

Nice! Are the Visualization commands the only new things? I assume no other API command syntax changed.
 

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

by Temperest » Sun Oct 14, 2012 03:11

Yep, the chat command interface is fully backwards compatible, while the API has been backwards compatible except for one early release that changed deserialization behavior along with the new WE file format.

I've given a shot at updating your worldedit_gui mod, but didn't have much luck. I might look into it more tomorrow.
WorldEdit 1.0 released

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

User avatar
Pythagoras
Member
 
Posts: 14
Joined: Mon Nov 05, 2012 00:29

by Pythagoras » Wed Nov 07, 2012 02:28

it may be a nice idea if someone could create some kind of schematics gallery where everyone can upload and get templates of different kind. this could be pretty much complementary to the primitives.

maybe i have some time to code that, but there could be a person with more time who is waiting for this very idea ;).
 

Comp52
Member
 
Posts: 56
Joined: Sun Oct 07, 2012 00:49

by Comp52 » Wed Nov 07, 2012 14:07

does anyone have the worldedit GUI? the thread doesn't have a working download link, and I really hate having to use chat commands so much.
 

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

by Temperest » Wed Nov 07, 2012 18:01

I'm working on rewriting it - in the future it will be included with WorldEdit itself. I've already obtained permission from cornernote to use inventory_plus in the mod pack.
WorldEdit 1.0 released

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

Smitje
Member
 
Posts: 22
Joined: Wed Nov 14, 2012 20:42

by Smitje » Wed Nov 14, 2012 21:36

O no rotate messed up my lovely tower.

//rotate y 90
Image

Image

It looks like random blocks were moved, blocks allso ended up completely outside the region i selected.
Dont worry about the tower I have a .we backup.

Is there anything I can do to help find out what was wrong?
(I have a backup of the world in its curent state if you want to analyse. I am afraid I did try to rotate back whitch made it worse)

I used ¨Uberi-MineTest-WorldEdit-426dfb0¨ downloaded today
Minetest version ¨minetestc55_201211041952-0~1730~precise1_amd64¨ but it says 0.4.3 on the screen in the game is that normal?

[EDIT] More experiments show the problem may be in the transpose function. I will attempt to sort it out. [END EDIT]

[EDIT 2]
hurrah! It apears there was a small error in the transpose function. I changed 1 line and now it works as expected for me. Please verrify that it now works as intended, and update.

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
--transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes, returning the number of nodes transposed
worldedit.transpose = function(pos1, pos2, axis1, axis2)
    local pos1, pos2 = worldedit.sort_pos(pos1, pos2)

    local pos = {x=pos1.x, y=0, z=0}
    local env = minetest.env
    while pos.x <= pos2.x do
        pos.y = pos1.y
        while pos.y <= pos2.y do
            pos.z = pos1.z
            while pos.z <= pos2.z do
                local extent1, extent2 = pos[axis1] - pos1[axis1], pos[axis2] - pos1[axis2]
                if extent1 < extent2 then
                    local node1 = env:get_node(pos)
                    local meta1 = env:get_meta(pos):to_table()
                    local value1, value2 = pos[axis1], pos[axis2]
                    pos[axis1], pos[axis2] = pos1[axis1] + extent2, pos1[axis2] + extent1 --This line changed
                    local node2 = env:get_node(pos)
                    local meta2 = env:get_meta(pos):to_table()
                    env:add_node(pos, node1)
                    env:get_meta(pos):from_table(meta1)
                    pos[axis1], pos[axis2] = value1, value2
                    env:add_node(pos, node2)
                    env:get_meta(pos):from_table(meta2)
                end
                pos.z = pos.z + 1
            end
            pos.y = pos.y + 1
        end
        pos.x = pos.x + 1
    end
    return worldedit.volume(pos1, pos2)
end


[END EDIT 2]

[EDIT 3]
There is still an isue left. transpose works if the selected area is square or longer in 1 direction but if it is longer in the other direction nothing happens
[END EDIT 3]



Cheers Smitje
Last edited by Smitje on Thu Nov 15, 2012 21:10, edited 1 time in total.
 

Smitje
Member
 
Posts: 22
Joined: Wed Nov 14, 2012 20:42

by Smitje » Fri Nov 16, 2012 20:24

Did some experiments.
I think the code below is correct now, however I am not sure the rotations still go in the right direction. As far as I can tell objects are not broken up any more no mater if the length or the width is larger.
only some minor changes to rotate and transpose are required (they are marked below)
please verify this works as intended before using it.

cheers Smitje


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
--transposes a region defined by the positions `pos1` and `pos2` between the `axis1` and `axis2` axes, returning the number of nodes transposed
worldedit.transpose = function(pos1, pos2, axis1, axis2)
    local pos1, pos2 = worldedit.sort_pos(pos1, pos2)
    if pos2[axis1]-pos1[axis1] >= pos2[axis2]-pos1[axis2] then --new
        largerOrSmaler = function(n1, n2) return n1 > n2 end    --new
    else                                                        --new
        largerOrSmaler = function(n1, n2) return n1 < n2 end    --new
    end                                                            --new
   

    local pos = {x=pos1.x, y=0, z=0}
    local env = minetest.env

    while pos.x <= pos2.x do
        pos.y = pos1.y
        while pos.y <= pos2.y do
            pos.z = pos1.z
            while pos.z <= pos2.z do
                local extent1, extent2 = pos[axis1] - pos1[axis1], pos[axis2] - pos1[axis2]
                if largerOrSmaler(extent1, extent2) then --changed
                    local node1 = env:get_node(pos)
                    local meta1 = env:get_meta(pos):to_table()
                    local value1, value2 = pos[axis1], pos[axis2]
                    pos[axis1], pos[axis2] = pos1[axis1] + extent2, pos1[axis2] + extent1 --This line changed
                    local node2 = env:get_node(pos)
                    local meta2 = env:get_meta(pos):to_table()
                    env:add_node(pos, node1)
                    env:get_meta(pos):from_table(meta1)
                    pos[axis1], pos[axis2] = value1, value2
                    env:add_node(pos, node2)
                    env:get_meta(pos):from_table(meta2)
                end
                pos.z = pos.z + 1
            end
            pos.y = pos.y + 1
        end
        pos.x = pos.x + 1
    end
    return worldedit.volume(pos1, pos2)
end



--rotates a region defined by the positions `pos1` and `pos2` by `angle` degrees clockwise around axis `axis` (90 degree increment), returning the number of nodes rotated
worldedit.rotate = function(pos1, pos2, axis, angle)
    local pos1, pos2 = worldedit.sort_pos(pos1, pos2)

    local axis1, axis2
    if axis == "x" then
        axis1, axis2 = "z", "y"
    elseif axis == "y" then
        axis1, axis2 = "x", "z"
    else --axis == "z"
        axis1, axis2 = "y", "x"
    end
    angle = angle % 360

    if angle == 90 then
        worldedit.flip(pos1, pos2, axis2)                --swapped
        worldedit.transpose(pos1, pos2, axis1, axis2)    --swapped
    elseif angle == 180 then
        worldedit.flip(pos1, pos2, axis1)
        worldedit.flip(pos1, pos2, axis2)
    elseif angle == 270 then
        worldedit.flip(pos1, pos2, axis1)                --swapped
        worldedit.transpose(pos1, pos2, axis1, axis2)    --swapped
    end
    return worldedit.volume(pos1, pos2)
end
 

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

by Temperest » Sat Dec 08, 2012 02:42

Hey Smitje, sorry about the delay in replying. my forum notifications apparently haven't been getting through for almost an entire month. And I was wondering why there was so little activity on the forums lately...

Anyways, this is a known issue (see here: https://github.com/Uberi/MineTest-WorldEdit/issues/8), I will try your solution out when I get to a computer. Thanks for testing.
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 Dec 13, 2012 02:18

Update:

  • Rotation and transposition fixed! Thanks Smitje!
  • Markers are now moved to new positions when rotating/transposing.
  • Small bugs fixed.
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 » Mon Jan 14, 2013 21:13

Update:

  • //replaceinverse command: replaces all nodes that are NOT a specific type of node. Also has corresponding function in WorldEdit API, worldedit.replaceinverse.
  • //orient command: rotates facedir and wallmounted nodes such as furnaces, stairs, torches, and etc. around the Y-axis. Also has corresponding function in WorldEdit API, worldedit.orient.
  • //lua command: runs arbitrary Lua code on the server, which can do literally anything Lua can. Also has corresponding function in WorldEdit API, worldedit.lua.
  • //luatransform command: runs arbitrary Lua code on the server for each node in the WorldEdit region. Also has corresponding function in WorldEdit API, worldedit.luatransform.
  • All Lua functions are sandboxed and errors will not crash MineTest. However, they do require the "server" privilege, since they can do things like read and modify files on the computer. Only give this privilege to people you trust.

All documentation is included with the download. See "Chat Commands.md" for a list of all commands, and "WorldEdit API.md" if you are developing against it.
WorldEdit 1.0 released

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

socramazibi
Member
 
Posts: 81
Joined: Mon Jan 28, 2013 12:29

by socramazibi » Sat Feb 02, 2013 10:37

Hey, so what's not, but I have not seen, in the world of minecraft edit, there is an option to copy cut and paste, could be implemented?

Good Mod

Thanks a Greeting
Forgive my English, but it is the translator of google.My Spanish.
My mod:
Pictures wool 1.0 3x5 , Charcoal+Textures , Map
 

PreviousNext

Return to Mod Releases

Who is online

Users browsing this forum: Bing [Bot] and 30 guests

cron