Calling Random Numbers
#3
If you had read the RPGm XP help manual you would have known that rand(n) function can do exactly what you want. Well almost. Winking

And VVulfy, that is a little too much computational overhead for my tastes (and I've never seen a die numbered 0 to sides-1). I'd do it like this:

Code:
module Roll
    #--------------------------------------------------------------------------
    # d - simulates a dice roll (num: 1 to sides)
    #    *sides : how many sides the dice has
    #---------------------------------------------------------------------------
    def d(sides)
        return rand(sides)+1
    end
end

Then rolls are just:
Code:
strength_roll = Roll.d(20)
Reply }


Messages In This Thread
Calling Random Numbers - by Alistor - 09-06-2013, 07:46 PM
RE: Calling Random Numbers - by DerVVulfman - 09-07-2013, 03:14 AM
RE: Calling Random Numbers - by MechanicalPen - 09-07-2013, 06:09 PM
RE: Calling Random Numbers - by DerVVulfman - 09-08-2013, 12:27 AM
RE: Calling Random Numbers - by MechanicalPen - 09-08-2013, 01:02 AM
RE: Calling Random Numbers - by DerVVulfman - 09-08-2013, 03:09 AM
RE: Calling Random Numbers - by MechanicalPen - 09-08-2013, 06:16 PM
RE: Calling Random Numbers - by DerVVulfman - 09-08-2013, 08:41 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Making Forest Maps with the Random Map Generator ShadowIce 16 22,017 02-02-2014, 08:18 PM
Last Post: ShadowIce
   Help Making Random Maps ShadowIce 0 3,264 02-02-2010, 03:28 PM
Last Post: ShadowIce
   Calling Scripts aistinger 3 5,906 12-03-2009, 01:41 AM
Last Post: aistinger
   Random Monster Groups Yin 25 31,111 08-18-2009, 06:04 AM
Last Post: DerVVulfman



Users browsing this thread: 1 Guest(s)