Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ Rolling Dice
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Shady Stranger
USA (45 posts) Bio
|
| Date
| Sun 07 Mar 2010 02:14 PM (UTC) |
| Message
| 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. | | Top |
|
| Posted by
| Shady Stranger
USA (45 posts) Bio
|
| Date
| Reply #1 on Sun 07 Mar 2010 03:30 PM (UTC) |
| Message
| 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. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,165 posts) Bio
Forum Administrator |
| Date
| Reply #2 on Sun 07 Mar 2010 11:51 PM (UTC) |
| Message
|
<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>
 |
For advice on how to copy the above, and paste it into MUSHclient, please see Pasting XML.
|
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Shady Stranger
USA (45 posts) Bio
|
| Date
| Reply #4 on Tue 09 Mar 2010 02:17 AM (UTC) Amended on Tue 09 Mar 2010 02:28 AM (UTC) by Shady Stranger
|
| Message
| 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. | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,981 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top