Модуль:ChatCommandslist
Материал из Eco - Русская Wiki
Для документации этого модуля может быть создана страница Модуль:ChatCommandslist/doc
local p = {}
function p.main()
local wiki = ''
-- import the required modules
local commandsData = require( "Module:CommandData" )
local commands = commandsData.commands
-- create the header of the table
local header = "<table class=\"wikitable sortable\"> \n "
header = header .. "<tr> \n "
header = header .. "<th>Уровень<br>доступа</th> \n "
header = header .. "<th>Команда</th> \n "
header = header .. "<th>Быстрый<br>вызов</th> \n "
header = header .. "<th>Описание</th> \n "
header = header .. "<th>Аргументы</th> \n "
header = header .. "</tr> \n "
wiki = header
for k,v in pairs(commands) do
local row = ''
row = row .. "<tr> \n "
if (v.parent == nil) then v.parent = '' else v.parent = v.parent .. " " end
if (v.parameters == nil) then v.parameters= '-'
else
if (v.parameters.Arg1 ~= nil) then ARG1 = v.parameters.Arg1[1] .. " (" .. v.parameters.Arg1[2] .. ")<br>" else ARG1 = "" end
if (v.parameters.Arg2 ~= nil) then ARG2 = v.parameters.Arg2[1] .. " (" .. v.parameters.Arg2[2] .. ")<br>" else ARG2 = "" end
if (v.parameters.Arg3 ~= nil) then ARG3 = v.parameters.Arg3[1] .. " (" .. v.parameters.Arg3[2] .. ")<br>" else ARG3 = "" end
if (v.parameters.Arg4 ~= nil) then ARG4 = v.parameters.Arg4[1] .. " (" .. v.parameters.Arg4[2] .. ")<br>" else ARG4 = "" end
if (v.parameters.Arg5 ~= nil) then ARG5 = v.parameters.Arg5[1] .. " (" .. v.parameters.Arg5[2] .. ")<br>" else ARG5 = "" end
if (v.parameters.Arg6 ~= nil) then ARG6 = v.parameters.Arg6[1] .. " (" .. v.parameters.Arg6[2] .. ")<br>" else ARG6 = "" end
v.parameters= ARG1 .. ARG2 .. ARG3 .. ARG4 .. ARG5 .. ARG6
end
if (v.shortCut ~= '') then v.shortCut = "/".. v.shortCut end
row = row .. "<td>" .. v.level.. " </td> \n"
row = row .. "<td>/" .. v.parent .. v.command.. " </td> \n"
row = row .. "<td>" .. v.shortCut .. " </td> \n"
row = row .. "<td>" .. v.helpText .. " </td> \n"
row = row .. "<td>" .. v.parameters .. "</td> \n"
row = row .. "</tr>"
wiki = wiki .. row
end
wiki = wiki .. " </table>"
return wiki
end
return p