View Full Version : Rolling Dice without Graphics
Weltenbrand
October 29th, 2020, 10:40
Is there a way to roll a dice in a script without the graphics in the chat window and get the result?
Basically a function like this:
local result = rolldice({'d6'})
Thank you
damned
October 29th, 2020, 11:33
either use the dice tower or maybe use
local result = math.random(6);
Weltenbrand
October 29th, 2020, 11:36
The d6 was an example it should be more general. And I want it in a script not by dragging something into the tower.
Trenloe
October 29th, 2020, 12:07
And I want it in a script not by dragging something into the tower.
So use math.random as mentioned by @damned.
Or, for slightly more complex RPG type dice strings, use StringManager.evalDiceString(sDice, bAllowDice, bMaxDice) - this uses math.random to return the total of the dice string passed in the sDice variable. This function is in the CoreRPG ruleset (scripts\manager_string.lua file). And is used in some of the layered rulesets - search for StringManager.evalDiceString in rulesets for an example. To roll1d6 you'd use local nResult = StringManager.evalDiceString("1d6", true);
Weltenbrand
October 29th, 2020, 12:22
StringManager.evalDiceString(sDice, bAllowDice, bMaxDice)
That is what I was looking for, thank you.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.