PDA

View Full Version : How to view a ruleset holistically?



Emrak
September 15th, 2012, 23:31
Hey all,

I'm not sure why I'm having such a hard time wrapping my mind around ruleset mod'ding. I'm coming at this from a .NET and Java background and I think that's where my difficulty is coming from? I keep looking for some way to view a ruleset holistically in Notepad++, like, in a hierarchical fashion.

Obviously I'm failing. :)

This lack of a "big picture" view is hindering me because it's hard for me to understand what the MAIN file is, and within that, what the MAIN function is. Once I know that (presumably) I can step through line by line and see what's going on, but it seems as if rulesets are a loose coagulation of unrelated files?

Do any of you have tips to help shorten my learning curve?

Thank you

Griogre
September 16th, 2012, 04:14
What you are missing is the "main()" is in the FG.exe. You can't change that. Rulesets are basically data structures read in by the program. That may be why it seems so disjointed to you. That said, LUA scripts allow you to defacto extend the parts of the FG program so they float on top of the FG.exe and extend its capabilities.

On a more practical level LUA scripting and rulesets feel more like C or BASIC procedural programming. It uses global variables and just enough window class objects to keep things confusing. ;)

Trenloe
September 16th, 2012, 08:02
Look in base.xml in the root folder of the ruleset you are interested in. This will give you the order in which the other ruleset XML files are loaded (which mostly contain the layouts of the desktop, windows and data structures) at startup, and the LUA scripts with their reference names.

Then, as Griogre says, the main code is in the FG.exe. The XML and LUA files control the look and feel of the desktop, the layout and logic behind windows (character sheets, combat tracker, etc.).

Taking the 3.5E ruleset as a reference: If you're interested in the main campaign objects (story, images and maps, NPCs, encounters, items, notes, etc.) have a look at the XML files and scripts in the "campaign" directory. Objects related to the character sheet are in the "charsheet" directory, e.g. "charsheet_main.xml" defines the main tab of the character sheet. Combat tracker related objects are in the "ct" directory and party sheet "stuff" is in the "ps" directory. Desktop layout is under the desktop directory.

A lot of the FG areas are event driven objects - they don't come into play until the GM or a player selects them or they're triggered by other events - e.g. clicking on the "Maps and images" button will bring up the "imagelist" window (defined in campaign\campaign_images.xml), this relationship is defined in desktop\scripts\desktop.lua which uses a DesktopManager.registerDockShortcut LUA command to tie the maps button to the imagelist windowclass.

So, yes, there is no hierarchical view that people used to development IDE's will be familiar with. It is a case of looking at the area that you are interested in and then going through the related XML and LUA files to see how things hang together. Also, Notepad++ "Find in Files" is your friend - use it to find where a particular LUA script or XML class is defined.

Valarian
September 16th, 2012, 08:04
What you're basically doing is building to contract for an existing interface. There are certain things that need to get defined - e.g. desktop, utilities, graphics, reference, character, adventure (npc, story, items, etc.)

The base.xml (or extension.xml for an extension) is the place to start. That defines the base files for each section. It cascades out from there.

Edit: beaten by Trenloe ;)

Griogre
September 16th, 2012, 17:22
Great perspectives by Valarian and Trenloe. One of the hardest things about modding an existing ruleset is sometimes just finding the part you want to mod. While you can use the Find in Files in Notepad++ or any other code editor, I have found its much less hassle to just use the old DOS find command in a console to narrow down the files that actually have what you need to change.

Moon Wizard
September 19th, 2012, 00:23
Or just ask questions on the forums. As you can see, there are a lot of friendly people in the community willing to point you in the right direction. Since I wrote the 3.5E and 4E rulesets, I can help point you to the right place in the XML or LUA, if there is something you are looking at in particular.

Regards,
JPG

Emrak
September 19th, 2012, 03:51
I really appreciate all the great input from everyone. Thanks!

I do have a follow up question though. If FG.exe is the black box which reaches out to a Ruleset, is there a dictionary of XML nodes (or lua functions or procedures) that FG.exe could potentially reach out for? That's poor wording. By way of example:

If you fire up the Foundation Core, you can roll dice all day long in FG, yet there seems to be no where in Foundation where it's telling FG to display dice a certain way and so forth. Presumably this function is compiled into FG.exe. If I wanted to tap into that function (and extend it), how would I know what XML to write? Or what to call the node after I wrote it? Is there "dictionary" somewhere that says "FG is looking for all these nodes, objects, functions, etc..."

This may be in the "anatomy of a ruleset" and I just haven't gotten to that part yet.

Barring a dictionary, the only other option is to grab another Ruleset and see what it's nodes/functions/etc. are named and experiment with that convention, but that still won't tell me if I'm "missing out" on other useful functions i could extend from FG.exe, know what I mean?

I appreciate any insights! This may be something obvious and my mind just hasn't adapted to the mental paradigm shift yet. Lol

Trenloe
September 19th, 2012, 07:45
I do have a follow up question though. If FG.exe is the black box which reaches out to a Ruleset, is there a dictionary of XML nodes (or lua functions or procedures) that FG.exe could potentially reach out for? That's poor wording. By way of example:

If you fire up the Foundation Core, you can roll dice all day long in FG, yet there seems to be no where in Foundation where it's telling FG to display dice a certain way and so forth. Presumably this function is compiled into FG.exe. If I wanted to tap into that function (and extend it), how would I know what XML to write? Or what to call the node after I wrote it? Is there "dictionary" somewhere that says "FG is looking for all these nodes, objects, functions, etc..."
Yes, these are available under the Library -> Ruleset Reference (Library link a the top of this page). The function used to throw dice is Comm.throwDice: https://www.fantasygrounds.com/refdoc/Comm.xcp#throwDice Do a "find in files" for throwDice in the ruleset you are using to see where this is used. You will probably then have to work back from this to see exactly how it is used in the specific ruleset.

Moon Wizard
September 19th, 2012, 19:16
Check out the chatwindow object (https://www.fantasygrounds.com/refdoc/chatwindow.xcp) for dice handling. Basically, you call throwDice to initiate a roll without a user dragging dice, and you register a callback for onDiceLanded to capture the dice results of any roll (either via throwDice or via user drag).

Regards,
JPG

Emrak
September 24th, 2012, 22:30
Fantastic info. Thanks folks! :) I'll definitely be back with questions as this project progresses.