ID:176635
 
This is the current dice verb im using.

Roll(T as text)
set category = "Communication"
var/rollvar=roll(T)
world<<"[usr] rolls [T]=[rollvar]"
Scoobert did this verb for me *Thanks dood* But what im wanting now in a dice verb is to make it more flexible.

Currently when you roll its like this.

Jake rolls 5d100=*total*

Well im wanting it to show the total for each dice rolled...

Jake rolls 5d100= 45,10,20,14,50, = *140*

like that. But how can i go about doing this?


You'll have to roll each die individually, rather than all at once. Then just output each die's value, and the total at the end:

<code>Roll(dice,sides) var/total=0 world << "[usr] rolls [dice]d[sides] = \..." // \... suppresses the automatic return for(var/x=0,x<dice,x++) var/roll=rand(1,sides) world << "[roll] " total += roll //Add them up world << "= [total]"</code>

Hopefully that's all correct, I'm not very good at this kind of for loop... :-)
In response to Crispy
It isn't working at all. Getting two errors
player.dm:21:error:dice :undefined argument type
player.dm:21:error:sides :undefined argument type

Hmm I dont understand why its doing that...

In response to Jacob
Well, you could try adding "as num" after each var on that line - don't know if that'll help, but it's worth a try! :-)
In response to Crispy
It works sorta but when its showing the roll var instead of of going acrose like 12,14,19,18= total.. it goes like this

12
14
19
18
total

I dont want it to do like that because it can be a spam tool for some kid wanting to cause problems
In response to Jacob
You could add it too a text string instead of outputting it too the world.
Roll(dice,sides)
var/total=0
var/ouput = "[src.name] rolled [dice]d[sides] to get: "
world << "[usr] rolls [dice]d[sides] = \..." // \... suppresses the automatic return
for(var/x=0,x<dice,x++)
var/roll=rand(1,sides)
ouput += "[roll], "
total += roll //Add them up
output += "for a total of [total]."
world << "[output]"

That should output something like "DogMan rolled 4d6 to get: 2, 4, 6, 4, for a total of 16.
-DogMan

In response to Dog Man
Thanks Crispy/DogMan you really helped me out
In response to Dog Man
Actually, that's not needed:
<code> Roll(dice,sides) var/total=0 world << "[usr] rolls [dice]d[sides] = \..." // \... suppresses the automatic return for(var/x=0,x<dice,x++) var/roll=rand(1,sides) world << "[roll] \..." // Crispy forgot to put a \... here total += roll //Add them up world << "= [total]" </code>
In response to Garthor
Garthor wrote:
world << "[roll] \..." // Crispy forgot to put a \... here

Hmm, so I did. Thanks for picking that up!

I would like to point out, however, that the code you posted is the code I posted, plus that one fix. :-)
In response to Crispy
And your point is...?
In response to Garthor
No point, I just felt like spamming randomly. :-) j/k