Starfinder Playlist
  1. #1

    Dice rolls not showing up in the 'Chat Window'

    First - thanks for all the help over the last few days. I'm working my way through the Traveller Ruleset for FG and am learning on the job.

    The character sheet is proving quite a challenge (which I like).

    However one issue today, I've got the 'Damage' dice rolling (I've copied the core scripting from the CoC ruleset) and the dice (the correct ones) do indeed roll on the screen, however they don't report in the chat window.

    I'm sure I've done something daft, just can't find it. This script is contained within the record_char_main.xml file.

    Any help is ace.

    Code:
    			function actionDamage(draginfo)
    				local node = getDatabaseNode();
    				local sName = name.getValue();
    				local sDamage = damage.getValue();
    				local aDice, nMod = StringManager.convertStringToDice(sDamage);
    
    				local rActor = ActorManager.getActor("pc", node.getChild("..."));
    				local sDesc = "[DAMAGE] " .. sName .. " (" .. sDamage .. ")";
    				local rRoll = { sType = "damage", sDesc = sDesc, aDice = aDice, nMod = nMod };
    				ActionsManager.performAction(draginfo, rActor, rRoll);
    			end
    Cheers
    Colin

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    You've initiated the roll, but you don't have a result handler to display text, as dice rolling is asynchronous.

    I'd recommend you use the action functionality built in to CoreRPG - where you define custom action types (e.g. rRoll.sType = "damage" - where the actual custom action is defined in the ruleset manager_gameystem.lua) and then have manager_action_XXXXXX.lua scripts to do the whole process from start to finish (where XXXXXX is the action name, e.g. damage).

    Lots of info here: https://www.fantasygrounds.com/forum...-under-CoreRPG

    As I mention in that thread, the 3.5E manager_action_ability.lua file is a good one to have a look at as it isn't that big.
    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
    Morning chap,

    My ruleset has been built on the top of the CoreRPG ruleset. So thanks for the reply, I'll look at how this all works tonight. I'm learning a lot of stuff and writing it all down.

    Thanks for your time to reply!

    Cheers
    Colin

  4. #4
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,684
    Blog Entries
    1
    Quote Originally Posted by MadBeardMan View Post
    Morning chap,

    My ruleset has been built on the top of the CoreRPG ruleset. So thanks for the reply, I'll look at how this all works tonight. I'm learning a lot of stuff and writing it all down.

    Thanks for your time to reply!

    Cheers
    Colin
    I had to write everything down to give me *some* chance of remembering something!

  5. #5
    Cheers chaps,

    My dice roll and in the chat window I get:

    "Fred "Can't hit me" Smith:
    [ATTACK] Assault Rifle (50%) <dice show 39>
    That's excellent, enough to be getting on with.

    Next questions though (whilst I start on the Skills section).

    I know Fred has 50% in Assault Rifle, and I can see the rolls appearing, so:

    How do I show that it's a success or not
    How do I access the result of the roll

    I've been reading through the 3.5E and CoreRPG and can't seem (yet) to put my finger on it. So a gentle nudge if you please.

    Cheers
    Colin

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    One of the best examples to look at is the 3.5E scripts\manager_action_ability.lua file.

    I don't know if you're familiar with d20 based RPGs. This is an ability check (Strength, Dexterity, etc.) against a DC (Difficulty Class) - which is a number the roll must equal or exceed to be a success.

    In the getRoll function, the target DC is set using: rRoll.nTarget = nTargetDC; to set the target DC number in the rRoll table (record).

    Then, after the roll has been made, the onRoll function is called - this is the action result handler, because it is registered at the beginning of the script using ActionsManager.registerResultHandler. In this function there is code to check for the existence of rRoll.nTarget in the roll table, and then compares this will the roll total ActionsManager.total(rRoll) to indicate success or failure.
    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!

  7. #7
    Quote Originally Posted by Trenloe View Post
    I don't know if you're familiar with d20 based RPGs. This is an ability check (Strength, Dexterity, etc.) against a DC (Difficulty Class) - which is a number the roll must equal or exceed to be a success.
    Not really, I stopped RPGing in the early 2k's whilst my Beer Intake increased vastly.

    Quote Originally Posted by Trenloe View Post
    In the getRoll function, the target DC is set using: rRoll.nTarget = nTargetDC; to set the target DC number in the rRoll table (record).

    Then, after the roll has been made, the onRoll function is called - this is the action result handler, because it is registered at the beginning of the script using ActionsManager.registerResultHandler. In this function there is code to check for the existence of rRoll.nTarget in the roll table, and then compares this will the roll total ActionsManager.total(rRoll) to indicate success or failure.
    Ok I understand. I'll look for these and work out how it all functions. Half of my problems are that I can't see the wood for the trees as CoreRPG has a lot of stuff already done, and the other half is that I assume I'll simply pick it up. I am finding once I work something out that it's very cool and powerful. Reminds me of figuring out Garage Games Torque game engine all those years ago...

    So thanks again, I really do owe you a case of beer.

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,404
    The thing to keep in mind is that CoreRPG has the framework that rulesets build on top of. So, whereas it has the base action process laid out in manager_actions.lua (and included below for reference), it doesn't actually use this process to the full (i.e. pass target numbers, compare results, calculate criticals/impales, etc.) within the CoreRPG ruleset. Hence why it's good to look at a fully fledged ruleset to see who the manager_action_XXXXX processes are being used for those rulesets.

    Action process (as defined in the header of manager_actions.lua in CoreRPG):

    -- ACTION FLOW
    --
    -- 1. INITIATE ACTION (DRAG OR DOUBLE-CLICK)
    -- 2. DETERMINE TARGETS (DROP OR TARGETING SUBSYSTEM)
    -- 3. APPLY MODIFIERS
    -- 4. PERFORM ROLLS (IF ANY)
    -- 5. RESOLVE ACTION

    -- ROLL
    -- .sType
    -- .sDesc
    -- .aDice
    -- .nMod
    -- (Any other fields added as string -> string map, if possible)

    The 3.5E "ability" action handler (as mentioned above) is a good one to look at as it has all of this (other than targets) in a pretty straight forward (small-ish) script. Tying in this script to the above action flow:
    1. Drag or double-click would initiate the performRoll function, with various parameters: performRoll(draginfo, rActor, sAbilityStat, nTargetDC, bSecretRoll) An example of this is:

      ActionAbility.performRoll(draginfo, rActor, self.target[1], nTargetDC, bSecretRoll);

      ActionAbility is the global package name which points at the 3.5E scripts\manager_action_ability.lua file.
    2. Not appropriate for this action.
    3. The modifiers to the roll are applied via the modRoll function, which is registered as a modifier handler in the onInit function using: ActionsManager.registerModHandler("ability", modRoll); - this means that the modifier handler for the "ability" action will be the modRoll function. The modRoll function essentially looks at any modifiers to apply to the roll - these come mostly from effects/conditions and the base ability stat modifier.

      Note: This is done automatically as part of the perform roll action process - as long as the modifier handler for the action is setup in onInit.
    4. The dice are rolled, modifiers added, etc..
    5. Once all of the dice have landed, the result handler onRoll is executed. This is the function that was setup in onInit as the result handler for the "ability" action using: ActionsManager.registerResultHandler("ability", onRoll);

      This function has access to the whole rRoll table that includes data from before the roll (see the getRoll function which is executed as part of step #1) and also result information - the total of the roll: ActionsManager.total(rRoll), each individual dice in the rRoll.aDice table, etc..

      The result text is compiled in this onRoll result handler function (including any success/failure reporting) and displayed using Comm.deliverChatMessage(rMessage); at the end of the 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!

  9. #9
    @Trenloe (no idea how I link you),

    You sir are a star. Thanks for giving up so much time to help me with this stuff. I've just cracked skills, so am tidying that up then I'll come back to the above (or maybe finish up the rest of the character sheet).

    Cheers

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
  •  
5E Character Create Playlist

Log in

Log in