Files
cuberite-2a/MCServer/Plugins/Core/help.lua
T

40 lines
1.1 KiB
Lua
Raw Normal View History

2013-02-01 19:55:42 +00:00
function HandleHelpCommand(Split, Player)
2012-01-26 22:44:37 +00:00
local PluginManager = cRoot:Get():GetPluginManager()
2013-02-01 19:55:42 +00:00
local LinesPerPage = 9;
local CurrentPage = 1;
local CurrentLine = 0;
local PageRequested = 1;
local Output = {};
2012-01-26 22:44:37 +00:00
2013-02-01 19:55:42 +00:00
if (#Split == 2) then
PageRequested = tonumber(Split[2]);
2012-01-26 22:44:37 +00:00
end
2013-02-01 19:55:42 +00:00
local Process = function(Command, Permission, HelpString)
if not(Player:HasPermission(Permission)) then
return false;
end;
if (HelpString == "") then
return false;
end;
2012-01-26 22:44:37 +00:00
2013-02-01 19:55:42 +00:00
CurrentLine = CurrentLine + 1;
CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1;
if (CurrentPage ~= PageRequested) then
return false;
end;
table.insert(Output, cChatColor.Blue .. Command .. HelpString);
2012-01-26 22:44:37 +00:00
end
2013-02-01 19:55:42 +00:00
PluginManager:ForEachCommand(Process);
-- CurrentPage now contains the total number of pages, and Output has the individual help lines to be sent
Player:SendMessage(cChatColor.Purple .. "- All commands - " .. cChatColor.Gold .. "[Page " .. PageRequested .. " / " .. CurrentPage .. "]");
for idx, msg in ipairs(Output) do
Player:SendMessage(msg);
end;
2012-01-26 22:44:37 +00:00
return true
end