Skip to content

CavefulGames/luau-rng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Useful random-related utilities for Luau

Example Usage

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)

Installation

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

TO-DOs

  • Make docs from moonwave comments

Credits

  • Chance.js - Inspiration and Implementation of rng.weighted

About

Useful random-related utilities for Luau

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages