PDA

View Full Version : Where to find information on all APIs and functions usable for custom FG coding?



StoryWeaver
January 4th, 2019, 09:29
While developing in lua within FG, besides googling, extracting and digging through modules and extensions to see sample code I've found these two resources.

https://www.fantasygrounds.com/refdoc/
https://www.fantasygrounds.com/wiki/index.php/Developer_Guide

While they are good they still seem to miss a large amount of more specific information on various functions and API calls within FG that are available.

As just one example the, OptionsManager (ex OptionsManager.addOptionValue()) function. Found this in a reply to a forum question some years back, "OptionsManager.isOption(<option name>, <option value>) or OptionsManager.getOption(<option name>)". Found calls to this in CoreRPG.pak\scripts\data_options_core.lua, but so far been unable to find the original source of this information.
That's just one example of course, but there are any number of functions or calls such as those, and as I can't exactly walk/step through the code during execution to trace the source and keep an eye on the variables during the process it leads me to the following questions.

Is there some other document source I'm missing that details all of these?
Or do I need to search for them manually in for example the CoreRPG.pak and do my best to guess the parameters and make sense of them from there?
Are some of these encrypted away in the data\vault, if so how do I find these details if there?
How do I find the pipeline of function calls?

In other words, where/how do I find out what purpose, parameters, return values etc. all the inbuilt FG functions have?

damned
January 4th, 2019, 12:02
https://www.fantasygrounds.com/refdoc/ and examples in other rulesets is what I use.

LordEntrails
January 4th, 2019, 19:39
In short, you have already found the two best sources. There is no complete and comprehensive documentation. I believe you can also look at some online LUA documentation, but I don't remember which version of LUA FG uses. Other than that, search the forums here, especially the Workshop, and ask when you have questions.

Bidmaron
January 4th, 2019, 20:56
The best thing is to study corerpg ruleset. Look at the scripts directory. All the managers are in there. Look at the base.xml and it will show you the manager names and the associated script file.

Valyar
January 4th, 2019, 21:34
You found the weakest part of FG :)

StoryWeaver
January 5th, 2019, 03:58
It seems I'm on the right track in that case. I'll keep digging into the CoreRPG code, other extensions and the reference documents.

Thank you all for your replies, I appreciate them.

Andraax
January 5th, 2019, 04:33
In other words, where/how do I find out what purpose, parameters, return values etc. all the inbuilt FG functions have?

You would look in base.xml to see what script file is being pointed to by the name "OptionsManager" ("scripts/manager_options.lua") and then go find the function "isOption" in that file.

Naroe
April 10th, 2020, 11:34
Is there a way to determine what diagonal distance has been selected in the options,
IE Standard, Variant, Raw

From in code of course.

superteddy57
April 10th, 2020, 11:42
I believe it is defined in the gameelements.xml under the distance tag.

Naroe
April 10th, 2020, 12:47
Yes it is, But im talking about when you change it in the options menu from standard to variant to raw.
Can you detect that in code.
Im hoping so as it affects the value of a pointer arrow or distance between targets.

So changing the option is changing distance values

33392

superteddy57
April 10th, 2020, 14:05
I started with the label and found it pointing in data_options5E.lua for the 5E ruleset. As you mentioned you found that location, but I dug deeper with 5E and found that it gets called in the CombatManager2 (manager_combat2.lua). Its further checked in the onHRDistanceChanged() function. Takes a bit of detective work to find how things work. You can get to them faster, if you have a text editor with 'find in files' option to search an unpacked ruleset for certain calls.