Rolling Dice

Posted by Shady Stranger on Sun 07 Mar 2010 02:14 PM — 5 posts, 20,174 views.

USA #0
I am trying to make a dice rolling alias but can't figure it out.

I have set up an alias "throw * dice *"

Send ("squint and throws %1 %2-sided dice...")

<The calculation part here is what I can't figure out.>

Send ("say [Dice 1] + [Dice 2], etc. = [Total]")

I assume this would involve the use of MtRandom () but am having no luck with it.

Thanks in advance for the help.
USA #1
ok, here is what I've got now...

Send ("squint and throws %1 %2-sided dice......")

for i = 1, %1 do

Tell (math.floor (MtRand () * %2) + 1, " " )

end

This will generate random numbers based on how many numbers on each dice and quantity of dice.

What I want it to do is store the values of each number generated so that I can Send the command "say" followed by each number rolled and have it calculate the total.

Thanks for any help.
Australia Forum Administrator #2

<aliases>
  <alias
   match="throw * dice *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("emote squints and throws %1 %2-sided dice......")

local total = 0

for i = 1, %1 do

  result = math.floor (MtRand () * %2) + 1
  total = total + result
  Tell (result, " " )

end

Send ""
Send ("say Total was ", total)

</send>
  </alias>
</aliases>


Template:pasting
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.

USA #3
Perfect. Thank you!

SS
USA #4
Ok, I have been trying to figure out how to display the value of each individual dice...


<aliases>
  <alias
   match="throw * dice *"
   enabled="y"
   send_to="12"
   sequence="100"
  >
  <send>

Send ("emote squints and throws %1 %2-sided dice......")

local total = 0

for i = 1, %1 do

  result = math.floor (MtRand () * %2) + 1
  total = total + result
  Tell (result, " " )

end

Send ""
Send ("say Result: ", result)
Send ("say Total was ", total)

</send>
  </alias>
</aliases>


This only returns the first number.