indentation fixes

This commit is contained in:
VorTechnix 2021-02-24 19:35:20 -08:00
parent 1d93122801
commit f6ed297270
4 changed files with 38 additions and 37 deletions

View file

@ -7,14 +7,14 @@ worldedit.register_command("basename", {
params = "<nodealias>", params = "<nodealias>",
description = "Returns the base name of nodes that use a given alias.", description = "Returns the base name of nodes that use a given alias.",
privs = {worldedit = true}, privs = {worldedit = true},
parse = function(params_text) parse = function(params_text)
if params_text == "" or not params_text then if params_text == "" or not params_text then
return false, "Node not specified." return false, "Node not specified."
end end
return true, params_text return true, params_text
end, end,
func = function(name, params_text) func = function(name, params_text)
if name == nil then return end if name == nil then return end
worldedit.player_notify(name, worldedit.normalize_nodename(params_text) or 'Error 404: "'..params_text..'" not found!') worldedit.player_notify(name, worldedit.normalize_nodename(params_text) or 'Error 404: "'..params_text..'" not found!')
end end
}) })

View file

@ -4,42 +4,42 @@
-- ██ ██ ██ ██ ██ ██ -- ██ ██ ██ ██ ██ ██
-- ███████ ██ ██ ███████ ██████ ██ -- ███████ ██ ██ ███████ ██████ ██
-- lua parse_params_srect("10") -- lua parse_params_srect("10")
-- local -- local -- TODO: set this to local once development is finished
function parse_params_srect(params_text) function parse_params_srect(params_text)
local find, _, sn1, ax1, sn2, ax2, len = params_text:find("([+-]?)([xyz]?)%s*([+-]?)([xyz]?)%s*(%d*)") local find, _, sn1, ax1, sn2, ax2, len = params_text:find("([+-]?)([xyz]?)%s*([+-]?)([xyz]?)%s*(%d*)")
-- If ax1 is nil set to player facing dir -- If ax1 is nil set to player facing dir
if ax1 == "" then ax1 = "get" if ax1 == "" then ax1 = "get"
else ax1 = {tonumber(sn1..1),string.lower(ax1)} else ax1 = {tonumber(sn1..1),string.lower(ax1)}
end end
-- If ax2 is nil set to +y -- If ax2 is nil set to +y
if ax2 == "" then ax2 = "y" end if ax2 == "" then ax2 = "y" end
ax2 = {tonumber(sn2..1),string.lower(ax2)} ax2 = {tonumber(sn2..1),string.lower(ax2)}
len = tonumber(len) len = tonumber(len)
if len == nil then if len == nil then
return false, "No length specified." return false, "No length specified."
end end
return true, ax1, ax2, len return true, ax1, ax2, len
end end
worldedit.register_command("srect", { worldedit.register_command("srect", {
params = "[<axis1> [<axis2>]] <length>", params = "[<axis1> [<axis2>]] <length>",
description = "Set WorldEdit region position 2 at a set distance along 2 axes.", description = "Set WorldEdit region position 2 at a set distance along 2 axes.",
privs = {worldedit=true}, privs = {worldedit=true},
require_pos = 1, require_pos = 1,
parse = function(params_text) parse = function(params_text)
local values = {parse_params_srect(params_text)} local values = {parse_params_srect(params_text)}
return unpack(values) return unpack(values)
end, end,
func = function(name, axis1, axis2, len) func = function(name, axis1, axis2, len)
if axis1 == "get" then axis1 = worldeditadditions.player_axis2d(name) end if axis1 == "get" then axis1 = worldeditadditions.player_axis2d(name) end
local pos1 = worldedit.pos1[name] local pos1 = worldedit.pos1[name]
local p2 = {["x"] = pos1.x,["y"] = pos1.y,["z"] = pos1.z} local p2 = {["x"] = pos1.x,["y"] = pos1.y,["z"] = pos1.z}
p2[axis1[2]] = p2[axis1[2]] + tonumber(len) * axis1[1] p2[axis1[2]] = p2[axis1[2]] + tonumber(len) * axis1[1]
p2[axis2[2]] = p2[axis2[2]] + tonumber(len) * axis2[1] p2[axis2[2]] = p2[axis2[2]] + tonumber(len) * axis2[1]
worldedit.pos2[name] = p2 worldedit.pos2[name] = p2
worldedit.mark_pos2(name) worldedit.mark_pos2(name)
@ -49,3 +49,4 @@ worldedit.register_command("srect", {
-- Tests -- Tests
-- params_text = "-x z 13" -- params_text = "-x z 13"
-- params_text = "-x a 13"