odd and even tested, stable

This commit is contained in:
VorTechnix 2021-06-22 14:02:56 -07:00
parent 99c0b26086
commit 7c92c811e5

View file

@ -68,12 +68,12 @@ worldedit.register_command("smake", {
end, end,
func = function(name, oper, mode, targ, base) func = function(name, oper, mode, targ, base)
local p1, p2, eval = vector.new(worldedit.pos1[name]), vector.new(worldedit.pos2[name]), function(int) return int or 0 end local p1, p2, eval = vector.new(worldedit.pos1[name]), vector.new(worldedit.pos2[name]), function(int) return int or 0 end
local delta, targ, _m = vector.subtract(p2,p1), wea.tocharset(targ), 0 -- local delta equation: Vd(a) = V2(a) - V1(a) local delta, _tl, targ, _m = vector.subtract(p2,p1), #targ, wea.tocharset(targ), 0 -- local delta equation: Vd(a) = V2(a) - V1(a)
-- set _m to the max, min or mean of the target axes depending on mode -- set _m to the max, min or mean of the target axes depending on mode (_tl is the length of targ)
if mode == "avg" then if mode == "avg" then
for k,v in pairs(targ) do _m = _m + math.abs(delta[k]) end for k,v in pairs(targ) do _m = _m + math.abs(delta[k]) end
_m = _m / #targ _m = _m / _tl
elseif mode == "grow" then elseif mode == "grow" then
for k,v in pairs(targ) do if math.abs(delta[k]) > _m then _m = math.abs(delta[k]) end end for k,v in pairs(targ) do if math.abs(delta[k]) > _m then _m = math.abs(delta[k]) end end
else else
@ -115,19 +115,21 @@ worldedit.register_command("smake", {
return false, "Case \"equal\" not handled." return false, "Case \"equal\" not handled."
end end
-- for k,v in pairs(targ) do delta[k] = eval(delta[k]) end
--- Test: --- Test:
if false then
local brk = "" local brk = ""
for k,v in pairs(targ) do for k,v in pairs(targ) do
brk = brk..k..": "..delta[k]..", " brk = brk..k..": "..delta[k]..", "
delta[k] = eval(delta[k]) delta[k] = eval(delta[k])
brk = brk..k..": "..delta[k]..", " brk = brk..k..": "..delta[k]..", "
end end
if true then return false, brk end return false, brk
end
-- //multi //fp set1 589 2 -82 //fp set2 615 2 -53 -- //multi //fp set1 589 2 -82 //fp set2 615 2 -53
-- //smake even shrink -- //smake even shrink
for k,v in pairs(targ) do delta[k] = eval(delta[k]) end
worldedit.pos2[name] = vector.add(p1,delta) worldedit.pos2[name] = vector.add(p1,delta)
worldedit.mark_pos2(name) worldedit.mark_pos2(name)
return true, "position 2 set to " .. minetest.pos_to_string(p2) return true, "position 2 set to " .. minetest.pos_to_string(p2)