Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Weight system (Will make a C# one soon too!)
-- Loot Box System Code -- -- Random item generator -- -- Weight system -- -- Simple -- -- Tags ^^ -- Made by Ice Scripter -- local items = { {"Coins", 85}, {"Diamonds", 10}, {"Legendary item", 5} } local total_weight = 0 for _, data in pairs (items) do total_weight = total_weight + data[2] end for i = 0, 100 do -- Test with higher numbers to get more accurate results -- Get weighted item for _, data in pairs (items) do if math.random(total_weight) <= data[2] then print(data[1]) end end end
run
|
edit
|
history
|
help
0
personal use
PAID HACK PuBG
Map generator
python like round function in lua
Random numbers in Lua. Range: 1-49. Sets of numbers without duplicates
Creating habits. Lua
Relative Angles
Truly random numbers (Lua)
PAID HACK PuBG
kraft1c