GetModuleInfo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
string getModuleInfo ( string moduleName, string information )
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"
*'''information:''' A string containing the information you wish to retrieve. Currently supported parametres are
**'''Version'''
**'''Name'''
**'''Author'''


===Returns===
===Returns===
Returns a [[string]] with the requested information about the module. If invalid names for parameters are passed, it will return ''false''.
Returns a [[table]] contraining 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==
Line 28: Line 28:


     for k, v in ipairs ( modules ) do
     for k, v in ipairs ( modules ) do
         local moduleName = getModuleInfo ( v, "Name" )
         local moduleInfo = getModuleInfo ( v )
        local moduleVersion = getModuleInfo ( v, "Version" )
         outputConsole ( moduleInfo.name .. "(" .. v .. ") v" .. moduleInfo.version .. ", author: " .. moduleInfo.author, thePlayer )
        local moduleAuthor = getModuleInfo ( v, "Author" )
         outputConsole ( moduleName .. "(" .. v .. ") v" .. moduleVersion .. ", author: " .. moduleAuthor, thePlayer )
     end
     end
end
end

Revision as of 19:39, 18 May 2009

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 contraining 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
        outputConsole ( "There are no modules loaded!", thePlayer )
    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 )

See Also