antiblock
Cyphriun
  • Chatbox

    You don't have permission to chat.
    Load More
  • 0
Sign in to follow this  
.ukitobi

Função - Dúvida

Question

Olá estou com uma pequena dúvida que gostava que me esclarecessem.

Pretendo com a função seguinte haver 50% de probabilidade de acontecer x, 25% de acontecer y, 15% de acontecer z e ainda 10% de acontecer b.

local a = math.random(1,100)



if a <= 50 then

x

elseif a > 50 and a <= 75 then

y

elseif a > 75 and a <= 90 then

z

elseif a > 90 and a <= 100 then

b

Usando esta estrutura consigo as probabilidades que queria?

Obrigado desde já

Share this post


Link to post
Share on other sites

3 answers to this question

  • 0

Deverá funcionar, o math.random(1,100) dá-te um numero entre 1 e 100, inclusive, portanto pela tua lógica terás 50% de probabilidade de X, 25% de Y, 15% de Z e 10% de B.

Share this post


Link to post
Share on other sites
antiblock
Rodnia | Alpha & Omega
  • 0
4 minutes ago, Cσяvσ⋆ said:

Deverá funcionar, o math.random(1,100) dá-te um numero entre 1 e 100, inclusive, portanto pela tua lógica terás 50% de probabilidade de X, 25% de Y, 15% de Z e 10% de B.

Era só para confirmar, já não mexo nisto há algum tempo. 

Obrigado, podem fechar.

Share this post


Link to post
Share on other sites
  • 0

Tópico fechado a pedido da autora ! 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this