PDA

View Full Version : [5E] Get the list of all classes



st4lk3r87
July 14th, 2019, 00:56
Hello!

I'd like to retrieve from codes all the classes that are loaded. So if there's a module that contains new classes I'll be able to get them too.

I'm pretty sure it's very easy to do but I can't really understand how it can be done.

celestian
July 14th, 2019, 01:18
Hello!

I'd like to retrieve from codes all the classes that are loaded. So if there's a module that contains new classes I'll be able to get them too.

I'm pretty sure it's very easy to do but I can't really understand how it can be done.



for _,nodeClass in pairs(DB.getChildrenGlobal("class")) do
Debug.console("nodeClass:",nodeClass);
end

st4lk3r87
July 14th, 2019, 01:26
for _,nodeClass in pairs(DB.getChildrenGlobal("class")) do
Debug.console("nodeClass:",nodeClass);
end


Argh!!! I totally missed the getChildrenGlobal. Thank you!
I've tried it and it works only with custom classes. It looks like to get all the classes located in other modules (like the PHB) I have to use "reference.classdata" instead of "class". Is it wrong?

Trenloe
July 14th, 2019, 01:29
I've tried it and it works only with custom classes. It looks like to get all the classes located in other modules (like the PHB) I have to use "reference.classdata" instead of "class". Is it wrong?
Read-only data (usually in commercial modules) is in the reference.*** database path. Some info on editable and read-only data here: https://www.fantasygrounds.com/wiki/index.php/Campaign_and_Module_Data_File_Overview#CoreRPG_Dat a_File_Format

st4lk3r87
July 14th, 2019, 01:33
Read-only data (usually in commercial modules) is in the reference.*** database path. Some info on editable and read-only data here: https://www.fantasygrounds.com/wiki/index.php/Campaign_and_Module_Data_File_Overview#CoreRPG_Dat a_File_Format
Thank you Trenloe. So if I want to retrieve all the classes I should collect from "class" path and "refernece.classdata" I guess.

Trenloe
July 14th, 2019, 01:36
So if I want to retrieve all the classes I should collect from "class" path and "refernece.classdata" I guess.
Yup.

What I've done for lookups in the PFRPG2 ruleset is to look in three places in order:
In the campaign data first - this allows the GM to override standard entries with their own custom data.
Editable entries in modules.
Read-only entries in modules.

Moon Wizard
July 15th, 2019, 04:39
There is a function in the CoreRPG LibraryData script to retrieve all the registered node paths.



local vMappings = LibraryData.getMappings("class");
for i = 1, #vMappings do
for _,nodeClass in pairs(DB.getChildrenGlobal(vMappings[i])) do
Debug.console("nodeClass:",nodeClass);
end
end


Regards,
JPG

st4lk3r87
July 15th, 2019, 11:57
There is a function in the CoreRPG LibraryData script to retrieve all the registered node paths.



local vMappings = LibraryData.getMappings("class");
for i = 1, #vMappings do
for _,nodeClass in pairs(DB.getChildrenGlobal(vMappings[i])) do
Debug.console("nodeClass:",nodeClass);
end
end


Regards,
JPG

Thank you!
Does this approach cover all the three steps mentioned by Trenloe?

Moon Wizard
July 15th, 2019, 17:49
Yes, for 5E ruleset.

Regards,
JPG