PDA

View Full Version : Module.getModuleInfo()



Bidmaron
July 20th, 2018, 16:31
There appears to be a problem with the wiki documentation on this api because there is this code in the utility_library.xml file:


<windowclass name="library_booklistentry">
<margins control="0,0,0,7" />
<sizelimits>
<minimum height="70" />
</sizelimits>
<script>
function onInit()
local sModule = getDatabaseNode().getModule();
local info = Module.getModuleInfo(sModule);
name.setValue(info.displayname or info.name);
thumbnail.setIcon("module_" .. sModule);
end

The getModuleInfo api says the following:

function getModuleInfo( name )
This function can be used to retrieve information about a particular module. The returned table contains information in the following fields:

name
category
author
size
installed (on local machine)
loaded
loading (from host machine)
loadpending (active request to host machine)
permission (none, disallow, allow, autoload)
intact (host only)
replaces (which other modules does this one override)
hastokens
hasdata
Parameters

name (string)
The name of the module being targeted by the operation
Return values

(table)
A table containing information about the module, see above for details

Note there is no returned field for displayname.

But this also raises two questions:

1. What is the difference in name, displayname, and the string parameter you pass to getModuleInfo to obtain the module record?
2. Why did the icon get set to "module_" and the sModule variable? Wouldn't the icon field of the record have returned the icon name?

Bidmaron
July 20th, 2018, 21:22
OK, I went in and did some exploring, and it appears that displayname is the only undocumented field. And, of course, there is no icon field, so disregard question #2.
I have over 200 modules, and it would seem that, at least for the ones I own, the name used to look up the module with getModuleInfo, the field called 'name,' and the field called 'displayname' are identical for all the modules I own.

Talyn
July 21st, 2018, 01:40
<displayname> was added a few updates ago. It goes in definition.xml so you can have the Library page show something other than what the <name> value is. (Note: so far, displayname only works in the Library. All the campaign windows group names will still show the name.)

It was primarily added because @Moon Wizard finally got irritated enough at the 5E DLC saying "DD Player's Handbook" etc. because the original developer apparently didn't know how to use ASCII codes. So now the <displayname> shows "D&D Player's Handbook" in the Library, while the <name> is still "DD Player's Handbook" to avoid breaking links in existing campaigns.

Moon Wizard
July 21st, 2018, 01:54
All of what Talyn said is true. :)

Also, the “name” field is equal to the file name if undefined; and the display name is equal to the “name” field if undefined.

Finally, the name field is used internally within FG as the unique key for accessing assets and data within modules.

Cheers,
JPG

Bidmaron
July 21st, 2018, 01:55
Talyn, according to the code in 3.5.5, it should be showing the displayname if it is available. This is the code:


function onInit()
local sModule = getDatabaseNode().getModule();
local info = Module.getModuleInfo(sModule);
name.setValue(info.displayname or info.name);
thumbnail.setIcon("module_" .. sModule);
end