Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Dice
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dice



On Oct 25, 2004, at 11:48 PM, Kevin wrote:
How does a dice generate diffrent #?  What is the command?  Any
programs that has source code that I could look at?  Thanks a lot!
...
I have figured out how to get a random number but have yet to figure
out how to get words?  Any help?

I don't really understand what you mean. You need to be more specific. Perhaps something like this?


set theDie to "one two three four five six"
some word of theDie

I have a dice handler that may help:

on doRoll(NumRolls, NumDice, NumSides, NumModifier)
--NumRolls = How many times to make this roll, returning each total seperately
--NumDice = How many times to roll this die, adding up the total
--NumSides = How many sides the die has
--NumModifier = A modifier to add to or subtract from the total
--Parameters (4, 2, 6, 1) will roll a six-sided die twice, adding the result, then adding 1 to the total, and then repeats it for a total of 4 times, returning each result in a list.
--For instance, a Yahtzee roll would be (5, 1, 6, 0), to roll 5 six-sided dice.

-- Resets the RollResult
set RollResult to {}

-- Do the roll
repeat NumRolls times
set RollSubTotal to 0
repeat NumDice times
set RollSubTotal to RollSubTotal + (random number from 1 to NumSides)
end repeat

-- Places the resulting RollSubTotal with Modifier at the end of the RollResult and repeats if necessary.
set RollResult to RollResult & (RollSubTotal + NumModifier)
end repeat
return RollResult
end doRoll



Shrug, Joe Weaks _______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re:Dice (From: Kevin <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.