Thread: Very simple dice rolling
-
February 23rd, 2024, 03:29 #1
- Join Date
- Feb 2021
- Posts
- 376
Very simple dice rolling
I read the sticky on this but all I want to do is roll a simple dice combo and get back the total. I.e. "5d10" or "5d10+5". Is there an easy way to do this? Thanks.
-
February 23rd, 2024, 03:38 #2
As explained in the coding dice rolls thread, FG rolls are asynchronous - you put the roll together and then tell FG to execute the roll, and that's where the code ends. If you want to do some processing of the result, then you need to code in the onRoll result handler - which is all explained in the thread. You can't code to roll the dice and then have your code pause until the result is returned, as this would hang the whole of FG.
One way around this is not to roll dice, but work out the dice rolls using random numbers - as the dice don't roll, you have the result immediately available in your code and can have the roll and result handler all in the same function. Have a look at the evalDiceString function in the CoreRPG ruleset -> scripts\manager_dice.lua file.Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!
-
February 23rd, 2024, 23:24 #3
- Join Date
- Mar 2009
- Location
- Lidingö, Sweden, Europe
- Posts
- 377
Googling for "lua dice" gave the following link: https://github.com/brianherbert/dice...aster/roll.lua, which you could modify for your needs.
-
February 24th, 2024, 02:56 #4
You need to provide more info.
You can type /die 5d10+5 in chat and it will roll and output the result.
This works in almost every ruleset.
If you are wanting to play an otherwise unsupported game try XCore it supports a lot of dice mechanics and writing new rolls is quite trivial.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks