Use builtin operator for modulus calculations

master
whats_his_face 2022-05-02 13:44:09 -05:00
parent e84d73dbdc
commit 6511554d19
4 changed files with 2 additions and 16 deletions

View File

@ -25,7 +25,6 @@ local function load_module(path)
end
dofile(path .. "/common.lua")
dofile(path .. "/moremath.lua")
load_module(path .. "/manipulations.lua")
load_module(path .. "/primitives.lua")
load_module(path .. "/visualization.lua")

View File

@ -75,7 +75,7 @@ function worldedit.add_param2(pos1, pos2, delta)
-- Add delta to every node
for i in area:iterp(pos1, pos2) do
new_p2 = math.mod(param2_data[i] + delta, 256)
new_p2 = (param2_data[i] + delta) % 256
if new_p2 < 0 then new_p2 = new_p2 + 256 end
param2_data[i] = new_p2
end

View File

@ -1,13 +0,0 @@
math.mod = function(value, m)
if value < 0 then
while value < -m do
value = value + m
end
elseif value > m then
while value > m do
value = value - m
end
end
return value
end

View File

@ -610,7 +610,7 @@ worldedit.register_command("pbrush", {
if found == nil then return false end
if steps ~= nil and steps ~= "" then
local count = math.mod(tonumber(steps), 8)
local count = tonumber(steps) % 8
delta = 32 * count
end
if sign == "-" then delta = -delta end