add wea_c.range(min, max, step)

This commit is contained in:
Starbeamrainbowlabs 2023-01-21 01:32:17 +00:00
parent 42fb6571da
commit 66227153d0
Signed by: sbrl
GPG key ID: 1BE5172E637709C2

View file

@ -106,6 +106,25 @@ function wea_c.clamp(value, min, max)
return value return value
end end
--- Return a sequence of numbers as a list.
-- @example
-- local result = worldeditadditions_core.range(0, 10, 1)
-- -- [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]
-- @example
-- local result = worldeditadditions_core.range(6, 12, 2)
-- -- [ 6, 8, 10, 12 ]
-- @param min number The minimum value in the sequence.
-- @param max number The maximum value in the sequence.
-- @param step number The value to increment between each value in the sequence.
-- @returns number[] The list of numbers.
function wea_c.range(min, max, step)
local result = {}
for i = min, max, step do
table.insert(result, i)
end
return result
end
-- For Testing: -- For Testing:
-- wea_c = {} -- wea_c = {}
-- print(wea_c.getsign('-y')) -- print(wea_c.getsign('-y'))