From 48f9c6c23fbfb81d2f071994acb7b33df47ea8b0 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Sun, 1 Nov 2015 16:50:36 -0500 Subject: [PATCH 01/11] Fix #93 (thanks @za267!) --- worldedit/primitives.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit/primitives.lua b/worldedit/primitives.lua index 6d3b026..303f51d 100644 --- a/worldedit/primitives.lua +++ b/worldedit/primitives.lua @@ -157,7 +157,7 @@ function worldedit.pyramid(pos, axis, height, node_name) -- Set up voxel manipulator local manip, area = mh.init_axis_radius(pos, axis, height >= 0 and height or -height) - local data = mh.get_empty_data() + local data = mh.get_empty_data(area) -- Handle inverted pyramids local start_axis, end_axis, step From 3d30588a68dd0a90ef65ef872b2e6878396eb2c8 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Fri, 18 Dec 2015 17:33:29 -0500 Subject: [PATCH 02/11] Clarify `//deleteblocks` --- ChatCommands.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChatCommands.md b/ChatCommands.md index 0c8b3a1..d3ed7db 100644 --- a/ChatCommands.md +++ b/ChatCommands.md @@ -100,7 +100,7 @@ Display the volume of the current WorldEdit region. ### `//deleteblocks` -Delete the MapBlocks (16x16x16 units) that contain the selected region. This means that mapgen will be invoked for that area. As only whole MapBlocks get removed, the deleted area is usually larger than the selected one. Also, mapgen can trigger mechanisms like mud reflow or cavegen, which affects nodes (up to 112 nodes away) outside the MapBlock, so dont use this near buildings. +Delete the MapBlocks (16x16x16 units) that contain the selected region. This means that mapgen will be invoked for that area. As only whole MapBlocks get removed, the deleted area is usually larger than the selected one. Also, mapgen can trigger mechanisms like mud reflow or cavegen, which affects nodes (up to 112 nodes away) outside the MapBlock, so dont use this near buildings. Note that active entities are not part of a MapBlock and do not get deleted. //deleteblocks From 3aa315f134bd8da41af9d21a7da5dea77005952f Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 5 Jan 2016 12:24:06 +0100 Subject: [PATCH 03/11] Fix Orient in WorldEdit GUI --- worldedit_gui/functionality.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua index 989c9eb..e812bf5 100644 --- a/worldedit_gui/functionality.lua +++ b/worldedit_gui/functionality.lua @@ -497,7 +497,7 @@ worldedit.register_gui_handler("worldedit_gui_orient", function(name, fields) if fields.worldedit_gui_orient_submit then gui_angle[name] = angle_indices[fields.worldedit_gui_orient_angle] worldedit.show_page(name, "worldedit_gui_orient") - minetest.chatcommands["/orient"].func(name, angle_values[gui_angle[name]]) + minetest.chatcommands["/orient"].func(name, tostring(angle_values[gui_angle[name]])) return true end return false From 51158eca9f28a95d4aae8dfe79996d710569f613 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 5 Jan 2016 12:42:01 +0100 Subject: [PATCH 04/11] Fix Save/Load from WorldEdit GUI, fixes #90 --- worldedit_gui/functionality.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua index e812bf5..c131612 100644 --- a/worldedit_gui/functionality.lua +++ b/worldedit_gui/functionality.lua @@ -588,9 +588,9 @@ worldedit.register_gui_function("worldedit_gui_save_load", { end, }) -worldedit.register_gui_handler("worldedit_gui_save", function(name, fields) - if fields.worldedit_gui_save_load_submit_save or worldedit_gui_save_load_submit_allocate or worldedit_gui_save_load_submit_load then - gui_filename[name] = tostring(fields.worldedit_gui_save_axis) +worldedit.register_gui_handler("worldedit_gui_save_load", function(name, fields) + if fields.worldedit_gui_save_load_submit_save or fields.worldedit_gui_save_load_submit_allocate or fields.worldedit_gui_save_load_submit_load then + gui_filename[name] = tostring(fields.worldedit_gui_save_filename) worldedit.show_page(name, "worldedit_gui_save_load") if fields.worldedit_gui_save_load_submit_save then minetest.chatcommands["/save"].func(name, gui_filename[name]) From 35b68c481b62e0bc39260578eb68dbcde6817eb4 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 5 Jan 2016 13:14:47 +0100 Subject: [PATCH 05/11] Fixed dropdown menus in the WorldEdit GUI (closes #78, thanks to @sponce) --- worldedit_gui/functionality.lua | 56 +++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua index c131612..c358a8c 100644 --- a/worldedit_gui/functionality.lua +++ b/worldedit_gui/functionality.lua @@ -280,6 +280,11 @@ worldedit.register_gui_handler("worldedit_gui_cylinder", function(name, fields) end return true end + if fields.worldedit_gui_cylinder_axis then + gui_axis1[name] = axis_indices[fields.worldedit_gui_cylinder_axis] + worldedit.show_page(name, "worldedit_gui_cylinder") + return true + end return false end) @@ -310,6 +315,11 @@ worldedit.register_gui_handler("worldedit_gui_pyramid", function(name, fields) end return true end + if fields.worldedit_gui_pyramid_axis then + gui_axis1[name] = axis_indices[fields.worldedit_gui_pyramid_axis] + worldedit.show_page(name, "worldedit_gui_pyramid") + return true + end return false end) @@ -370,6 +380,11 @@ worldedit.register_gui_handler("worldedit_gui_copy_move", function(name, fields) end return true end + if fields.worldedit_gui_copy_move_axis then + gui_axis1[name] = axis_indices[fields.worldedit_gui_copy_move_axis] or 4 + worldedit.show_page(name, "worldedit_gui_copy_move") + return true + end return false end) @@ -392,6 +407,11 @@ worldedit.register_gui_handler("worldedit_gui_stack", function(name, fields) minetest.chatcommands["/stack"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], gui_count1[name])) return true end + if fields.worldedit_gui_stack_axis then + gui_axis1[name] = axis_indices[fields.worldedit_gui_stack_axis] + worldedit.show_page(name, "worldedit_gui_stack") + return true + end return false end) @@ -438,13 +458,23 @@ worldedit.register_gui_handler("worldedit_gui_transpose", function(name, fields) minetest.chatcommands["/transpose"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], axis_values[gui_axis2[name]])) return true end + if fields.worldedit_gui_transpose_axis1 then + gui_axis1[name] = axis_indices[fields.worldedit_gui_transpose_axis1] + worldedit.show_page(name, "worldedit_gui_transpose") + return true + end + if fields.worldedit_gui_transpose_axis2 then + gui_axis2[name] = axis_indices[fields.worldedit_gui_transpose_axis2] + worldedit.show_page(name, "worldedit_gui_transpose") + return true + end return false end) worldedit.register_gui_function("worldedit_gui_flip", { name = "Flip", privs = minetest.chatcommands["/flip"].privs, get_formspec = function(name) - local axis = gui_axis2[name] + local axis = gui_axis1[name] return "size[5,3]" .. worldedit.get_formspec_header("worldedit_gui_flip") .. string.format("dropdown[0,1;2.5;worldedit_gui_flip_axis;X axis,Y axis,Z axis,Look direction;%d]", axis) .. "button_exit[0,2.5;3,0.8;worldedit_gui_flip_submit;Flip]" @@ -453,9 +483,14 @@ worldedit.register_gui_function("worldedit_gui_flip", { worldedit.register_gui_handler("worldedit_gui_flip", function(name, fields) if fields.worldedit_gui_flip_submit then - gui_axis2[name] = axis_indices[fields.worldedit_gui_flip_axis] + gui_axis1[name] = axis_indices[fields.worldedit_gui_flip_axis] + worldedit.show_page(name, "worldedit_gui_flip") + minetest.chatcommands["/flip"].func(name, axis_values[gui_axis1[name]]) + return true + end + if fields.worldedit_gui_flip_axis then + gui_axis1[name] = axis_indices[fields.worldedit_gui_flip_axis] worldedit.show_page(name, "worldedit_gui_flip") - minetest.chatcommands["/flip"].func(name, axis_values[gui_axis2[name]]) return true end return false @@ -480,6 +515,16 @@ worldedit.register_gui_handler("worldedit_gui_rotate", function(name, fields) minetest.chatcommands["/rotate"].func(name, string.format("%s %s", axis_values[gui_axis1[name]], angle_values[gui_angle[name]])) return true end + if fields.worldedit_gui_rotate_axis then + gui_axis1[name] = axis_indices[fields.worldedit_gui_rotate_axis] + worldedit.show_page(name, "worldedit_gui_rotate") + return true + end + if fields.worldedit_gui_rotate_angle then + gui_angle[name] = angle_indices[fields.worldedit_gui_rotate_angle] + worldedit.show_page(name, "worldedit_gui_rotate") + return true + end return false end) @@ -500,6 +545,11 @@ worldedit.register_gui_handler("worldedit_gui_orient", function(name, fields) minetest.chatcommands["/orient"].func(name, tostring(angle_values[gui_angle[name]])) return true end + if fields.worldedit_gui_orient_angle then + gui_angle[name] = angle_indices[fields.worldedit_gui_orient_angle] + worldedit.show_page(name, "worldedit_gui_orient") + return true + end return false end) From 7a19c5303bc5f39f4321143862d0f3ea244c323c Mon Sep 17 00:00:00 2001 From: Rui Date: Sun, 13 Sep 2015 12:54:18 +0900 Subject: [PATCH 06/11] Fix undeclared global variable --- worldedit_gui/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/worldedit_gui/init.lua b/worldedit_gui/init.lua index afd8c2c..da54f7b 100644 --- a/worldedit_gui/init.lua +++ b/worldedit_gui/init.lua @@ -67,7 +67,7 @@ local get_formspec = function(name, identifier) end --implement worldedit.show_page(name, page) in different ways depending on the available APIs -if unified_inventory then --unified inventory installed +if rawget(_G, "unified_inventory") then --unified inventory installed local old_func = worldedit.register_gui_function worldedit.register_gui_function = function(identifier, options) old_func(identifier, options) @@ -100,7 +100,7 @@ if unified_inventory then --unified inventory installed player:set_inventory_formspec(get_formspec(name, page)) end end -elseif inventory_plus then --inventory++ installed +elseif rawget(_G, "inventory_plus") then --inventory++ installed minetest.register_on_joinplayer(function(player) local can_worldedit = minetest.check_player_privs(player:get_player_name(), {worldedit=true}) if can_worldedit then From e0a26617002564db0c3d06f4f9e6d509b55b106c Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 5 Jan 2016 13:57:48 +0100 Subject: [PATCH 07/11] Fix //stack2 not working (closes #94) --- WorldEdit API.md | 6 ++++++ worldedit/manipulations.lua | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/WorldEdit API.md b/WorldEdit API.md index f50b506..7b99c8b 100644 --- a/WorldEdit API.md +++ b/WorldEdit API.md @@ -45,6 +45,12 @@ Copies the region defined by positions `pos1` and `pos2` along the `axis` axis ( Returns the number of nodes copied. +### count = worldedit.copy2(pos1, pos2, off) + +Copies the region defined by positions `pos1` and `pos2` by the offset vector `off`. + +Returns the number of nodes copied. + ### count = worldedit.move(pos1, pos2, axis, amount) Moves the region defined by positions `pos1` and `pos2` along the `axis` axis ("x" or "y" or "z") by `amount` nodes. diff --git a/worldedit/manipulations.lua b/worldedit/manipulations.lua index 365d7b3..cf95517 100644 --- a/worldedit/manipulations.lua +++ b/worldedit/manipulations.lua @@ -90,7 +90,7 @@ function worldedit.stack2(pos1, pos2, direction, amount, finished) translated.x = translated.x + direction.x translated.y = translated.y + direction.y translated.z = translated.z + direction.z - worldedit.copy2(pos1, pos2, translated, volume) + worldedit.copy2(pos1, pos2, translated) minetest.after(0, next_one) else if finished then @@ -164,6 +164,38 @@ function worldedit.copy(pos1, pos2, axis, amount) return worldedit.volume(pos1, pos2) end +--- Copies a region by offset vector `off`. +-- @param pos1 +-- @param pos2 +-- @param off +-- @return The number of nodes copied. +function worldedit.copy2(pos1, pos2, off) + local pos1, pos2 = worldedit.sort_pos(pos1, pos2) + + worldedit.keep_loaded(pos1, pos2) + + local get_node, get_meta, set_node = minetest.get_node, + minetest.get_meta, minetest.set_node + local pos = {} + pos.x = pos2.x + while pos.x >= pos1.x do + pos.y = pos2.y + while pos.y >= pos1.y do + pos.z = pos2.z + while pos.z >= pos1.z do + local node = get_node(pos) -- Obtain current node + local meta = get_meta(pos):to_table() -- Get meta of current node + local newpos = vector.add(pos, off) -- Calculate new position + set_node(newpos, node) -- Copy node to new position + get_meta(newpos):from_table(meta) -- Set metadata of new node + pos.z = pos.z - 1 + end + pos.y = pos.y - 1 + end + pos.x = pos.x - 1 + end + return worldedit.volume(pos1, pos2) +end --- Moves a region along `axis` by `amount` nodes. -- @return The number of nodes moved. From 2e2fcfdfa2f5f9b15951d6f149c3c1d72bedf1a6 Mon Sep 17 00:00:00 2001 From: Sebastien Ponce Date: Mon, 14 Sep 2015 22:09:36 +0200 Subject: [PATCH 08/11] Fixed Issue #83 : upsidedown pyramid not working well --- worldedit/primitives.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worldedit/primitives.lua b/worldedit/primitives.lua index 303f51d..962a02f 100644 --- a/worldedit/primitives.lua +++ b/worldedit/primitives.lua @@ -177,7 +177,7 @@ function worldedit.pyramid(pos, axis, height, node_name) y = pos.y - area.MinEdge.y, z = pos.z - area.MinEdge.z, } - local size = height * step + local size = math.abs(height * step) local count = 0 -- For each level of the pyramid for index1 = 0, height, step do From e9e8de385c8810e8dd50d7af37bea32cb77b829d Mon Sep 17 00:00:00 2001 From: kilbith Date: Sun, 17 Jan 2016 15:17:44 +0100 Subject: [PATCH 09/11] Adapt WorldEdit GUI button to the new creative inventory --- worldedit_gui/init.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/worldedit_gui/init.lua b/worldedit_gui/init.lua index da54f7b..c0a1d8f 100644 --- a/worldedit_gui/init.lua +++ b/worldedit_gui/init.lua @@ -143,8 +143,19 @@ else --fallback button if not player then --this is in case the player signs off while the media is loading return end - if (minetest.check_player_privs(name, {creative=true}) or minetest.setting_getbool("creative_mode")) and creative_inventory then --creative_inventory is active, add button to modified formspec - formspec = player:get_inventory_formspec() .. "image_button[6,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" + if (minetest.check_player_privs(name, {creative=true}) or + minetest.setting_getbool("creative_mode")) and + creative_inventory then --creative_inventory is active, add button to modified formspec + local creative_formspec = player:get_inventory_formspec() + local tab_id = tonumber(creative_formspec:match("tabheader%[.*;(%d)%;.*%]")) + + if tab_id == 1 then + formspec = creative_formspec .. + "image_button[0,1;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" + elseif not tab_id then + formspec = creative_formspec .. + "image_button[6,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" + end else formspec = formspec .. "image_button[0,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]" end From 47712844a3f2551aedfa9e39cc3a8cc06e01993e Mon Sep 17 00:00:00 2001 From: Joseph Pickard Date: Sun, 17 Jan 2016 13:27:33 -0500 Subject: [PATCH 10/11] Added a WorldEdit wand item that can be used to select areas with worldedit. --- worldedit/init.lua | 1 + worldedit/textures/worldedit_wand.png | Bin 0 -> 442 bytes worldedit/wand.lua | 51 ++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 worldedit/textures/worldedit_wand.png create mode 100644 worldedit/wand.lua diff --git a/worldedit/init.lua b/worldedit/init.lua index e193454..ec6e99d 100644 --- a/worldedit/init.lua +++ b/worldedit/init.lua @@ -36,6 +36,7 @@ load_module(path .. "/visualization.lua") load_module(path .. "/serialization.lua") load_module(path .. "/code.lua") load_module(path .. "/compatibility.lua") +load_module(path .. "/wand.lua") if minetest.setting_getbool("log_mods") then diff --git a/worldedit/textures/worldedit_wand.png b/worldedit/textures/worldedit_wand.png new file mode 100644 index 0000000000000000000000000000000000000000..13eb12189cb19a680229526a474f38f932300ab1 GIT binary patch literal 442 zcmV;r0Y(0aP)YX~D;^6zhY%lq+t9~~3e-UnQMy0G(L5CoCbLBh== z5DNIw3X)cJp+6FWexczo(!-(xV*dHr8*{Uf%fUJ@g7q`K=_*qFSkw$sgJBr=*Vvy8 zuyBGp@o_hoig{RlLBvn4NLT;>YtaC^q!P$t!^+Vu2@3!qHqph3MTY70B9_X~zZ*1? zIDaM6>4p6Egzf2G78U?NER`XfqZ5^40rB}T3kv{X=|Cs5!w2=NfQ`v+ZhC`8wx+yn zl?gAkb|lkT5*7f!a&(A2ZDqXIOl+P$Q&ScGl1yhQU#UW|%UGQoX5j?C<1UQyhj9nL kM{P|20J}2^J8ETo0~vOCmI$`c0000007*qoM6N<$f^)O3761SM literal 0 HcmV?d00001 diff --git a/worldedit/wand.lua b/worldedit/wand.lua new file mode 100644 index 0000000..415e7ca --- /dev/null +++ b/worldedit/wand.lua @@ -0,0 +1,51 @@ +minetest.register_tool("worldedit:wand", { + description = "WorldEdit wand tool. Left-click to set the 1st position, Right-click to set the 2nd position.", + groups = {}, + inventory_image = "worldedit_wand.png", + wield_image = "", + wield_scale = {x=1,y=1,z=1}, + stack_max = 1, -- there is no need to have more than one + liquids_pointable = true, -- ground with only water on can be selected as well + -- the tool_capabilities are completely irrelevant here - no need to dig + tool_capabilities = { + full_punch_interval = 1.0, + max_drop_level=0, + groupcaps={ + fleshy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, + snappy={times={[2]=0.80, [3]=0.40}, maxwear=0.05, maxlevel=1}, + choppy={times={[3]=0.90}, maxwear=0.05, maxlevel=0} + } + }, + node_placement_prediction = nil, + + on_use = function(itemstack, placer, pointed_thing) + if placer ~= nil and pointed_thing ~= nil then + local name = placer:get_player_name() + local pos = minetest.get_pointed_thing_position( pointed_thing, false ) -- not above + + if not pos then + return itemstack + end + + worldedit.pos1[name] = pos + worldedit.mark_pos1(name) + + end + return itemstack -- nothing consumed, nothing changed + end, + + on_place = function(itemstack, placer, pointed_thing) -- Left Click + if placer ~= nil and pointed_thing ~= nil then + local name = placer:get_player_name() + local pos = minetest.get_pointed_thing_position( pointed_thing, false ) -- not above + + if not pos then + return itemstack + end + + worldedit.pos2[name] = pos + worldedit.mark_pos2(name) + end + return itemstack -- nothing consumed, nothing changed + end, +}) From f2f714c19e18ede9b3e201b2a5b6bf9828a5dd8d Mon Sep 17 00:00:00 2001 From: ShadowNinja Date: Sat, 23 Jan 2016 16:57:00 -0500 Subject: [PATCH 11/11] Fix crash when loading version 3 schematics --- worldedit/serialization.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worldedit/serialization.lua b/worldedit/serialization.lua index 00d984d..a0848e2 100644 --- a/worldedit/serialization.lua +++ b/worldedit/serialization.lua @@ -144,9 +144,9 @@ local function load_schematic(value) "([^%s]+)%s+(%d+)%s+(%d+)[^\r\n]*[\r\n]*") do param1, param2 = tonumber(param1), tonumber(param2) table.insert(nodes, { - x = originx + tonumber(x), - y = originy + tonumber(y), - z = originz + tonumber(z), + x = tonumber(x), + y = tonumber(y), + z = tonumber(z), name = name, param1 = param1 ~= 0 and param1 or nil, param2 = param2 ~= 0 and param2 or nil,