DICE PACKS BUNDLE
Page 1 of 4 123 ... Last
  1. #1
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413

    Basic success counting extension

    I checked in with DMFirmy (the creator of the drop lowest extension I mentioned above) and he was very happy for me to do a quick success reporting extension based off the framework he used in his extension. Thanks very much DMFirmy!

    Attached is a very basic success reporting extension. This should work in all rulesets based on CoreRPG and uses a basic slashhandler to roll dice and report on the number of successes.

    1. Download the attached CountSuccesses.ext file and install in your <FG App Data>\extensions directory.
    2. Load up a CoreRPG based campaign and select the "Count Successes" extension.
    3. Once in your campaign you can use the success count extension through a slash command in the chat window - see usage below.


    Usage

    Use the /successes chat slashhandler as follows:

    /successes XdY Z Where XdY is the dice string to roll, e.g. 5d10, 25d12, etc. and Z is the target success number (each dice equal to or above this number will be counted as a success).

    Fantasy Grounds will count the number of successes and report these in the chat window as part of the roll result.

    For example: /successes 10d10 7 will roll ten 10 sided dice and report the total number of dice that were 7 or more.

    Example screenshot:


    There's no further integration into any ruleset, this is just a quick extension to show what can be done - and to provide some use to people who want this basic functionality.

    The /successes string can be dragged to a FG hotkey to allow quick rolling of frequently used rolls.

    I'll expand on this/provide further documentation (probably in extension comments) at some point...

    EDIT: Minor edit to extension to allow active identity (PC, GM ID, etc.) to be shown in the roll.
    Last edited by Trenloe; September 4th, 2016 at 18:40.
    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!

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Reserved.
    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,685
    Blog Entries
    1
    Hey Trenloe when you roll usin this extension it reports the Username and not the Character name as making the roll.
    I had a look but I cant work out what to change

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Quote Originally Posted by damned View Post
    Hey Trenloe when you roll usin this extension it reports the Username and not the Character name as making the roll.
    Remove rRoll.sUser = User.getUsername(); from count_successes.lua, and don't put anything in for rRoll.sUser. This will leave it to the ChatManager.createBaseMessage function to create the right name.
    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
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Much obliged Trenloe that fixed both this one and DMFirmys Drop Lowest extension.

  6. #6
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Hi Trenloe is it possible (how would you go about) setting this up to report the Successes and not the Sum? It already reports the Success Count but I would like to know how you would report this number as a the draggable number.

  7. #7
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    https://www.fantasygrounds.com/refdoc/Comm.xcp dicedisplay = 0 stops the total being displayed.

    You'd then have to construct any drag data separately - and code in the value/s you want to be available in a drag action: https://www.fantasygrounds.com/refdoc/dragdata.xcp
    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!

  8. #8
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,685
    Blog Entries
    1
    Hi Trenloe - can you think of anywhere that I can see an example of setting your own dragdata?

  9. #9
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Quote Originally Posted by damned View Post
    Hi Trenloe - can you think of anywhere that I can see an example of setting your own dragdata?
    CoreRPG, campaign\record_char_main.xml - line 111, you need to put the info together in the onDragStart function. Do other searches for onDragStart for other examples. You'll need to get info out of the chat info when the drag starts, so you may need to use some coding in [] or something in the description to easily get to the info you want. Info on the onDragStart event here: https://www.fantasygrounds.com/refdo...cp#onDragStart There's a bunch of stuff already there (related to the comm data structure: https://www.fantasygrounds.com/refdoc/Comm.xcp) you'll probably want to do lots of Debug.console commands to see exactly what is available when you start the drag.
    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!

  10. #10
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,413
    Depending on what you want to do (as I'm not sure what you're wanting to do), you might not even need the onDragStart code. Set the info in the chat message and then it will come across in the draginfo, and decode in the onDrop function on the control/window where you drop the drag: https://www.fantasygrounds.com/refdo...rol.xcp#onDrop

    I do this for damage in the Star Wars ruleset. I send a line of [Damage: X] to the chat window, where X is the amount of damage done. This message is constructed using:
    Code:
    local damagemsg = {};
    damagemsg.font = "msgfont";
    damagemsg.type = "wounds";
    local sDamage = "";
    sDamage = string.match(description, "%[DAMAGE:%s*(%w+)%]");
    local totaldamage = tonumber(sDamage) + resultSummary.success
    damagemsg.text = "[Damage: " .. totaldamage .. "]";
    deliverMessage(damagemsg);
    The key thing here is the .type data of "wounds". When this chat entry is dragged and then dropped somewhere (in this specific case on a PC or NPC record) the onDrop function has access to the message data in the dragdata record. I use if draginfo.isType("wounds") as part of the onDrop function to see if the drag/drop is doing damage and then run the code to extract the damage info and apply it:
    Code:
    if draginfo.isType("wounds") then
    	if draginfo.getDescription() then
    		sDamage = string.match(draginfo.getDescription(), "%[Damage:%s*(%w+)%]");	
    	end
    end
    It then uses the description text (the damagemsg.text from the chat message) and uses that to extract the wounds value using sDamage = string.match(draginfo.getDescription(), "%[Damage:%s*(%w+)%]"); You'd have to write something similar to get the numerical value from your chat message text. https://www.fantasygrounds.com/refdo...getDescription
    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!

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
  •  
STAR TREK 2d20

Log in

Log in