#rng

1 messages · Page 1 of 1 (latest)

modest spade
#

how do people generally code rng for like gacha pulls?

spring geyser
#

and they prolly have a table of a bounch of random items

modest spade
snow portal
fiery obsidianBOT
#

studio** You are now Level 26! **studio

snow portal
#

Percentage based or weighted

modest spade
#

im doing weighted rn is percentage based better? i see games use them more

worn niche
modest spade
worn niche
modest spade
worn niche
limber gull
#

For a weighted one I did smth like this

local table = {}

local function add(string, times)
for i = 1 times do
table.insert(table,string)
end
end
-- then add your things
add("rock",10)
add("dirt",5)

local function choose()
print(table[math.random(1,#table)])
end
choose()
fiery obsidianBOT
#

studio** You are now Level 10! **studio

limber gull
#

Finally!

worn niche
#

I tested it by having it choose many many times, and the percentages equaled the weight it was given, so I trust this.

I found this solution somewhere online at some point, but I used the code to make this class.

trail cipher
#

you can always use random.new

#

instead of math.random

#

it would just be Random.New():NextInteger(1,#table) instead of math.random(1,#table) i think

modest spade
#

moon tuner looks pretty nice ill trust that it works

modest spade
worn niche
modest spade
worn niche
#

It's been a while since I looked at it more fully so it could be really stupid, I just know when I used it, it worked well lol

modest spade
#

@worn niche when u used this did u implement a pity system outside? or your rolls had no pity system

fiery obsidianBOT
#

studio** You are now Level 8! **studio

worn niche
modest spade