diff --git a/worldeditadditions_commands/commands/measure/init.lua b/worldeditadditions_commands/commands/measure/init.lua new file mode 100644 index 0000000..e8ce9c9 --- /dev/null +++ b/worldeditadditions_commands/commands/measure/init.lua @@ -0,0 +1,11 @@ +-- ███ ███ ███████ █████ ███████ ██ ██ ██████ ███████ +-- ████ ████ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ████ ██ █████ ███████ ███████ ██ ██ ██████ █████ +-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ███████ ██ ██ ███████ ██████ ██ ██ ███████ + +-- Chat commands that measure things. + +local we_cm = worldeditadditions_commands.modpath .. "/commands/measure/" + +dofile(we_cm.."mface.lua") diff --git a/worldeditadditions_commands/commands/measure/mface.lua b/worldeditadditions_commands/commands/measure/mface.lua new file mode 100644 index 0000000..53249e6 --- /dev/null +++ b/worldeditadditions_commands/commands/measure/mface.lua @@ -0,0 +1,37 @@ +-- ███ ███ ███████ █████ ██████ ███████ +-- ████ ████ ██ ██ ██ ██ ██ +-- ██ ████ ██ █████ ███████ ██ █████ +-- ██ ██ ██ ██ ██ ██ ██ ██ +-- ██ ██ ██ ██ ██ ██████ ███████ +local wea = worldeditadditions +worldedit.register_command("mface", { + params = "", + description = "Return player facing axis.", + privs = { worldedit = true }, + require_pos = 0, + parse = function(params_text) + return true + end, + func = function(name, params_text) + local str = "You are facing " + local dir = minetest.get_player_by_name(name):get_look_dir() + + if math.abs(dir.z) > math.abs(dir.x) then + if dir.z < 0 then str = str.."-Z" + else str = str.."Z" end + if math.abs(dir.x) >= 0.35 then -- Alternate value: 1/3 + if dir.x < 0 then str = str.."-X" + else str = str.."X" end + end + else + if dir.x < 0 then str = str.."-X" + else str = str.."X" end + if math.abs(dir.z) >= 0.35 then -- Alternate value: 1/3 + if dir.z < 0 then str = str.."-Z" + else str = str.."Z" end + end + end + + return true, str + end, +}) diff --git a/worldeditadditions_commands/init.lua b/worldeditadditions_commands/init.lua index f435b8c..d99c26e 100644 --- a/worldeditadditions_commands/init.lua +++ b/worldeditadditions_commands/init.lua @@ -44,6 +44,9 @@ dofile(we_c.modpath.."/commands/meta/ellipsoidapply.lua") -- Selection Tools dofile(we_c.modpath.."/commands/selectors/init.lua") +-- Measure Tools +dofile(we_c.modpath.."/commands/measure/init.lua") + dofile(we_c.modpath.."/commands/extra/saplingaliases.lua") dofile(we_c.modpath.."/commands/extra/basename.lua") @@ -76,6 +79,9 @@ worldedit.alias_command("naturalize", "layers") worldedit.alias_command("flora", "bonemeal") -worldedit.alias_command("mcount", "count") - +-- Selection Tools worldedit.alias_command("sfac", "sfactor") + +-- Measure Tools +worldedit.alias_command("mcount", "count") +worldedit.alias_command("mfacing", "mface")