FG Spreadshirt Swag
Page 1 of 2 12 Last
  1. #1

    Changing Font Color Caster Level Check an Save Messages

    I need help modifying a "lua" file that valeros wrote. His extension, link provided here, changes the color of attack rolls.

    I would like to change the font color of a a caster level checks (CLC) and save rolls, to make it easier to distinguish rolls. I have attempted the following code:

    Code:
    local outputResult = nil;
    
    function onInit()
    	outputResult = ActionsManager.outputResult;
    	ActionsManager.outputResult = replaceCastRollFont;
    end
    
    function replaceCastRollFont(bTower, rSource, rTarget, rMessageGM, rMessagePlayer)
    
    	if (rMessageGM and rMessagePlayer) then
    		if (rMessageGM.icon == "roll_cast_clc_success") then
    			rMessageGM.font = "cast_clc_roll_success_msgfont";
    			rMessagePlayer.font = "cast_clc_roll_success_msgfont";
    		elseif (rMessageGM.icon == "roll_cast clc_failure") then
    			rMessageGM.font = "cast_clc_roll_failure_msgfont";
    			rMessagePlayer.font = "cast_clc_roll_failure_msgfont";
    		elseif (rMessageGM.icon == "roll_cast save_success") then
    			rMessageGM.font = "cast_save_roll_success_msgfont";
    			rMessagePlayer.font = "cast_save_roll_success_msgfont";
    		elseif (rMessageGM.icon == "roll_cast save_failure") then
    			rMessageGM.font = "cast_save_roll_failure_msgfont";
    			rMessagePlayer.font = "cast_save_roll_failure_msgfont";
    		elseif (rMessageGM.icon == "roll_cast save_auto_success") then
    			rMessageGM.font = "cast_save_roll_auto_success_msgfont";
    			rMessagePlayer.font = "cast_save_roll_auto_success_msgfont";
    		elseif (rMessageGM.icon == "roll_cast save_auto_failure") then
    			rMessageGM.font = "cast_save_roll_auto_failure_msgfont";
    			rMessagePlayer.font = "cast_save_roll_auto_failure_msgfont";
    
    		end
    	end
    	
    	outputResult(bTower, rSource, rTarget, rMessageGM, rMessagePlayer);
    Thanks for the help.
    Last edited by dellanx; June 23rd, 2020 at 10:39.

    These are the modules and extensions created and/or taken over by dellanx for PFRPG.

    I had a lot of help and advice from many here at FG.

    Thank You!

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    What actually happens?

    Does your custom function get called? Put some debug in the function to see if it is.

    If it is being called, are those fonts all defined? Do you see any warnings in the console?

    There's steps you can do to verify what is happening and what code is being called - use liberal use of Debug.console commands to track code and variables.
    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
    Quote Originally Posted by Trenloe View Post
    What actually happens?

    Does your custom function get called? Put some debug in the function to see if it is.

    If it is being called, are those fonts all defined? Do you see any warnings in the console?

    There's steps you can do to verify what is happening and what code is being called - use liberal use of Debug.console commands to track code and variables.
    Have not actually tried it yet, will edit XML tonight. Do I type "/ Debug.console" ?

    These are the modules and extensions created and/or taken over by dellanx for PFRPG.

    I had a lot of help and advice from many here at FG.

    Thank You!

  4. #4
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    Used Debug.console("<your comment here>", <variable name>, <variable name>); in your code. Replace the items in <> with your comment or a variable you want to display the contents of.

    For example, I'd add Debug.console("replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ", rMessageGM, rMessagePlayer); at the start of the replaceCastRollFont function to see what the values of the two message records (LUA tables) are.

    https://fantasygroundsunity.atlassia.../4128996/Debug

    Then, before running your code, type /console in the chat window to open the console.

    Debug.console commands will be output to the console when they are executed. Click the "Copy to Clipboard" button and then paste into Notepad++ (or whichever text editor you're using) for easier reading.
    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
    Quote Originally Posted by Trenloe View Post
    Used Debug.console("<your comment here>", <variable name>, <variable name>); in your code. Replace the items in <> with your comment or a variable you want to display the contents of.

    For example, I'd add Debug.console("replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ", rMessageGM, rMessagePlayer); at the start of the replaceCastRollFont function to see what the values of the two message records (LUA tables) are.

    https://fantasygroundsunity.atlassia.../4128996/Debug

    Then, before running your code, type /console in the chat window to open the console.

    Debug.console commands will be output to the console when they are executed. Click the "Copy to Clipboard" button and then paste into Notepad++ (or whichever text editor you're using) for easier reading.
    Is this an extra line?

    Debug.console("replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ", rMessageGM, rMessagePlayer);

    These are the modules and extensions created and/or taken over by dellanx for PFRPG.

    I had a lot of help and advice from many here at FG.

    Thank You!

  6. #6
    LordEntrails's Avatar
    Join Date
    May 2015
    Location
    -7 UTC
    Posts
    17,147
    Blog Entries
    9
    Yes, you put that line at the start of your code (probably before the if statement) that way FG writes to the console window the value of the variables youa re about to use. And you will then see if those variables have valid values.

    Problems? See; How to Report Issues, Bugs & Problems
    On Licensing & Distributing Community Content
    Community Contributions: Gemstones, 5E Quick Ref Decal, Adventure Module Creation, Dungeon Trinkets, Balance Disturbed, Dungeon Room Descriptions
    Note, I am not a SmiteWorks employee or representative, I'm just a user like you.

  7. #7
    Quote Originally Posted by LordEntrails View Post
    Yes, you put that line at the start of your code (probably before the if statement) that way FG writes to the console window the value of the variables youa re about to use. And you will then see if those variables have valid values.
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Runtime Notice: s'replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ' | { s'text' = s'Save [49][vs. DC 22] -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)] [SUCCESS] [EVASION]', s'font' = s'msgfont' } | { s'font' = s'msgfont', s'icon' = s'roll_cast', s'text' = s'Save -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)]' }
    Runtime Notice: s'replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ' | { s'text' = s'Save [46][vs. DC 22] -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)] [SUCCESS] [EVASION]', s'font' = s'msgfont' } | { s'font' = s'msgfont', s'icon' = s'roll_cast', s'text' = s'Save -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)]' }
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Ruleset Warning: window: Anchored static width ignored for control (name) in windowclass (charsheet)
    Runtime Notice: s'replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ' | { s'text' = s'Save [48][vs. DC 24] -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)] [SUCCESS]', s'font' = s'msgfont' } | { s'font' = s'msgfont', s'icon' = s'roll_cast', s'text' = s'Save -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)]' }

    Looks like that's what I get when I run the script.

    These are the modules and extensions created and/or taken over by dellanx for PFRPG.

    I had a lot of help and advice from many here at FG.

    Thank You!

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    I'm trying to help you to learn how to debug your own code... The debug output wasn't for me, it was an attempt to help you look at your own code and work out why it isn't working.

    The above debug code shows that your custom replaceCastRollFont code is being called - so that's good.

    So, try to think of what might be causing your font replacement to not work? Things like:
    1) The font variable in the message table isn't getting replaced correctly.
    2) The font definition isn't correct/valid.

    Looking at your code in post #1 you're comparing rMessageGM.icon with different cast icons. Looking at the debug output, which displays the contents of rMessageGM:

    Code:
    Runtime Notice: s'replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ' | { s'text' = s'Save [48][vs. DC 24] -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)] [SUCCESS]', s'font' = s'msgfont' } | { s'font' = s'msgfont', s'icon' = s'roll_cast', s'text' = s'Save -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)]' }
    There's no "icon" variable in rMessageGM, so your code will never match anything and so won't change the font.
    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
    Quote Originally Posted by Trenloe View Post
    I'm trying to help you to learn how to debug your own code... The debug output wasn't for me, it was an attempt to help you look at your own code and work out why it isn't working.

    The above debug code shows that your custom replaceCastRollFont code is being called - so that's good.

    So, try to think of what might be causing your font replacement to not work? Things like:
    1) The font variable in the message table isn't getting replaced correctly.
    2) The font definition isn't correct/valid.

    Looking at your code in post #1 you're comparing rMessageGM.icon with different cast icons. Looking at the debug output, which displays the contents of rMessageGM:

    Code:
    Runtime Notice: s'replaceCastRollFont - starting. rMessageGM, rMessagePlayer = ' | { s'text' = s'Save [48][vs. DC 24] -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)] [SUCCESS]', s'font' = s'msgfont' } | { s'font' = s'msgfont', s'icon' = s'roll_cast', s'text' = s'Save -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)]' }
    There's no "icon" variable in rMessageGM, so your code will never match anything and so won't change the font.
    So the variable rMessageGM has to be rMessageGM.icon and rMessagePlayer has to be rMessagePlayer.icon, am I correct?

    Thanks

    These are the modules and extensions created and/or taken over by dellanx for PFRPG.

    I had a lot of help and advice from many here at FG.

    Thank You!

  10. #10
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,361
    So, let's take a step back here.

    rMessageGM contains details of how FG constructs the message to send to the GM.
    rMessagePlayer contains details of how FG constructs the message to send to the players.

    Both of these use the format detailed in "Message Data Structure" here: https://fantasygroundsunity.atlassia...s/4096265/Comm

    So, rMessageGM.text is the text to send to the GM, rMessageGM.font is the font resource to use to display that text. The same goes for rMessagePlayer - it has text, font and also an icon defined.

    What is it you're wanting to do? Change the colour of the attack roles based off the result, right?

    The only way to change the colour of text is to use a different font definition with different a different "color" entry: https://fantasygroundsunity.atlassia...s/4162481/font

    You if statement in post #1 is nearly there, it's just that rMessageGM.icon doesn't exist (so the if statement never runs) and if you changed to rMessagePlayer.icon all you have is ""roll_cast" - you don't have the result.

    So, looking at the data in the debug statements, how are you going to determine the result of the roll? This is the only data you have available at this point:

    Code:
    rMessageGM = { s'text' = s'Save [48][vs. DC 24] -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)] [SUCCESS]', s'font' = s'msgfont' } 
    
    rMessagePlayer  = { s'font' = s'msgfont', s'icon' = s'roll_cast', s'text' = s'Save -> [for Venarus Almon (Ariusven Onalm)] [vs Navoy (Yovan Portheria)]' }
    rMessageGM.text has [SUCCESS] in the text (in this example). So in order to determine if the roll was a success, you could use if string.match(rMessageGM.text, "%[SUCCESS%]") then to determine if the roll is a success.
    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)

Tags for this Thread

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