deadsmelly
New Member
- Joined
- Apr 5, 2009
- Messages
- 8
- Reaction score
- 4
Hello all!
I am attempting to run a D&D campaign using TFS 1.1 and have a talk action that can roll dice. I've managed to code together a simple dice roller that broadcasts the results of rolling a d20.
What I'd really like to do is have it so players could type /roll and then the type of dice they want and it would give the result back. Example: /roll 2d20 to roll two 2o sided dice. I am not sure how to get the script to listen for different strings and react accordingly though.
Any help would be appreciated!
SOLVED : Used Xikini's excellent script below.
I am attempting to run a D&D campaign using TFS 1.1 and have a talk action that can roll dice. I've managed to code together a simple dice roller that broadcasts the results of rolling a d20.
Code:
function onSay(player, words, param)
local value = math.random(1, 20)
do
broadcastMessage(player:getName() .. " rolled a d20. It lands on " .. value .. ".", MESSAGE_STATUS_CONSOLE_BLUE )
end
end
What I'd really like to do is have it so players could type /roll and then the type of dice they want and it would give the result back. Example: /roll 2d20 to roll two 2o sided dice. I am not sure how to get the script to listen for different strings and react accordingly though.
Any help would be appreciated!
SOLVED : Used Xikini's excellent script below.
Last edited: