summaryrefslogtreecommitdiff
path: root/worldedit_gui
diff options
context:
space:
mode:
Diffstat (limited to 'worldedit_gui')
-rw-r--r--worldedit_gui/functionality.lua66
-rw-r--r--worldedit_gui/init.lua23
2 files changed, 76 insertions, 13 deletions
diff --git a/worldedit_gui/functionality.lua b/worldedit_gui/functionality.lua
index d3b78f6..7010b14 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)
@@ -313,6 +318,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)
@@ -373,6 +383,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)
@@ -395,6 +410,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)
@@ -441,13 +461,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]"
@@ -456,9 +486,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
@@ -483,6 +518,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,7 +545,12 @@ 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
+ 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
@@ -591,9 +641,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])
@@ -620,7 +670,7 @@ worldedit.register_gui_function("worldedit_gui_lua", {
worldedit.register_gui_handler("worldedit_gui_lua", function(name, fields)
if fields.worldedit_gui_lua_run or fields.worldedit_gui_lua_transform then
- gui_code[name] = fields.worldedit_gui_lua_value
+ gui_code[name] = fields.worldedit_gui_lua_code
worldedit.show_page(name, "worldedit_gui_lua")
if fields.worldedit_gui_lua_run then
minetest.chatcommands["/lua"].func(name, gui_code[name])
diff --git a/worldedit_gui/init.lua b/worldedit_gui/init.lua
index afd8c2c..57fd9a8 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
@@ -118,7 +118,7 @@ elseif inventory_plus then --inventory++ installed
return true
elseif fields.worldedit_gui_exit then --return to original page
if gui_player_formspecs[name] then
- inventory_plus.set_inventory_formspec(player, gui_player_formspecs[name])
+ inventory_plus.set_inventory_formspec(player, inventory_plus.get_formspec(player, "main"))
end
return true
end
@@ -143,8 +143,21 @@ 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 then --creative 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;]"
+ else
+ return
+ end
else
formspec = formspec .. "image_button[0,0;1,1;inventory_plus_worldedit_gui.png;worldedit_gui;]"
end