ID:176567
 
Im having yet another dice problem. Here is the current one im using right now.

Roll()
set category = "Communication"
var/dice=0
var/sides=0
dice = input("How many dice?","How many dice?")as num
sides= input("How many sides?","How many sides?")as num
var/total=0
var/output = "[src.name] rolls [dice]d[sides]= "
world << "\..." // \... suppresses the automatic return
for(var/x=0,x<dice,x++)
var/roll=rand(1,sides)
output += "[roll], "
total += roll //Add them up
output += " Total:[total]"
world << "[output]"

What im wanting to do is have the use type in [dice]d[sides] instead of it having to pop up asking how many dice then how many sides.

You would use the verb like this Roll"1d5" If your getting what I mean. Im wanting it to still show the [roll] var. Im also having problems figuring on how to limit the amount of dice that can be rolled. like so a usr can't roll over 100 dice lets say..
you could use the HTML library. I'm not great with that library (not much experiance) though, so you'll have to figure out the rest yourself.
In response to Hazman
I dont think the HTML lib has anything to do with a dice.. *cough* or does it..
In response to Jacob
Use a form from the HTML library to output [thisnumber]d[thisnumber] then generate a random number based on them using a proc. Finally, output this number.
In response to Hazman
lol Ok. HTML lib is the last thing I wanted to fool around with =-\. Im guessing there isn't a easier way to get around it.
In response to Jacob
Not that I am aware of.
Ignore Hazman, he has no clue what you're talking about.
verb
Roll(var/text as text|null)
set category = "Communication"
var/dice = 0
var/sides = 0
var/dPos = findtext(text,"d")
if(!text || !dPos || (dPos == 1 && length(text) == 1) || dPos == length(text)) //If there is no text, or the text is invalid.
//Set dice and sides using an input.
else
if(dPos == 1) dice = 1
else dice = text2num(copytext(text,1,dPos)
sides = text2num(copytext(text,dPos)
//And then do the rolling.