VoxeLibre/mods/DATA/mcl_numbers/init.lua

26 lines
689 B
Lua
Raw Normal View History

mcl_numbers = {
providers = {},
}
2021-03-16 08:40:37 +01:00
dofile(minetest.get_modpath("mcl_numbers") .. "/api.lua")
mcl_numbers.register_provider("mcl_numbers:constant", function(provider)
return provider.value
end)
mcl_numbers.register_provider("mcl_numbers:uniform", function(provider, data)
2021-03-11 10:05:46 +01:00
return mcl_util.rand(data.pr, mcl_numbers.get_number(provider.min, data), mcl_numbers.get_number(provider.max, data))
end)
mcl_numbers.register_provider("mcl_numbers:binomial", function(provider, data)
2021-03-11 10:05:46 +01:00
local n = mcl_numbers.get_number(provider.n, data)
local num = 0
for i = 1, n do
2021-03-11 10:05:46 +01:00
if mcl_util.rand_bool(mcl_numbers.get_number(provider.p, data), data.pr) then
num = num + 1
end
end
return num
end)
2021-03-16 08:40:37 +01:00