Register to post in forums, or Log in to your existing account
 

 Related 
Contents
Miscelaneous
  %ansi
  %clip
  %color
  %colorname
  %exec
  %expand
  %gsl
  %literal
  %mcp
  %mss
  %null
  %numparam
  %param
  %time
Function Reference
  %abs
  %additem
  %addkey
  %alarm
  %alias
  %ansi
  %array
  %arrget
  %arrhigh
  %arrset
  %ascii
  %average
  %begins
  %bitand
  %bitnot
  %bitor
  %bitxor
  %btncol
  %btnenable
  %btnimage
  %case
  %char
  %charcomment
  %charnotes
  %class
  %clip
  %color
  %colorname
  %comactive
  %comcreate
  %comget
  %comset
  %concat
  %copy
  %count
  %countlist
  %crtonl
  %db
  %dbget
  %dblist
  %dbmax
  %dbmin
  %dde
  %ddeclose
  %ddemacro
  %ddeopen
  %ddepoke
  %defined
  %delete
  %delitem
  %delkey
  %delnitem
  %destroom
  %dice
  %diceavg
  %dicedev
  %dicemax
  %dicemin
  %doorname
  %dups
  %ends
  %eval
  %exec
  %expand
  %expanddb
  %expandlist
  %filesize
  %find
  %float
  %format
  %getglobal
  %grep
  %gsl
  %handle
  %if
  %insert
  %int
  %inwalk
  %isfloat
  %iskey
  %ismember
  %isnumber
  %item
  %lastdir
  %left
  %leftback
  %len
  %literal
  %look
  %lower
  %match
  %mapfilter
  %maplocked
  %mapquery
  %mapvnum
  %max
  %mcp
  %min
  %mod
  %mss
  %nextdir
  %nltocr
  %norm
  %null
  %number
  %numbuttons
  %numitems
  %numkeys
  %numparam
  %numrec
  %numrooms
  %numwords
  %numzones
  %param
  %parsemode
  %pathcompress
  %pathexpand
  %pathfrom
  %pathreverse
  %pick
  %pop
  %portal
  %portalenabled
  %pos
  %prompt
  %proper
  %push
  %query
  %quote
  %random
  %read
  %regex
  %remove
  %repeat
  %replace
  %replaceitem
  %reversedir
  %right
  %rightback
  %roomcol
  %roomcom
  %roomcontents
  %roomcost
  %roomdesc
  %roomexit
  %roomflags
  %roomid
  %roomkey
  %roomkind
  %roomlink
  %roomload
  %roommob
  %roommode
  %roomname
  %roomnote
  %roomnum
  %roomobj
  %roomportal
  %roomvnum
  %roomzone
  %round
  %setglobal
  %sort
  %sqrt
  %state
  %stdev
  %string
  %stripansi
  %stripq
  %subchar
  %subregex
  %sum
  %time
  %trigger
  %trim
  %trimleft
  %trimright
  %upper
  %viewrec
  %walk
  %walkactive
  %walkconfirm
  %walkmode
  %walkroom
  %window
  %word
  %write
  %yesno
  %zonename
  %zonenum
  %zonevnum
Related Links:
  #CASE
  Function Reference
  %case
  %dice
  %random
  Predefined Variables
  Random
  RandomInt
  RandomG
  DiceStr
  RandSeed
  %case
  %dice
  %random
  #CASE
  Miscellaneous
  Scripting
  Dice
  4: Simple Functions
  5: Tables
%random [[%random]] 
random

Syntax: %random(i,j)

return a random integer >= I and <= J. If J is omitted, then I specifies the maximum value, and 0 is used as the minimum value.

Examples:

#VAR dirList {n|e|s|w|ne|se|sw|nw|u|d}
#20 {%item(@dirList,%random(5,8))}
sends 20 randomized diagonal directions to the mud.

#VAR dType 12
#VAR dNum 6
#VAR dOffset 22
#VAR sum @dOffset
#LOOP @dNUM {#ADD sum %random(1,@dType)}
#SAY @sum
displays the sum of 6 rolls with a 12-sided die plus an offset of 22

Note: The 'short version' of this example is
#SAY %dice(6d12+22)

 User comments 
nibbledeuce: Sat Mar 18, 2006 12:44 am    

Would also like to see an example using a list of strings to help round out the understanding of %random.
MattLofton: Sat Mar 18, 2006 11:21 pm    

Seems that smilies are enabled on that page. Either pick another number besides 8 in the example or disable the smilies.

I'm seeing a set of NOBR tags around the #var dtype 12 line and the #var dirList {} line. Is that some sort of MXP thing or a Firefox 1.5 issue?
Taz: Sat Mar 18, 2006 11:55 pm    

No it's not a Firefox 1.5 issue because I also have the problem here in IE6. HTML is OFF so the <NOBR>'s are rendered as text. Are they needed, I don't think so, I'll remove them. Smilies are ON and as the example requires 5 to 8 I'm not sure how to edit that, I'll have a play.

<edit>Ok I've fixed it, I just used color black tags round the 8.</edit>
Viewer Comments [3 - Post your comments]

Jump to:  

© 2009 Zugg Software. Hosted by Wolfpaw.net