Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function Dice(d)
- if type(d)~="string" then
- return nil;
- end
- local rolls,sides = d:match("(%d+)d(%d+)");
- if rolls==nil or sides==nil then
- return nil;
- end
- local result = 0;
- rolls = math.max(math.min(rolls,10000),1);
- sides = math.max(math.min(sides,10000),1);
- for n=1, rolls do
- result = result + math.random(1,sides);
- end
- return result;
- end
- local func = function(msg,usr,chan)
- local res = Dice(msg);
- if res==nil then
- print("@"..usr.." enter a valid dice. Example: 1d6");
- return
- end
- print("@"..usr.." "..msg.." = "..res);
- end
- return func;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement