Useful random-related utilities for Luau
local dict = {
a = {
name = "Alpha",
weight = 0.1,
},
b = {
name = "Beta",
weight = 0.2,
},
c = {
name = "Charlie",
weight = 0.3,
}
} :: {
[string]: {
name: string,
weight: number
}
}
local choose = rng.weightedKey(dict, function(_, v)
return v.weight
end)
via pesde
pesde add caveful_games/rng
This library is zero-dependency so this can be used as git submodule too
git submodule add https://github.com/CavefulGames/luau-rng.git submodules/rng
- Make docs from moonwave comments
- Chance.js - Inspiration and Implementation of
rng.weighted