Run Code
|
API
|
Code Wall
|
Users
|
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
Please
log in
to post a comment.
ok
PAID HACK PuBG
test123
123
Surface Area of things (Incomplete)
Monty Hall Problem Simulated
quick sort
cumulative probability
gdgdf
BasicTablePrinter
Please log in to post a comment.