Need help with math.random (code to stop it)

Heyho

Basically, what I am doing, is a random character generator for our Pen & Paper group.

I have 8 different Stats; MU, KL, IN, CH, FF, GE, KO, KK

Each of them can have a value from 8 to 14, while only one of them can be 15.

What I have so far is: 

repeat

    mu = 7+(math.random(8))

    kl = 7+(math.random(8))

    int = 7+(math.random(8))

    ch = 7+(math.random(8))

    ff = 7+(math.random(8))

    ge = 7+(math.random(8))

    ko = 7+(math.random(8))

    kk = 7+(math.random(8))

    

  until mu == 15 and kl < 15 and int < 15 and ch < 15 and ff < 15 and ge < 15 and ko < 15 and kk < 15 or

  mu < 15 and kl == 15 and int < 15 and ch < 15 and ff < 15 and ge < 15 and ko < 15 and kk < 15 or

  mu < 15 and kl < 15 and int == 15 and ch < 15 and ff < 15 and ge < 15 and ko < 15 and kk < 15 or

  mu < 15 and kl < 15 and int < 15 and ch == 15 and ff < 15 and ge < 15 and ko < 15 and kk < 15 or

  mu < 15 and kl < 15 and int < 15 and ch < 15 and ff == 15 and ge < 15 and ko < 15 and kk < 15 or 

  mu < 15 and kl < 15 and int < 15 and ch < 15 and ff < 15 and ge == 15 and ko < 15 and kk < 15 or

  mu < 15 and kl < 15 and int < 15 and ch < 15 and ff < 15 and ge < 15 and ko == 15 and kk < 15 or

  mu < 15 and kl < 15 and int < 15 and ch == 15 and ff < 15 and ge < 15 and ko < 15 and kk == 15

  

This seems … like there could be a better way :stuck_out_tongue:

So my question is if you got any better ideas how to handle this? Something with less walls of text :wink:

I would do this like that:

 math.randomseed( os.time() ) &nbsp; &nbsp; local mRand = math.random &nbsp; &nbsp; local statsNum = 8 &nbsp; &nbsp; local randomValues = {} &nbsp; &nbsp; for i=1, statsNum do &nbsp; &nbsp; &nbsp; randomValues[#randomValues + 1] = mRand( 8, 14 ) &nbsp; &nbsp; end &nbsp; &nbsp; randomValues[mRand( statsNum )] = 15 &nbsp; &nbsp; --for i=1, statsNum do &nbsp; &nbsp; -- print( randomValues[i] ) &nbsp; &nbsp; --end &nbsp; &nbsp; local mu, kl, int, ch, ff, ge, ko, kk = unpack( randomValues ) &nbsp; &nbsp; --print( mu, kl, int, ch, ff, ge, ko, kk )

I would do this like that:

 math.randomseed( os.time() ) &nbsp; &nbsp; local mRand = math.random &nbsp; &nbsp; local statsNum = 8 &nbsp; &nbsp; local randomValues = {} &nbsp; &nbsp; for i=1, statsNum do &nbsp; &nbsp; &nbsp; randomValues[#randomValues + 1] = mRand( 8, 14 ) &nbsp; &nbsp; end &nbsp; &nbsp; randomValues[mRand( statsNum )] = 15 &nbsp; &nbsp; --for i=1, statsNum do &nbsp; &nbsp; -- print( randomValues[i] ) &nbsp; &nbsp; --end &nbsp; &nbsp; local mu, kl, int, ch, ff, ge, ko, kk = unpack( randomValues ) &nbsp; &nbsp; --print( mu, kl, int, ch, ff, ge, ko, kk )