5E Product Walkthrough Playlist
  1. #1

    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.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,399
    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!

  3. #3

    Join Date
    Mar 2009
    Location
    Lidingö, Sweden, Europe
    Posts
    367
    Googling for "lua dice" gave the following link: https://github.com/brianherbert/dice...aster/roll.lua, which you could modify for your needs.

  4. #4
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,673
    Blog Entries
    1
    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 2 users browsing this thread. (0 members and 2 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in