GetLoadedModules: Difference between revisions
Jump to navigation
Jump to search
(Added.) |
mNo edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 16: | Line 16: | ||
==Example== | ==Example== | ||
<!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | <!-- Add the code below, an emphasis should be on making it clear, not optimized. You could provide two versions if you wish, one clear and well commented, the other optimized --> | ||
Adds a command that lists all loaded modules in the server log. | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function checkModules() | function checkModules() | ||
Line 21: | Line 22: | ||
if #modules == 0 then | if #modules == 0 then | ||
outputServerLog("No modules are loaded!") | return outputServerLog("No modules are loaded!") | ||
end | |||
for k,v in ipairs(modules) do | |||
outputServerLog( v ) | |||
end | |||
outputServerLog("Loaded " .. #modules .. " modules in total.") | |||
end | end | ||
addCommandHandler("modules", checkModules) | addCommandHandler("modules", checkModules) | ||
Line 37: | Line 37: | ||
<!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | <!-- Change FunctionArea to the area that this function is in on the main function list page, e.g. Server, Player, Vehicle etc --> | ||
{{Module_functions}} | {{Module_functions}} | ||
[[ru:getLoadedModules]] |
Latest revision as of 15:18, 16 September 2014
This function returns all the currently loaded modules of the server.
Syntax
table getLoadedModules ()
Returns
Returns a table of all the currently loaded modules. If no modules are loaded, the table will be empty.
Example
Adds a command that lists all loaded modules in the server log.
function checkModules() local modules = getLoadedModules() if #modules == 0 then return outputServerLog("No modules are loaded!") end for k,v in ipairs(modules) do outputServerLog( v ) end outputServerLog("Loaded " .. #modules .. " modules in total.") end addCommandHandler("modules", checkModules)