diff options
author | madmaxoft <github@xoft.cz> | 2014-01-06 10:25:52 +0100 |
---|---|---|
committer | madmaxoft <github@xoft.cz> | 2014-01-06 10:25:52 +0100 |
commit | 8b6be58ad9c5f0769b3982501e806fd9a21b1756 (patch) | |
tree | a69aa4a4184f416d63c96eb7a16ed8fa6eb85362 /MCServer/Plugins | |
parent | Fixed wrong enqueueing. (diff) | |
download | cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.tar cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.tar.gz cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.tar.bz2 cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.tar.lz cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.tar.xz cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.tar.zst cuberite-8b6be58ad9c5f0769b3982501e806fd9a21b1756.zip |
Diffstat (limited to '')
-rw-r--r-- | MCServer/Plugins/InfoDump.lua | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/MCServer/Plugins/InfoDump.lua b/MCServer/Plugins/InfoDump.lua index 54d7a6042..df47d566b 100644 --- a/MCServer/Plugins/InfoDump.lua +++ b/MCServer/Plugins/InfoDump.lua @@ -53,8 +53,24 @@ lfs = require("lfs"); local function ForumizeString(a_Str) assert(type(a_Str) == "string"); + -- Remove the indentation, unless in the code tag: + -- Only one code or /code tag per line is supported! + local IsInCode = false; + local function RemoveIndentIfNotInCode(s) + if (IsInCode) then + -- we're in code section, check if this line terminates it + IsInCode = (s:find("{%%/code}") ~= nil); + return s .. "\n"; + else + -- we're not in code section, check if this line starts it + IsInCode = (s:find("{%%code}") ~= nil); + return s:gsub("^%s*", "") .. "\n"; + end + end + a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode); + -- Replace multiple line ends with {%p} and single line ends with a space, - -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum + -- so that manual word-wrap in the Info.lua file doesn't wrap in the forum. a_Str = a_Str:gsub("\n\n", "{%%p}"); a_Str = a_Str:gsub("\n", " "); @@ -146,19 +162,22 @@ end --- Writes the specified command detailed help array to the output file, in the forum dump format -local function WriteCommandDetailedHelpForum(a_CmdString, a_DetailedHelp, f) +local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f) assert(type(a_CmdString) == "string"); - assert(type(a_DetailedHelp) == "table"); + assert(type(a_ParameterCombinations) == "table"); assert(f ~= nil); - if (#a_DetailedHelp == 0) then + if (#a_ParameterCombinations == 0) then -- No explicit parameter combinations to write return; end f:write("The following parameter combinations are recognized:\n"); - for idx, combination in ipairs(a_DetailedHelp) do - f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color] - ", ForumizeString(combination.Help)); + for idx, combination in ipairs(a_ParameterCombinations) do + f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params, "[/color]"); + if (combination.Help ~= nil) then + f:write(" - ", ForumizeString(combination.Help)); + end if (combination.Permission ~= nil) then f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')"); end @@ -194,8 +213,8 @@ local function WriteCommandsCategoryForum(a_Category, f) if (cmd.Info.DetailedDescription ~= nil) then f:write(cmd.Info.DetailedDescription); end - if (cmd.Info.DetailedHelp ~= nil) then - WriteCommandDetailedHelpForum(cmd.CommandString, cmd.Info.DetailedHelp, f); + if (cmd.Info.ParameterCombinations ~= nil) then + WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f); end end f:write("[/list]\n\n") |