diff options
author | Alexander Harkness <bearbin@gmail.com> | 2013-07-27 17:16:04 +0200 |
---|---|---|
committer | Alexander Harkness <bearbin@gmail.com> | 2013-07-27 17:16:04 +0200 |
commit | 0623a4f9be1c21651ea212f7b4d86136a67ddffe (patch) | |
tree | 5a96f13f72fa394bf74d10839a76ec7a1eac9275 /Core/help.lua | |
parent | Removed all the pre-exising core files. (diff) | |
download | cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.tar cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.tar.gz cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.tar.bz2 cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.tar.lz cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.tar.xz cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.tar.zst cuberite-0623a4f9be1c21651ea212f7b4d86136a67ddffe.zip |
Diffstat (limited to 'Core/help.lua')
-rw-r--r-- | Core/help.lua | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/Core/help.lua b/Core/help.lua new file mode 100644 index 000000000..339fc054b --- /dev/null +++ b/Core/help.lua @@ -0,0 +1,41 @@ +function HandleHelpCommand(Split, Player) + local PluginManager = cRoot:Get():GetPluginManager() + + local LinesPerPage = 8; + local CurrentPage = 1; + local CurrentLine = 0; + local PageRequested = 1; + local Output = {}; + + if (#Split == 2) then + PageRequested = tonumber(Split[2]); + end + + local Process = function(Command, Permission, HelpString) + if not(Player:HasPermission(Permission)) then + return false; + end; + if (HelpString == "") then + return false; + end; + + CurrentLine = CurrentLine + 1; + CurrentPage = math.floor(CurrentLine / LinesPerPage) + 1; + if (CurrentPage ~= PageRequested) then + return false; + end; + table.insert(Output, cChatColor.Blue .. Command .. HelpString); + end + + 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 .. "---------- [COMMANDS HELP " .. cChatColor.Gold .. "(Page " .. PageRequested .. " / " .. CurrentPage .. ")" .. cChatColor.Purple .. "] -----------"); + Player:SendMessage(cChatColor.Purple .. "'-' means no prefix, '~' means a value is required."); + for idx, msg in ipairs(Output) do + Player:SendMessage(msg); + end; + + return true +end
\ No newline at end of file |