Fantasy Grounds Fridays Pre
View RSS Feed

Minty23185Fresh

A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)

Rate this Entry
Due to posting limits, I have had to split this session into three posts.
This is part 1 of 3.


It takes only a single line of code to change an effectís default visibility behavior in the Combat Tracker. To discover and implement it requires a little work as outlined below.

Using Notepad++ I searched for the string displayed on the effect visibility button, VSBL, in the 5E ruleset subfolder, of the Fantasy Grounds data folder. No luck, the search failed to find any instances of that string. I expanded the search to all rulesets. Still no luck. My initial reaction was, itís possible "VSBL" is strictly a graphical representation of some other name.

Note that when one hovers over the VSBL button a tool tip is displayed Visible to All. I searched the 5E ruleset for that string. Again, the search failed. I expanded the search to all rulesets, and finally received a hit in the CoreRPG. In the Notepad++ search results pane, it was obvious to me that this is a simple XML <string> definition.

So I searched for the stringís name visibilityon in all rulesets. Ouch, 41 hits in 20 files. Because I was looking for an XML string name, I started with 5E ruleset .xml files. The first file I looked at yielded a good candidate, a <state> button, with a tooltip attribute using the sought after string name.

Double clicking the search result line, Notepad++ opened the file to the corresponding line (number 754, FG v3.1.7). The line of code looked even more promising, as I noted it resides in a <windowclass> definition named ďct_effectď, ďctĒ as in Combat Tracker! To verify that this is the definition of the button I seek, I changed the line from this:
Code:
        <state icon="button_toggle_visible" tooltipres="visibilityon" />
to this (note I used a tool tip instead of a tool tip resource):
Code:
        <state icon="button_toggle_visible" tooltip="TOM WAS HERE" />
I saved my code, reloaded the ruleset, and brought up the Combat Tracker. When I hovered over the VSBL button, my hacked in tool tip text appeared! To remove my hack, a Ctrl-Z or two to undo my edits, does the trick. Then I resaved the file.

At this point, I have located the XML code that defines the button. Now to try to find some lua that handles the functionality behind the button. A search for the icon string wonít help, that string will point me to the graphic file. Instead I searched for the name of the <button field>, isgmonly, and I limited my search to the 5E ruleset.

The search results included 5 files, three of which were .lua files. When I looked at the first lua file, the code containing my sought after string was in a function called ďonDragStartď. Thatís not too promising, it sounds like something to do with drag and drop functionality. The next five hits were all in the same file, ďmanager_effect.luaď. Viewing the lua statements in the results pane, it looks daunting. It might take quite a while to decipher what all of these statements do.

I tried a shortcut. I went to each result in the file and looked at the name of the function containing that line of code in an attempt to get a handle on what the function does and consequently what the line of code might do. Sure enough, the fifth hit in the file is in a function called ďaddEffectĒ. Could I be any more fortunate! A Debug.console( ) statement, should inform me as to how lucky I am. I added it just after the function definition as shown here:

Code:
function addEffect(sUser, sIdentity, nodeCT, rNewEffect, bShowMsg, sEffectTargetNode)
  Debug.console("TWD|manager_effect.lua|addEffect()|status", "Arrived in 5E");
  -- VALIDATE
I saved the file, reloaded the ruleset, opened the Combat Tracker and Effects Manager. When I petrified the Orc, my debug strings appeared in the console.

(continued in part 2)

Submit "A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)" to Digg Submit "A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)" to del.icio.us Submit "A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)" to StumbleUpon Submit "A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)" to Google Submit "A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)" to Facebook Submit "A Neophyte Tackles the FG Extension - Change Effect Visibility with One Line (Part 1)" to Twitter

Comments

Joshua Stream Pre

Log in

Log in