#rng system

1 messages · Page 1 of 1 (latest)

violet lily
#

hopefully you guys get the memo of what im trying to get at here

vagrant steeple
#

youre trying to loop thro a number

#

i assume you wanted to grab its value but not loop thro it

violet lily
#

yes

vagrant steeple
#

its just a number

violet lily
#

yeah ik i fixed it later on

#

i done a bit of changing but now im only getting uncommons and commons

#

im not good at math

#

to be coding this

vagrant steeple
violet lily
#

every folder within rarities has a chance attribute set to it, common is 90, mythic is 0.01

#

and the rest is self explanatory

violet lily
#

40

vagrant steeple
#

roll is 0-100

#

and common is 90, uncommon 40

#

so thats 130!

#

you cant ever get higher ones

violet lily
#

yikes..

#

fair enough, what do i do to fix it

#

as i said

#

im not good at math so i have no idea what to set the chances to

vagrant steeple
violet lily
#

i mostly used chatgpt and i regret doing that because i want to learn by myself; not by an ai bot

vagrant steeple
#

so sum all chances

#

then just randomize from 0 to sum

vagrant steeple
#

just do something like

  total = 0
  for _, chance in rarities do
  total += chance:GetAttribute("chance")
end

#

then roll from 0 to total

#

and then keep your previous code u had

violet lily
#

i noticed you didnt use ipairs

#

do i not need it?

violet lily
vagrant steeple
violet lily
#

oh

#

good to know

vagrant steeple
#

it really doesnt do anything

violet lily
#

fair enough

#

good to know aswell

vagrant steeple
#

look

violet lily
#

yes

#

im looking

vagrant steeple
# violet lily

go back to this rng logic
BUT do the chance fix so u dont loop over number

#

and

#

before that code in same function

#

SUM all the chances

#

so another for loop

vagrant steeple
#

then roll

violet lily
vagrant steeple
vagrant steeple
violet lily
#

have i done it now

#

this looks correct

rich thorn
violet lily
rich thorn
#

try it

vagrant steeple
vagrant steeple
#

youre using same variable for 2 things

#

use something like total or totalchancefor the first loop and inside math.random

#

or just reset the variable back to 0 after roll and before loop

violet lily
#

and it worked aswell

vagrant steeple
violet lily
#

i know its what i just said

vagrant steeple
#

it would bug out if you used same for SUM and then never reset it to 0 and use to to check what you rolled

vagrant steeple
violet lily
#

thank you for the help

violet lily
#

do you have any tips for coding

vagrant steeple
violet lily
#

for like remembering and like starting thinking logically more

violet lily
#

but i just stopped

#

also wkizi should i feel grief because im using chatgpt instead of learning by myself

rich thorn
#

@violet lily the more you code the more you get better