STAR TREK 2d20
  1. #1

    Custom Data for throwDice

    The parameters for Comm.throwDice are as such:
    function throwDice( dragtype, dice, modifier, description, [customdata] )
    How does one access the customdata? It doesn't appear in the rRoll and there are no examples of it in the 5e or CoreRPG ruleset. (Maybe another ruleset has an example...)
    I never claimed to be sane. Besides, it's more fun this way.

  2. #2
    It's not used at all by the CoreRPG ActionsManager framework. It's a way to pass a single Lua variable along with the dice throw. You would use dragdata.getCustomData to access that variable returned via the dragdata object provided in onDiceLanded.

    There are two other approaches:

    1. Encode any information you need in the roll description string, and then decode when the result function is reached. (i.e. half damage, etc.)

    2. A different approach which the CoreRPG ActionsManager framework uses is to pass the rRoll variable as part of the meta-data in the throw slot. (See line 529 of ActionsManager:buildThrow in CoreRPG ruleset) This information is recovered into the roll object returned to the ResultHandler functions registered with the ActionManager script. For example, this is used in ActionAbility script in 3.5E to pass rRoll.nTarget variable to the final onRoll handler. (See lines 23 and 114 in ActionAbility in 3.5E ruleset)

    Cheers,
    JPG

  3. #3
    Quote Originally Posted by Moon Wizard View Post
    in onDiceLanded.
    This is what I was looking for.
    Quote Originally Posted by Moon Wizard View Post
    1. Encode any information you need in the roll description string, and then decode when the result function is reached. (i.e. half damage, etc.)
    This is what I was planning on doing.
    Quote Originally Posted by Moon Wizard View Post
    2. A different approach which the CoreRPG ActionsManager framework uses is to pass the rRoll variable as part of the meta-data in the throw slot. (See line 529 of ActionsManager:buildThrow in CoreRPG ruleset) This information is recovered into the roll object returned to the ResultHandler functions registered with the ActionManager script. For example, this is used in ActionAbility script in 3.5E to pass rRoll.nTarget variable to the final onRoll handler. (See lines 23 and 114 in ActionAbility in 3.5E ruleset)
    This is what I was wanting to do. Though it seems that all the metadata is converted to strings.

    Thanks for the prompt response.
    I never claimed to be sane. Besides, it's more fun this way.

  4. #4
    Yes, all the metadata is converted to strings, but can be easily converted back to numbers using the Lua tonumber() function.

    Cheers,
    JPG

  5. #5
    I was actually trying to pass a function. Don't need to; was just seeing if I could include a callback.
    I never claimed to be sane. Besides, it's more fun this way.

  6. #6
    You could pass an an identifier string to denote which callback to use.

    JPG

  7. #7
    I could. But I couldn't figure out how to convert a string into a function in Lua. I imagine it is something easy, but as I don't really need the callback function (just testing the waters to see my boundaries), I'll just use the decoded description for now.
    I never claimed to be sane. Besides, it's more fun this way.

  8. #8
    I was thinking that you would do something like this:

    In performRoll/getRoll function:
    rRoll.sCallback = name of callback function

    In onRoll function:
    if rRoll.sCallback == "callback1" then
    callback1(...);
    elseif rRoll.sCallback == "callback2" then
    callback2(...);
    ...
    end

    Cheers,
    JPG

  9. #9
    Ah, a switch. Could work. Thanks for the insight.
    I never claimed to be sane. Besides, it's more fun this way.

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
  •  
FG Spreadshirt Swag

Log in

Log in