mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-25 03:51:05 +01:00
15 lines
420 B
Lua
15 lines
420 B
Lua
mcl_numbers.register_provider = mcl_util.registration_function(mcl_numbers.providers)
|
|
|
|
function mcl_numbers.get_number(provider, data)
|
|
local t = type(provider)
|
|
if t == "nil" then
|
|
return 0
|
|
elseif t == "number" then
|
|
return provider
|
|
elseif t == "table" then
|
|
local func = assert(mcl_numbers.providers[data.type])
|
|
return assert(tonumber(func(provider, data)))
|
|
else
|
|
error("invalid number type: " .. t)
|
|
end
|
|
end
|