STAR TREK 2d20
  1. #1
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,674
    Blog Entries
    1

    making Dice string rollable

    For a character sheet Im working on weapons will be entered with damage ratings/rolls like 2d6+2.
    Where can I find an example of how to make this "rollable"?
    Can I use the new /die commands somehow? Is there another way?

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    The rRoll.aDice (details of rRoll are in the header of the CoreRPG \scripts\manager_action.lua file) is a table of valid FG dice. If you want to roll 2d6 you need to define the rRoll.aDice table with two d6's: {"d6"," d6"}.

    Then set rRoll.nMod to be the modifier, e.g. 2 (a number, not a string).

    See desktop\scripts\manager_chat.lua and the processDie function - this is what is ran when the /die slash command is used in the chat window to roll dice. See how the local aDice, nMod = StringManager.convertStringToDice(sDice); command takes the dice part of the /die command and breaks it out into the aDice table and the nMod modifier (put into the rRoll structure at the end of the function). Then further code checks for valid FG dice (to be rolled via the 3D dice) or non-standard dice to be rolled via math.random.

    You could use ChatManager.processDie("", "2d6+2") to roll your dice with mod, but the action type would always be "dice" and so you couldn't use this as part of a custom action handler (with a custom rRoll.sType).

    You're best understanding the rRoll.aDice table struture and how to add dice to that table - perhaps using the StringManager.convertStringToDice function.
    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
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,674
    Blog Entries
    1
    you are a funny fellow. speak english for me!

    ok... 2d6+2 is an example. it could be 1d8+3 or 2d4 etc.

    would I still be going at this the same way?

    due to the limited scope of my project (eg character sheet only, no combat tracker, no npcs and no effects) this would not be an opposed roll and nor would it be applied automatically against another object/entity. it would just need to report the result to the chat windows - eg [Damage] <2><5>+2 9

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    Quote Originally Posted by damned View Post
    you are a funny fellow. speak english for me!
    Come on! You've already been through a lot of this with your Maelstrom dice roll antics.

    Remember the rRoll.sDesc part from that? This is just another part: rRoll.aDice being a table of dice - it can be anything that FG supports: {"d4","d4"} for 2d4, {"d8"} for 1d8, etc..

    Quote Originally Posted by damned View Post
    would I still be going at this the same way?
    Yes. rRoll.aDice = the dice you want to roll in a LUA table format. rRoll.nMod = the modifier you want to apply.


    Take a deep breath, go through my first post - look at what I reference, these are examples in the code of the CoreRPG ruleset showing you how it is done.
    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!

  5. #5

  6. #6
    Valarian's Avatar
    Join Date
    Mar 2007
    Location
    Worcestershire, UK
    Posts
    2,567
    Ooo. Nice.
    Using Ultimate license - that means anyone can play.
    Valarian's Fantasy Grounds Rulesets

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 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
  •  
DICE PACKS BUNDLE

Log in

Log in