GetModuleInfo: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
table getModuleInfo ( string moduleName ) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
===Required Arguments=== | ===Required Arguments=== | ||
*'''moduleName:''' A string containing the module you wish to get information of e.g. "hashing.dll" | *'''moduleName:''' A string containing the module you wish to get information of e.g. "hashing.dll" | ||
===Returns=== | ===Returns=== | ||
Returns a [[ | Returns a [[table]] containing information about module. These keys are present in the table: | ||
*'''version''': Module version in format X.XX | |||
*'''name''': Module name | |||
*'''author''': Module author | |||
If invalid name for module is passed, it will return ''false''. | |||
==Example== | ==Example== | ||
<syntaxhighlight lang="lua">-- | This example adds a command ''checkmodules'' with which you can view information about currently loaded modules. | ||
<syntaxhighlight lang="lua"> | |||
function printModuleInfo ( thePlayer ) | |||
local modules = getLoadedModules() | |||
if #modules == 0 then | |||
return outputConsole ( "There are no modules loaded!", thePlayer ) -- Return as no module is loaded, the for has nothing todo | |||
end | |||
for k, v in ipairs ( modules ) do | |||
local moduleInfo = getModuleInfo ( v ) | |||
outputConsole ( moduleInfo.name .. "(" .. v .. ") v" .. moduleInfo.version .. ", author: " .. moduleInfo.author, thePlayer ) | |||
end | |||
end | |||
addCommandHandler ( "checkmodules", printModuleInfo ) | |||
</syntaxhighlight> | |||
==See Also== | ==See Also== | ||
{{Module_functions}} | {{Module_functions}} | ||
[[ru:getModuleInfo]] |
Latest revision as of 15:43, 16 September 2014
This function returns information about the specified module.
Syntax
table getModuleInfo ( string moduleName )
Required Arguments
- moduleName: A string containing the module you wish to get information of e.g. "hashing.dll"
Returns
Returns a table containing information about module. These keys are present in the table:
- version: Module version in format X.XX
- name: Module name
- author: Module author
If invalid name for module is passed, it will return false.
Example
This example adds a command checkmodules with which you can view information about currently loaded modules.
function printModuleInfo ( thePlayer ) local modules = getLoadedModules() if #modules == 0 then return outputConsole ( "There are no modules loaded!", thePlayer ) -- Return as no module is loaded, the for has nothing todo end for k, v in ipairs ( modules ) do local moduleInfo = getModuleInfo ( v ) outputConsole ( moduleInfo.name .. "(" .. v .. ") v" .. moduleInfo.version .. ", author: " .. moduleInfo.author, thePlayer ) end end addCommandHandler ( "checkmodules", printModuleInfo )