From 410ba0e331f145264581d1c8d5f61a61c3403c86 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 10 Sep 2013 22:02:18 +0200 Subject: DumpAPI: Basic HTML output for classes --- MCServer/Plugins/APIDump/main.lua | 184 ++++++++++++++++++++++++++++++-------- 1 file changed, 148 insertions(+), 36 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index d0a1da3b1..0f63f9ab5 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -16,10 +16,13 @@ function Initialize(Plugin) LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) -- dump all available API functions and objects: - DumpAPI(); + -- DumpAPITxt(); -- Dump all available API objects in wiki-style tables: - DumpAPIWiki(); + -- DumpAPIWiki(); + + -- Dump all available API object in HTML format into a subfolder: + DumpAPIHtml(); return true end @@ -29,7 +32,7 @@ end -function DumpAPI() +function DumpAPITxt() LOG("Dumping all available functions to API.txt..."); function dump (prefix, a, Output) for i, v in pairs (a) do @@ -67,13 +70,55 @@ end function DumpAPIWiki() + LOG("Dumping all available functions and constants to API_wiki.txt..."); + + local API, Globals = CreateAPITables(); + + -- Now dump the whole thing into a file, formatted as a wiki table: + local function WriteClass(a_File, a_ClassAPI) + if (#a_ClassAPI.Functions > 0) then + a_File:write("Functions:\n"); + a_File:write("^ Function name ^ Parameters ^ Return value ^ Note ^\n"); + for i, n in ipairs(a_ClassAPI.Functions) do + a_File:write("| " .. n[1] .. " | | | |\n"); + end + a_File:write("\n\n"); + end + + if (#a_ClassAPI.Constants > 0) then + a_File:write("Constants:\n"); + a_File:write("^ Constant ^ Value ^ Note ^\n"); + for i, n in ipairs(a_ClassAPI.Constants) do + a_File:write("| " .. n[1] .. " | " .. n[2] .. " | |\n"); + end + a_File:write("\n\n"); + end + end + + local f = io.open("API_wiki.txt", "w"); + for i, n in ipairs(API) do + f:write("Class " .. n[1] .. "\n"); + WriteClass(f, n[2]); + f:write("\n\n\n----------------\n"); + end + f:write("globals:\n"); + WriteClass(f, Globals); + f:close(); + + LOG("API_wiki.txt file written"); +end + + + + +function CreateAPITables() --[[ We want an API table of the following shape: local API = { {"cCuboid", { Functions = { - "Sort", - "IsInside" + {"Sort"}, -- The extra table will be used to later add params, return values and notes + {"IsInside"} }, Constants = { } @@ -102,14 +147,12 @@ function DumpAPIWiki() }; --]] - LOG("Dumping all available functions and constants to API_wiki.txt..."); - local Globals = {Functions = {}, Constants = {}}; local API = {}; local function Add(a_APIContainer, a_ClassName, a_ClassObj) if (type(a_ClassObj) == "function") then - table.insert(a_APIContainer.Functions, a_ClassName); + table.insert(a_APIContainer.Functions, {a_ClassName}); elseif (type(a_ClassObj) == "number") then table.insert(a_APIContainer.Constants, {a_ClassName, a_ClassObj}); end @@ -117,7 +160,11 @@ function DumpAPIWiki() local function SortClass(a_ClassAPI) -- Sort the function list and constant lists: - table.sort(a_ClassAPI.Functions); + table.sort(a_ClassAPI.Functions, + function(f1, f2) + return (f1[1] < f2[1]); + end + ); table.sort(a_ClassAPI.Constants, function(c1, c2) return (c1[1] < c2[1]); @@ -154,38 +201,103 @@ function DumpAPIWiki() end ); - -- Now dump the whole thing into a file, formatted as a wiki table: - local function WriteClass(a_File, a_ClassAPI) - if (#a_ClassAPI.Functions > 0) then - a_File:write("Functions:\n"); - a_File:write("^ Function name ^ Parameters ^ Return value ^ Note ^\n"); - for i, n in ipairs(a_ClassAPI.Functions) do - a_File:write("| " .. n .. " | | | |\n"); - end - a_File:write("\n\n"); - end - - if (#a_ClassAPI.Constants > 0) then - a_File:write("Constants:\n"); - a_File:write("^ Constant ^ Value ^ Note ^\n"); - for i, n in ipairs(a_ClassAPI.Constants) do - a_File:write("| " .. n[1] .. " | " .. n[2] .. " | |\n"); - end - a_File:write("\n\n"); - end - end + return API, Globals; +end + + + + + +function DumpAPIHtml() + LOG("Dumping all available functions and constants to API subfolder..."); + + local API, Globals = CreateAPITables(); - local f = io.open("API_wiki.txt", "w"); + -- Create the folder: + os.execute("mkdir API"); + + -- Create a "class index" file, write each class as a link to that file, + -- then dump class contents into class-specific file + local f = io.open("API/index.html", "w"); + f:write([[MCServer API - class index + + + "); f:close(); +end + + + + +function WriteHtmlClass(a_ClassAPI) + local cf, err = io.open("API/" .. a_ClassAPI[1] .. ".html", "w"); + if (cf == nil) then + return; + end - LOG("API_wiki.txt file written"); + local function LinkifyString(a_String) + -- TODO: Make a link out of anything with the special linkifying syntax [[link|title]] + -- a_String:gsub("\[\[" .. "[ + return a_String; + end + + cf:write([[MCServer API - ]] .. a_ClassAPI[1] .. [[ + + +

Contents

+ "); + + -- Write the class description: + cf:write("

" .. a_ClassAPI[1] .. "

\n"); + if (a_ClassAPI.Description ~= nil) then + cf:write("

"); + cf:write(n.Description); + cf:write("

\n"); + end; + + -- Write the constants: + if (#a_ClassAPI[2].Constants > 0) then + cf:write("

Constants

\n"); + cf:write("\n"); + for i, n in ipairs(a_ClassAPI[2].Constants) do + cf:write(""); + cf:write(""); + cf:write("\n"); + end + cf:write("
NameValueNotes
" .. n[1] .. "" .. n[2] .. "" .. LinkifyString(n.Notes or "") .. "
\n"); + end + + -- Write the functions: + if (#a_ClassAPI[2].Functions > 0) then + cf:write("

Functions

\n"); + cf:write("\n"); + for i, f in ipairs(a_ClassAPI[2].Functions) do + cf:write(""); + cf:write(""); + cf:write(""); + cf:write("\n"); + end + cf:write("
NameParametersReturn valueNotes
" .. f[1] .. "" .. LinkifyString(f.Params or "").. "" .. LinkifyString(f.Return or "").. "" .. LinkifyString(f.Notes or "") .. "
\n"); + end + + cf:write(""); + cf:close(); end -- cgit v1.2.3 From 8012b8be6eb667ed018470e08d2b657b62afcd59 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Sep 2013 16:57:57 +0200 Subject: APIDump: First attempt at outputting annotations in the HTML format --- MCServer/Plugins/APIDump/APIDesc.lua | 68 +++++++++++ MCServer/Plugins/APIDump/APIDump.deproj | 3 + MCServer/Plugins/APIDump/main.lua | 193 ++++++++++++++++++-------------- 3 files changed, 179 insertions(+), 85 deletions(-) create mode 100644 MCServer/Plugins/APIDump/APIDesc.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua new file mode 100644 index 000000000..44981fdd7 --- /dev/null +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -0,0 +1,68 @@ + +-- APIDesc.lua + +-- Contains the API objects' descriptions + + + + +g_APIDesc = +{ + Classes = + { + cBlockArea = + { + Desc = [[ + This class is used when multiple adjacent blocks are to be manipulated. Because of chunking + and multithreading, manipulating single blocks using {{api:cWorld|cWorld:SetBlock}}() is a rather + time-consuming operation (locks for exclusive access need to be obtained, chunk lookup is done + for each block), so whenever you need to manipulate multiple adjacent blocks, it's better to wrap + the operation into a cBlockArea access. cBlockArea is capable of reading / writing across chunk + boundaries, has no chunk lookups for get and set operations and is not subject to multithreading + locking (because it is not shared among threads).

+

+ cBlockArea remembers its origin (MinX, MinY, MinZ coords in the Read() call) and therefore supports + absolute as well as relative get / set operations. Despite that, the contents of a cBlockArea can + be written back into the world at any coords.

+

+ cBlockArea can hold any combination of the following datatypes:

+ Read() and Write() functions have parameters that tell the class which datatypes to read / write. + Note that a datatype that has not been read cannot be written (FIXME).

+

+ Typical usage:

+ ]], + Functions = + { + Clear = { Notes = "Clears the object, resets it to zero size" }, + CopyFrom = { Params = "{{cBlockArea|BlockAreaSrc}}", Notes = "Copies contents from BlockAreaSrc into self"}, + CopyTo = { Params = "{{cBlockArea|BlockAreaDst}}", Notes = "Copies contents from self into BlockAreaDst"}, + GetBlockLight = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the blocklight at the specified absolute coords"}, + }, + }, + + cBlockEntity = + { + } + }, + + IgnoreFunctions = + { + "globals.assert", + "globals.collectgarbage", + "globals.xpcall", + } +} ; + + + + diff --git a/MCServer/Plugins/APIDump/APIDump.deproj b/MCServer/Plugins/APIDump/APIDump.deproj index 0d6ad82fa..9ee9170f2 100644 --- a/MCServer/Plugins/APIDump/APIDump.deproj +++ b/MCServer/Plugins/APIDump/APIDump.deproj @@ -1,5 +1,8 @@ + + APIDesc.lua + main.lua diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 0f63f9ab5..c13611d2e 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -7,8 +7,17 @@ +-- Global variables: +g_Plugin = nil; + + + + + function Initialize(Plugin) + g_Plugin = Plugin; + Plugin:SetName("APIDump") Plugin:SetVersion(1) @@ -18,12 +27,9 @@ function Initialize(Plugin) -- dump all available API functions and objects: -- DumpAPITxt(); - -- Dump all available API objects in wiki-style tables: - -- DumpAPIWiki(); - -- Dump all available API object in HTML format into a subfolder: DumpAPIHtml(); - + return true end @@ -69,69 +75,30 @@ end -function DumpAPIWiki() - LOG("Dumping all available functions and constants to API_wiki.txt..."); - - local API, Globals = CreateAPITables(); - - -- Now dump the whole thing into a file, formatted as a wiki table: - local function WriteClass(a_File, a_ClassAPI) - if (#a_ClassAPI.Functions > 0) then - a_File:write("Functions:\n"); - a_File:write("^ Function name ^ Parameters ^ Return value ^ Note ^\n"); - for i, n in ipairs(a_ClassAPI.Functions) do - a_File:write("| " .. n[1] .. " | | | |\n"); - end - a_File:write("\n\n"); - end - - if (#a_ClassAPI.Constants > 0) then - a_File:write("Constants:\n"); - a_File:write("^ Constant ^ Value ^ Note ^\n"); - for i, n in ipairs(a_ClassAPI.Constants) do - a_File:write("| " .. n[1] .. " | " .. n[2] .. " | |\n"); - end - a_File:write("\n\n"); - end - end - - local f = io.open("API_wiki.txt", "w"); - for i, n in ipairs(API) do - f:write("Class " .. n[1] .. "\n"); - WriteClass(f, n[2]); - f:write("\n\n\n----------------\n"); - end - f:write("globals:\n"); - WriteClass(f, Globals); - f:close(); - - LOG("API_wiki.txt file written"); -end - - - function CreateAPITables() --[[ We want an API table of the following shape: local API = { - {"cCuboid", { + { + Name = "cCuboid", Functions = { - {"Sort"}, -- The extra table will be used to later add params, return values and notes - {"IsInside"} + {Name = "Sort"}, + {Name = "IsInside"} }, Constants = { } }}, - {"cBlockArea", { + { + Name = "cBlockArea", Functions = { - "Clear", - "CopyFrom", + {Name = "Clear"}, + {Name = "CopyFrom"}, ... } Constants = { - {"baTypes", 0}, - {"baMetas", 1}, + {Name = "baTypes", Value = 0}, + {Name = "baMetas", Value = 1}, ... } ... @@ -152,9 +119,9 @@ function CreateAPITables() local function Add(a_APIContainer, a_ClassName, a_ClassObj) if (type(a_ClassObj) == "function") then - table.insert(a_APIContainer.Functions, {a_ClassName}); + table.insert(a_APIContainer.Functions, {Name = a_ClassName}); elseif (type(a_ClassObj) == "number") then - table.insert(a_APIContainer.Constants, {a_ClassName, a_ClassObj}); + table.insert(a_APIContainer.Constants, {Name = a_ClassName, Value = a_ClassObj}); end end @@ -162,18 +129,18 @@ function CreateAPITables() -- Sort the function list and constant lists: table.sort(a_ClassAPI.Functions, function(f1, f2) - return (f1[1] < f2[1]); + return (f1.Name < f2.Name); end ); table.sort(a_ClassAPI.Constants, function(c1, c2) - return (c1[1] < c2[1]); + return (c1.Name < c2.Name); end ); end; - local function ParseClass(a_ClassObj) - local res = {Functions = {}, Constants = {}}; + local function ParseClass(a_ClassName, a_ClassObj) + local res = {Name = a_ClassName, Functions = {}, Constants = {}}; for i, v in pairs(a_ClassObj) do Add(res, i, v); end @@ -188,7 +155,7 @@ function CreateAPITables() local StartLetter = GetChar(i, 0); if (StartLetter == "c") then -- Starts with a "c", handle it as a MCS API class - table.insert(API, {i, ParseClass(v)}); + table.insert(API, ParseClass(i, v)); end else Add(Globals, i, v); @@ -197,7 +164,7 @@ function CreateAPITables() SortClass(Globals); table.sort(API, function(c1, c2) - return (c1[1] < c2[1]); + return (c1.Name < c2.Name); end ); @@ -212,8 +179,13 @@ function DumpAPIHtml() LOG("Dumping all available functions and constants to API subfolder..."); local API, Globals = CreateAPITables(); + Globals.Name = "Globals"; + table.insert(API, Globals); + + -- Read in the descriptions: + ReadDescriptions(API); - -- Create the folder: + -- Create the output folder: os.execute("mkdir API"); -- Create a "class index" file, write each class as a link to that file, @@ -224,9 +196,9 @@ function DumpAPIHtml()
    ]]); - for i, n in ipairs(API) do - f:write("
  • " .. n[1] .. "
  • \n"); - WriteHtmlClass(n); + for i, cls in ipairs(API) do + f:write("
  • " .. cls.Name .. "
  • \n"); + WriteHtmlClass(cls); end f:write("
"); f:close(); @@ -235,19 +207,70 @@ end + +function ReadDescriptions(a_API) + local UnexportedDocumented = {}; -- List of API objects that are documented but not exported, simply a list of names + for i, cls in ipairs(a_API) do + local APIDesc = g_APIDesc.Classes[cls.Name]; + if (APIDesc ~= nil) then + cls.Desc = APIDesc.Desc; + + if (APIDesc.Functions ~= nil) then + -- Assign function descriptions: + for j, func in ipairs(cls.Functions) do + -- func is {"FuncName"}, add Parameters, Return and Notes from g_APIDesc + local FnDesc = APIDesc.Functions[func.Name]; + if (FnDesc ~= nil) then + func.Params = FnDesc.Params; + func.Return = FnDesc.Return; + func.Notes = FnDesc.Notes; + FnDesc.IsExported = true; + end + end -- for j, func + + -- Add all non-exported function descriptions to UnexportedDocumented: + for j, func in pairs(APIDesc.Functions) do + -- TODO + end + end -- if (APIDesc.Functions ~= nil) + + if (APIDesc.Constants ~= nil) then + -- Assign constant descriptions: + for j, cons in ipairs(cls.Constants) do + local CnDesc = APIDesc.Constants[cons.Name]; + if (CnDesc ~= nil) then + cons.Notes = CnDesc.Notes; + CnDesc.IsExported = true; + end + end -- for j, cons + + -- Add all non-exported constant descriptions to UnexportedDocumented: + for j, cons in pairs(APIDesc.Constants) do + -- TODO + end + end -- if (APIDesc.Constants ~= nil) + + end + end -- for i, class +end + + + + + function WriteHtmlClass(a_ClassAPI) - local cf, err = io.open("API/" .. a_ClassAPI[1] .. ".html", "w"); + local cf, err = io.open("API/" .. a_ClassAPI.Name .. ".html", "w"); if (cf == nil) then return; end local function LinkifyString(a_String) - -- TODO: Make a link out of anything with the special linkifying syntax [[link|title]] - -- a_String:gsub("\[\[" .. "[ + -- TODO: Make a link out of anything with the special linkifying syntax {{link|title}} + -- a_String:gsub("{{([^|]*)|[^}]*}}", "%2"); return a_String; end - cf:write([[MCServer API - ]] .. a_ClassAPI[1] .. [[ + cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[

Contents

@@ -255,43 +278,43 @@ function WriteHtmlClass(a_ClassAPI) ]]); -- Write the table of contents: - if (#a_ClassAPI[2].Constants > 0) then + if (#a_ClassAPI.Constants > 0) then cf:write("
  • Constants
  • \n"); end - if (#a_ClassAPI[2].Functions > 0) then + if (#a_ClassAPI.Functions > 0) then cf:write("
  • Functions
  • \n"); end cf:write(""); -- Write the class description: - cf:write("

    " .. a_ClassAPI[1] .. "

    \n"); - if (a_ClassAPI.Description ~= nil) then + cf:write("

    " .. a_ClassAPI.Name .. "

    \n"); + if (a_ClassAPI.Desc ~= nil) then cf:write("

    "); - cf:write(n.Description); + cf:write(a_ClassAPI.Desc); cf:write("

    \n"); end; -- Write the constants: - if (#a_ClassAPI[2].Constants > 0) then + if (#a_ClassAPI.Constants > 0) then cf:write("

    Constants

    \n"); cf:write("\n"); - for i, n in ipairs(a_ClassAPI[2].Constants) do - cf:write(""); - cf:write(""); - cf:write("\n"); + for i, cons in ipairs(a_ClassAPI.Constants) do + cf:write(""); + cf:write(""); + cf:write("\n"); end cf:write("
    NameValueNotes
    " .. n[1] .. "" .. n[2] .. "" .. LinkifyString(n.Notes or "") .. "
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "") .. "
    \n"); end -- Write the functions: - if (#a_ClassAPI[2].Functions > 0) then + if (#a_ClassAPI.Functions > 0) then cf:write("

    Functions

    \n"); cf:write("\n"); - for i, f in ipairs(a_ClassAPI[2].Functions) do - cf:write(""); - cf:write(""); - cf:write(""); - cf:write("\n"); + for i, func in ipairs(a_ClassAPI.Functions) do + cf:write(""); + cf:write(""); + cf:write(""); + cf:write("\n"); end cf:write("
    NameParametersReturn valueNotes
    " .. f[1] .. "" .. LinkifyString(f.Params or "").. "" .. LinkifyString(f.Return or "").. "" .. LinkifyString(f.Notes or "") .. "
    " .. func.Name .. "" .. LinkifyString(func.Params or "").. "" .. LinkifyString(func.Return or "").. "" .. LinkifyString(func.Notes or "") .. "
    \n"); end -- cgit v1.2.3 From 7dce0c276afea3806764f5e6849e17d69187ef4b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Sep 2013 21:21:51 +0200 Subject: APIDump: Initial implementation of wiki-to-lua conversion --- MCServer/Plugins/APIDump/main.lua | 88 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index c13611d2e..7e888a218 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -27,6 +27,9 @@ function Initialize(Plugin) -- dump all available API functions and objects: -- DumpAPITxt(); + -- DEBUG: Convert the wiki dump into APIDesc + ConvertWikiToDesc(); + -- Dump all available API object in HTML format into a subfolder: DumpAPIHtml(); @@ -185,12 +188,20 @@ function DumpAPIHtml() -- Read in the descriptions: ReadDescriptions(API); - -- Create the output folder: - os.execute("mkdir API"); - -- Create a "class index" file, write each class as a link to that file, -- then dump class contents into class-specific file local f = io.open("API/index.html", "w"); + if (f == nil) then + -- Create the output folder + os.execute("mkdir API"); + local err; + f, err = io.open("API/index.html", "w"); + if (f == nil) then + LOGINFO("Cannot output HTML API: " .. err); + return; + end + end + f:write([[MCServer API - class index @@ -202,6 +213,8 @@ function DumpAPIHtml() end f:write(""); f:close(); + + LOG("API subfolder written"); end @@ -326,3 +339,72 @@ end + +-- This function converts the wiki dump, as provided by FakeTruth, into the APIDesc format. +-- Dump available in forum: http://forum.mc-server.org/showthread.php?tid=1214&pid=9892#pid9892 +-- The dump is expected unpacked as "wikipages/api/*.txt", in the executable folder +-- Only Windows-style paths are supported for now, since this is a one-time action +function ConvertWikiToDesc() + local fout = io.open("APIDesc.wiki.lua", "w"); + for filename in io.popen([[dir wikipages\\api\\*.txt /b]]):lines() do + -- Read file + local fin = io.open("wikipages\\api\\" .. filename, "r"); + if (fin ~= nil) then + -- Read and parse the info from the file + local state = 0; + local Desc = ""; + local Constants = {}; + local Functions = {}; + for line in fin:lines() do + if (line:find("======") ~= nil) then + state = 1; -- The following is the class description + elseif (line:find("===== Constants") ~= nil) then + state = 2; -- The following is the constants description + elseif (line:find("===== Functions") ~= nil) then + state = 3; -- The following is the functions description + elseif (line:find("=====") ~= nil) then + state = 4; -- The following is an unknown text, skip it entirely + elseif (state == 1) then + -- Class description: + if (line == "") then + line = "

    \n

    "; -- Replace empty lines with paragraph delimiters + end + Desc = Desc .. line .. "\n"; + elseif (state == 2) then + -- Constants: + local Split = StringSplitAndTrim(line, "|"); + if (#Split >= 3) then + -- Split[1] is always "", because the line starts with a "|" + table.insert(Constants, {Name = Split[2], Notes = Split[3]}); + end + elseif (state == 3) then + -- Functions: + local Split = StringSplitAndTrim(line, "|"); + if (#Split >= 5) then + -- Split[1] is always "", because the line starts with a "|" + table.insert(Functions, {Name = Split[2], Params = Split[3], Return = Split[4], Notes = Split[5]}); + end + end + end -- for line + fin:close(); + + -- Write the info into the output file: + fout:write(filename:match("[^\.]*") .. " =\n{\tFunctions =\n\t{\n"); + for i, func in ipairs(Functions) do + fout:write("\t\t{ " .. func.Name .. " = { Params = \"" .. func.Params .. "\", Return =\"" .. + func.Return .. "\", Desc = \"" .. func.Notes .. "\" },\n" + ); + end + fout:write("\t},\n\tConstants =\n\t{\n"); + for i, cons in ipairs(Constants) do + fout:write("\t\t{ " .. cons.Name .. " = { Notes = \"" .. cons.Notes .. "\" },\n"); + end + fout:write("\t},\n},\n\n\n"); + end -- if fin ~= nil + end -- for file + fout:close(); +end + + + + -- cgit v1.2.3 From f845c1f72c3e25d0c6b9886c90cc26e02aa9539e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Sep 2013 21:22:10 +0200 Subject: APIDump: Added a testing constant description --- MCServer/Plugins/APIDump/APIDesc.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 44981fdd7..dad123ed6 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -48,6 +48,10 @@ g_APIDesc = CopyTo = { Params = "{{cBlockArea|BlockAreaDst}}", Notes = "Copies contents from self into BlockAreaDst"}, GetBlockLight = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the blocklight at the specified absolute coords"}, }, + Constants = + { + baTypes = { Notes = "Operation should work on block types" }, + }, }, cBlockEntity = -- cgit v1.2.3 From 068708145b866d1104d8f3dfe1b33f64fa58fea0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 11 Sep 2013 21:25:19 +0200 Subject: APIDump: Fixed a missing tab --- MCServer/Plugins/APIDump/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 7e888a218..5025c28f3 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -389,7 +389,7 @@ function ConvertWikiToDesc() fin:close(); -- Write the info into the output file: - fout:write(filename:match("[^\.]*") .. " =\n{\tFunctions =\n\t{\n"); + fout:write(filename:match("[^\.]*") .. " =\n{\n\tFunctions =\n\t{\n"); for i, func in ipairs(Functions) do fout:write("\t\t{ " .. func.Name .. " = { Params = \"" .. func.Params .. "\", Return =\"" .. func.Return .. "\", Desc = \"" .. func.Notes .. "\" },\n" -- cgit v1.2.3 From f553d8e29e2de5030ba402cd5622aab50275b1f6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 18:46:37 +0200 Subject: APIDump: Fixed parsing tables with wiki-links. Also added real class name, description and constructor renaming. --- MCServer/Plugins/APIDump/main.lua | 43 ++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 5025c28f3..c5d251445 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -18,10 +18,9 @@ g_Plugin = nil; function Initialize(Plugin) g_Plugin = Plugin; - Plugin:SetName("APIDump") - Plugin:SetVersion(1) + Plugin:SetName("APIDump"); + Plugin:SetVersion(1); - PluginManager = cRoot:Get():GetPluginManager() LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) -- dump all available API functions and objects: @@ -349,6 +348,8 @@ function ConvertWikiToDesc() for filename in io.popen([[dir wikipages\\api\\*.txt /b]]):lines() do -- Read file local fin = io.open("wikipages\\api\\" .. filename, "r"); + local ClassName = filename:match("[^\.]*"); + local AddNextTime = ""; if (fin ~= nil) then -- Read and parse the info from the file local state = 0; @@ -358,6 +359,13 @@ function ConvertWikiToDesc() for line in fin:lines() do if (line:find("======") ~= nil) then state = 1; -- The following is the class description + ClassName = line:gsub("======", ""); + ClassName = ClassName:match("%w+"); + if (ClassName == nil) then + -- Reset to default + ClassName = filename:match("[^\.]*"); + end + AddNextTime = ""; elseif (line:find("===== Constants") ~= nil) then state = 2; -- The following is the constants description elseif (line:find("===== Functions") ~= nil) then @@ -365,31 +373,46 @@ function ConvertWikiToDesc() elseif (line:find("=====") ~= nil) then state = 4; -- The following is an unknown text, skip it entirely elseif (state == 1) then + -- Class description: + Desc = Desc .. AddNextTime .. line .. "\n"; if (line == "") then - line = "

    \n

    "; -- Replace empty lines with paragraph delimiters + AddNextTime = "

    \n

    "; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line + else + AddNextTime = ""; end - Desc = Desc .. line .. "\n"; elseif (state == 2) then + -- Constants: - local Split = StringSplitAndTrim(line, "|"); + line = line:gsub("| ", "\n"); + local Split = StringSplitAndTrim(line, "\n"); if (#Split >= 3) then -- Split[1] is always "", because the line starts with a "|" - table.insert(Constants, {Name = Split[2], Notes = Split[3]}); + local notes = Split[3] or ""; + notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" + table.insert(Constants, {Name = Split[2], Notes = notes}); end elseif (state == 3) then + -- Functions: - local Split = StringSplitAndTrim(line, "|"); + line = string.gsub(line, "| ", "\n"); + local Split = StringSplitAndTrim(line, "\n"); if (#Split >= 5) then -- Split[1] is always "", because the line starts with a "|" - table.insert(Functions, {Name = Split[2], Params = Split[3], Return = Split[4], Notes = Split[5]}); + local notes = Split[5] or ""; + notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" + local name = (Split[2] or ""); + if ((name == "( )") or (name == "()")) then + name = "constructor"; -- Special name is used for the constructor in the wiki + end + table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); end end end -- for line fin:close(); -- Write the info into the output file: - fout:write(filename:match("[^\.]*") .. " =\n{\n\tFunctions =\n\t{\n"); + fout:write(ClassName .. " =\n{\n\tDesc = [[" .. Desc .. "]]\n\tFunctions =\n\t{\n"); for i, func in ipairs(Functions) do fout:write("\t\t{ " .. func.Name .. " = { Params = \"" .. func.Params .. "\", Return =\"" .. func.Return .. "\", Desc = \"" .. func.Notes .. "\" },\n" -- cgit v1.2.3 From 5b8271517d2f07ec00b13fca2c29c868c6e709ff Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 18:57:21 +0200 Subject: APIDump: replacing wiki-style markup with APIDump-style markup --- MCServer/Plugins/APIDump/main.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index c5d251445..188c6452f 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -357,6 +357,9 @@ function ConvertWikiToDesc() local Constants = {}; local Functions = {}; for line in fin:lines() do + -- Replace wiki-style markup: + line = line:gsub("%[%[.-:.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Plugin:Hook|LinkText]] + line = line:gsub("%[%[.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Class|LinkText]] if (line:find("======") ~= nil) then state = 1; -- The following is the class description ClassName = line:gsub("======", ""); -- cgit v1.2.3 From e9a809dfb9da77b032a98de6395e46a36fb7fa77 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 19:52:47 +0200 Subject: APIDump: The APIDesc from wiki can be read back by Lua. --- MCServer/Plugins/APIDump/main.lua | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 188c6452f..53052da62 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -345,6 +345,7 @@ end -- Only Windows-style paths are supported for now, since this is a one-time action function ConvertWikiToDesc() local fout = io.open("APIDesc.wiki.lua", "w"); + fout:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); for filename in io.popen([[dir wikipages\\api\\*.txt /b]]):lines() do -- Read file local fin = io.open("wikipages\\api\\" .. filename, "r"); @@ -356,10 +357,16 @@ function ConvertWikiToDesc() local Desc = ""; local Constants = {}; local Functions = {}; + local ConstructorNumber = 1; for line in fin:lines() do -- Replace wiki-style markup: line = line:gsub("%[%[.-:.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Plugin:Hook|LinkText]] + line = line:gsub("%[%[.-:.-:(.-)%]%]", "{{%1|%1}}"); -- Replaces [[API:Plugin:Hook]] line = line:gsub("%[%[.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Class|LinkText]] + line = line:gsub("%[%[.-:(.-)%]%]", "{{%1|%1}}"); -- Replaces [[API:Class]] + line = line:gsub("%[%[(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[Class|LinkText]] + line = line:gsub("%[%[(.-)%]%]", "{{%1|%1}}"); -- Replaces [[Class]] + if (line:find("======") ~= nil) then state = 1; -- The following is the class description ClassName = line:gsub("======", ""); @@ -378,10 +385,10 @@ function ConvertWikiToDesc() elseif (state == 1) then -- Class description: - Desc = Desc .. AddNextTime .. line .. "\n"; if (line == "") then - AddNextTime = "

    \n

    "; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line + AddNextTime = "

    \n\t\t

    "; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line else + Desc = Desc .. AddNextTime .. line .. "\n"; AddNextTime = ""; end elseif (state == 2) then @@ -406,7 +413,8 @@ function ConvertWikiToDesc() notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" local name = (Split[2] or ""); if ((name == "( )") or (name == "()")) then - name = "constructor"; -- Special name is used for the constructor in the wiki + name = "constructor" .. ConstructorNumber; -- Special name is used for the constructor in the wiki + ConstructorNumber = ConstructorNumber + 1; end table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); end @@ -415,19 +423,22 @@ function ConvertWikiToDesc() fin:close(); -- Write the info into the output file: - fout:write(ClassName .. " =\n{\n\tDesc = [[" .. Desc .. "]]\n\tFunctions =\n\t{\n"); + fout:write("\t\t" .. ClassName .. " =\n\t\t{\n\t\t\tDesc = [[" .. Desc .. "]],\n\t\t\tFunctions =\n\t\t\t{\n"); for i, func in ipairs(Functions) do - fout:write("\t\t{ " .. func.Name .. " = { Params = \"" .. func.Params .. "\", Return =\"" .. - func.Return .. "\", Desc = \"" .. func.Notes .. "\" },\n" - ); + fout:write(string.format("\t\t\t\t{ %s = { Params = %q, Return = %q, Notes = %q } },\n", + func.Name, func.Params, func.Return, func.Notes + )); end - fout:write("\t},\n\tConstants =\n\t{\n"); + fout:write("\t\t\t},\n\t\t\tConstants =\n\t\t\t{\n"); for i, cons in ipairs(Constants) do - fout:write("\t\t{ " .. cons.Name .. " = { Notes = \"" .. cons.Notes .. "\" },\n"); + fout:write(string.format("\t\t\t\t{ %s = { Notes = %q } },\n", + cons.Name, cons.Notes + )); end - fout:write("\t},\n},\n\n\n"); + fout:write("\t\t\t},\n\t\t},\n\n"); end -- if fin ~= nil end -- for file + fout:write("\t}\n}\n\n\n\n\n\n"); fout:close(); end -- cgit v1.2.3 From b0c4f22e4cd24b4957af91f5bd25610f02b2e580 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 20:10:21 +0200 Subject: APIDump: Added parsing for older wiki format, "Class Definition" header. --- MCServer/Plugins/APIDump/main.lua | 50 ++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 53052da62..4a2582a34 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -380,10 +380,12 @@ function ConvertWikiToDesc() state = 2; -- The following is the constants description elseif (line:find("===== Functions") ~= nil) then state = 3; -- The following is the functions description + elseif (line:find("===== Class [Dd]efinition ==") ~= nil) then + state = 4; -- The following contains both functions' and constants' descriptions elseif (line:find("=====") ~= nil) then - state = 4; -- The following is an unknown text, skip it entirely + state = 5; -- The following is an unknown text, skip it entirely + elseif (state == 1) then - -- Class description: if (line == "") then AddNextTime = "

    \n\t\t

    "; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line @@ -391,8 +393,8 @@ function ConvertWikiToDesc() Desc = Desc .. AddNextTime .. line .. "\n"; AddNextTime = ""; end + elseif (state == 2) then - -- Constants: line = line:gsub("| ", "\n"); local Split = StringSplitAndTrim(line, "\n"); @@ -400,10 +402,14 @@ function ConvertWikiToDesc() -- Split[1] is always "", because the line starts with a "|" local notes = Split[3] or ""; notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" - table.insert(Constants, {Name = Split[2], Notes = notes}); + local name = (Split[2] or ""); + name = name:match("%a+"); + if ((name ~= "") and (name ~= nil)) then + table.insert(Constants, {Name = name, Notes = notes}); + end end + elseif (state == 3) then - -- Functions: line = string.gsub(line, "| ", "\n"); local Split = StringSplitAndTrim(line, "\n"); @@ -416,7 +422,38 @@ function ConvertWikiToDesc() name = "constructor" .. ConstructorNumber; -- Special name is used for the constructor in the wiki ConstructorNumber = ConstructorNumber + 1; end - table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); + name = name:match("%a+"); + if ((name ~= "") and (name ~= nil)) then + table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); + end + end + + elseif (state == 4) then + -- Constants and functions interspersed: + line = line:gsub("| ", "\n"); + local Split = StringSplitAndTrim(line, "\n"); + if (#Split >= 5) then + -- Split[1] is always "", because the line starts with a "|" + local notes = Split[5] or ""; + notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" + local name = (Split[2] or ""); + if ((name == "( )") or (name == "()")) then + name = "constructor" .. ConstructorNumber; -- Special name is used for the constructor in the wiki + ConstructorNumber = ConstructorNumber + 1; + end + name = name:match("%a+"); + if ((name ~= "") and (name ~= nil)) then + table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); + end + elseif (#Split >= 3) then + -- Split[1] is always "", because the line starts with a "|" + local notes = Split[3] or ""; + notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" + local name = (Split[2] or ""); + name = name:match("%a+"); + if ((name ~= "") and (name ~= nil)) then + table.insert(Constants, {Name = name, Notes = notes}); + end end end end -- for line @@ -425,6 +462,7 @@ function ConvertWikiToDesc() -- Write the info into the output file: fout:write("\t\t" .. ClassName .. " =\n\t\t{\n\t\t\tDesc = [[" .. Desc .. "]],\n\t\t\tFunctions =\n\t\t\t{\n"); for i, func in ipairs(Functions) do + LOG(ClassName .. "." .. func.Name); fout:write(string.format("\t\t\t\t{ %s = { Params = %q, Return = %q, Notes = %q } },\n", func.Name, func.Params, func.Return, func.Notes )); -- cgit v1.2.3 From 435a8197c1235ef66e2a1c32d587da6093123b9c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 20:17:26 +0200 Subject: APIDump: Processing wiki-style bullets (" * ") into

  • tag --- MCServer/Plugins/APIDump/main.lua | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 4a2582a34..0fb6893b5 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -390,6 +390,10 @@ function ConvertWikiToDesc() if (line == "") then AddNextTime = "

    \n\t\t

    "; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line else + -- Replace wiki-style bullets with

  • tag: + if (line:find("^ +%*")) then + line = line:gsub("^ +%* *", "
  • ") .. "
  • "; + end Desc = Desc .. AddNextTime .. line .. "\n"; AddNextTime = ""; end -- cgit v1.2.3 From 69060f265629345066f385277bdd60fb4972e958 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 20:29:31 +0200 Subject: APIDump: Fixed nesting --- MCServer/Plugins/APIDump/main.lua | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 0fb6893b5..5d0070be3 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -466,14 +466,13 @@ function ConvertWikiToDesc() -- Write the info into the output file: fout:write("\t\t" .. ClassName .. " =\n\t\t{\n\t\t\tDesc = [[" .. Desc .. "]],\n\t\t\tFunctions =\n\t\t\t{\n"); for i, func in ipairs(Functions) do - LOG(ClassName .. "." .. func.Name); - fout:write(string.format("\t\t\t\t{ %s = { Params = %q, Return = %q, Notes = %q } },\n", + fout:write(string.format("\t\t\t\t%s = { Params = %q, Return = %q, Notes = %q },\n", func.Name, func.Params, func.Return, func.Notes )); end fout:write("\t\t\t},\n\t\t\tConstants =\n\t\t\t{\n"); for i, cons in ipairs(Constants) do - fout:write(string.format("\t\t\t\t{ %s = { Notes = %q } },\n", + fout:write(string.format("\t\t\t\t%s = { Notes = %q },\n", cons.Name, cons.Notes )); end -- cgit v1.2.3 From 3109762e34878af910bc046584a2fca243949791 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 20:38:30 +0200 Subject: APIDump: Imported the descriptions from the wiki. --- MCServer/Plugins/APIDump/APIDesc.lua | 1274 +++++++++++++++++++++++++++++++++- MCServer/Plugins/APIDump/main.lua | 150 ---- 2 files changed, 1268 insertions(+), 156 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index dad123ed6..929cc600b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -43,30 +43,1292 @@ g_APIDesc = ]], Functions = { - Clear = { Notes = "Clears the object, resets it to zero size" }, - CopyFrom = { Params = "{{cBlockArea|BlockAreaSrc}}", Notes = "Copies contents from BlockAreaSrc into self"}, - CopyTo = { Params = "{{cBlockArea|BlockAreaDst}}", Notes = "Copies contents from self into BlockAreaDst"}, - GetBlockLight = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the blocklight at the specified absolute coords"}, + Clear = { Params = "", Return = "", Notes = "Clears the object, resets it to zero size" }, + CopyFrom = { Params = "BlockAreaSrc", Return = "", Notes = "Copies contents from BlockAreaSrc into self" }, + CopyTo = { Params = "BlockAreaDst", Return = "", Notes = "Copies contents from self into BlockAreaDst." }, + Create = { Params = "SizeX, SizeY, SizeZ, [DataTypes]", Return = "", Notes = "Initializes this BlockArea to an empty area of the specified size and origin of {0, 0, 0}. Any previous contents are lost." }, + Crop = { Params = "AddMinX, SubMaxX, AddMinY, SubMaxY, AddMinZ, SubMaxZ", Return = "", Notes = "Crops the specified number of blocks from each border. Modifies the size of this blockarea object." }, + DumpToRawFile = { Params = "FileName", Return = "", Notes = "Dumps the raw data into a file. For debugging purposes only." }, + Expand = { Params = "SubMinX, AddMaxX, SubMinY, AddMaxY, SubMinZ, AddMaxZ", Return = "", Notes = "Expands the specified number of blocks from each border. Modifies the size of this blockarea object. New blocks created with this operation are filled with zeroes." }, + Fill = { Params = "DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight]", Return = "", Notes = "Fills the entire block area with the same values, specified. Uses the DataTypes param to determine which content types are modified." }, + FillRelCuboid = { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight]", Return = "", Notes = "Fills the specified cuboid with the same values (like Fill() )." }, + GetBlockLight = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the blocklight at the specified absolute coords" }, + GetBlockMeta = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified absolute coords" }, + GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "NIBBLETYPE", Notes = "Returns the skylight at the specified absolute coords" }, + GetBlockType = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified absolute coords" }, + GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified absolute coords" }, + GetDataTypes = { Params = "", Return = "number", Notes = "Returns the mask of datatypes that the objectis currently holding" }, + GetOriginX = { Params = "", Return = "number", Notes = "Returns the origin x-coord" }, + GetOriginY = { Params = "", Return = "number", Notes = "Returns the origin y-coord" }, + GetOriginZ = { Params = "", Return = "number", Notes = "Returns the origin z-coord" }, + GetRelBlockLight = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "NIBBLETYPE", Notes = "Returns the blocklight at the specified relative coords" }, + GetRelBlockMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, + GetRelBlockSkyLight = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "NIBBLETYPE", Notes = "Returns the skylight at the specified relative coords" }, + GetRelBlockType = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, + GetRelBlockTypeMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ", Return = "NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, + GetSizeX = { Params = "", Return = "number", Notes = "Returns the size of the held data in the x-axis" }, + GetSizeY = { Params = "", Return = "number", Notes = "Returns the size of the held data in the y-axis" }, + GetSizeZ = { Params = "", Return = "number", Notes = "Returns the size of the held data in the z-axis" }, + HasBlockLights = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include blocklight" }, + HasBlockMetas = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include block metas" }, + HasBlockSkyLights = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include skylight" }, + HasBlockTypes = { Params = "", Return = "bool", Notes = "Returns true if current datatypes include block types" }, + LoadFromSchematicFile = { Params = "FileName", Return = "", Notes = "Clears current content and loads new content from the specified schematic file. Returns true if successful. Returns false and logs error if unsuccessful, old content is preserved in such a case." }, + Merge = { Params = "BlockAreaSrc, RelX, RelY, RelZ, Strategy", Return = "", Notes = "Merges BlockAreaSrc into this object at the specified relative coords, using the specified strategy" }, + MirrorXY = { Params = "", Return = "", Notes = "Mirrors this block area around the XY plane. Modifies blocks' metas (if present) to match (i. e. furnaces facing the opposite direction)." }, + MirrorXYNoMeta = { Params = "", Return = "", Notes = "Mirrors this block area around the XY plane. Doesn't modify blocks' metas." }, + MirrorXZ = { Params = "", Return = "", Notes = "Mirrors this block area around the XZ plane. Modifies blocks' metas (if present)" }, + MirrorXZNoMeta = { Params = "", Return = "", Notes = "Mirrors this block area around the XZ plane. Doesn't modify blocks' metas." }, + MirrorYZ = { Params = "", Return = "", Notes = "Mirrors this block area around the YZ plane. Modifies blocks' metas (if present)" }, + MirrorYZNoMeta = { Params = "", Return = "", Notes = "Mirrors this block area around the YZ plane. Doesn't modify blocks' metas." }, + Read = { Params = "World, MinX, MaxX, MinY, MaxY, MinZ, MaxZ, DataTypes", Return = "bool", Notes = "Reads the area from World, returns true if successful" }, + RelLine = { Params = "RelX1, RelY1, RelZ1, RelX2, RelY2, RelZ2, DataTypes, BlockType, [BlockMeta], [BlockLight], [BlockSkyLight]", Return = "", Notes = "Draws a line between the two specified points. Sets only datatypes specified by DataTypes." }, + RotateCCW = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, counter-clockwise (east -> north). Modifies blocks' metas (if present) to match." }, + RotateCCWNoMeta = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, counter-clockwise (east -> north). Doesn't modify blocks' metas." }, + RotateCW = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Modifies blocks' metas (if present) to match." }, + RotateCWNoMeta = { Params = "", Return = "", Notes = "Rotates the block area around the Y axis, clockwise (north -> east). Doesn't modify blocks' metas." }, + SaveToSchematicFile = { Params = "FileName", Return = "", Notes = "Saves the current contents to a schematic file. Returns true if successful." }, + SetBlockLight = { Params = "BlockX, BlockY, BlockZ, BlockLight", Return = "", Notes = "Sets the blocklight at the specified absolute coords" }, + SetBlockMeta = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified absolute coords" }, + SetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified absolute coords" }, + SetBlockType = { Params = "BlockX, BlockY, BlockZ, BlockType", Return = "", Notes = "Sets the block type at the specified absolute coords" }, + SetRelBlockLight = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockLight", Return = "", Notes = "Sets the blocklight at the specified relative coords" }, + SetRelBlockMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified relative coords" }, + SetRelBlockSkyLight = { Params = "RelBlockX, RelBlockY, RelBlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified relative coords" }, + SetRelBlockType = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockType", Return = "", Notes = "Sets the block type at the specified relative coords" }, + Write = { Params = "World, MinX, MinY, MinZ, DataTypes", Return = "bool", Notes = "Writes the area into World at the specified coords, returns true if successful" }, }, Constants = { baTypes = { Notes = "Operation should work on block types" }, + baMetas = { Notes = "Operations should work on block metas" }, + baLight = { Notes = "Operations should work on block (emissive) light" }, + baSkyLight = { Notes = "Operations should work on skylight" }, + msOverwrite = { Notes = "Src overwrites anything in Dst" }, + msFillAir = { Notes = "Dst is overwritten by Src only where Src has air blocks" }, + msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" }, + msLake = { Notes = "Special mode for merging lake images" }, }, }, - + cBlockEntity = { + Desc = [[Block entities are simply blocks in the world that have persistent data, such as the text for a sign or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. The cBlockEntity class acts as a common ancestor for all the individual block entities. +]], + Functions = + { + GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" }, + GetChunkX = { Params = "", Return = "number", Notes = "Returns the chunk X-coord of the block entity's chunk" }, + GetChunkZ = { Params = "", Return = "number", Notes = "Returns the chunk Z-coord of the block entity's chunk" }, + GetPosX = { Params = "", Return = "number", Notes = "Returns the block X-coord of the block entity's block" }, + GetPosY = { Params = "", Return = "number", Notes = "Returns the block Y-coord of the block entity's block" }, + GetPosZ = { Params = "", Return = "number", Notes = "Returns the block Z-coord of the block entity's block" }, + GetRelX = { Params = "", Return = "number", Notes = "Returns the relative X coord of the block entity's block within the chunk" }, + GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" }, + GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" }, + }, + Constants = + { + }, + }, + + cBlockEntityWithItems = + { + Desc = [[This class is a common ancestor for all {{cItemGrid|cItemGrid}} object for storing the items; this ItemGrid is accessible through the API. The storage is a grid of items, items in it can be addressed either by a slot number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage is monitored for changes and the changes are immediately sent to clients of the UI window. +]], + Functions = + { + GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, + GetSlot = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, + GetSlot = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, + SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, + SetSlot = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, + }, + Constants = + { + }, + }, + + cChatColor = + { + Desc = [[A cChatColor represents possible chat colors in form of constant strings. +]], + Functions = + { + }, + Constants = + { + Color = { Notes = "|" }, + Delimiter = { Notes = "|" }, + Black = { Notes = "0" }, + Navy = { Notes = "1" }, + Green = { Notes = "2" }, + Blue = { Notes = "3" }, + Red = { Notes = "4" }, + Purple = { Notes = "5" }, + Gold = { Notes = "6" }, + LightGray = { Notes = "7" }, + Gray = { Notes = "8" }, + DarkPurple = { Notes = "9" }, + LightGreen = { Notes = "a" }, + LightBlue = { Notes = "b" }, + Rose = { Notes = "c" }, + LightPurple = { Notes = "d" }, + Yellow = { Notes = "e" }, + White = { Notes = "f" }, + Random = { Notes = "k" }, + Bold = { Notes = "l" }, + Strikethrough = { Notes = "m" }, + Underlined = { Notes = "n" }, + Italic = { Notes = "o" }, + Plain = { Notes = "r" }, + MakeColor = { Notes = "String" }, + }, + }, + + Data = + { + Desc = [[
  • Inherits {{cBlockEntity|cBlockEntity}}
  • +A chest entity represents a chest in the world, currently only single chests exist in MCServer +Chest entities are saved and loaded from disk when the chunk they reside in is saved or loaded +

    +

    Here's some raw C++ code showing how chest entities are saved + +void cChestEntity::WriteToFile(FILE* a_File) +{ + fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File ); + fwrite( &m_PosX, sizeof( int ), 1, a_File ); + fwrite( &m_PosY, sizeof( int ), 1, a_File ); + fwrite( &m_PosZ, sizeof( int ), 1, a_File ); +

    +

    unsigned int NumSlots = c_ChestHeight*c_ChestWidth; + fwrite( &NumSlots, sizeof(unsigned int), 1, a_File ); + for(unsigned int i = 0; i < NumSlots; i++) + { + cItem* Item = GetSlot( i ); + if( Item ) + { + fwrite( &Item->m_ItemID, sizeof(Item->m_ItemID), 1, a_File ); + fwrite( &Item->m_ItemCount, sizeof(Item->m_ItemCount), 1, a_File ); + fwrite( &Item->m_ItemHealth, sizeof(Item->m_ItemHealth), 1, a_File ); } + } +} + +]], + Functions = + { + }, + Constants = + { + }, + }, + + cChunkDesc = + { + Desc = [[The cChunkDesc class is a container for chunk data while the chunk is being generated. As such, it is only used as a parameter for the {{onchunkgenerating|OnChunkGenerating}} and {{OnChunkGenerated|OnChunkGenerated}} hooks and cannot be constructed on its own. Plugins can use this class in both those hooks to manipulate generated chunks. +]], + Functions = + { + FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" }, + GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" }, + GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, + GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, + GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, + GetHeight = { Params = "RelX, RelZ", Return = "number", Notes = "Returns the height at the specified relative coords" }, + IsUsingDefaultBiomes = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default biome generator" }, + IsUsingDefaultComposition = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default composition generator" }, + IsUsingDefaultFinish = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default finishers" }, + IsUsingDefaultHeight = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default height generator" }, + IsUsingDefaultStructures = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default structures" }, + ReadBlockArea = { Params = "BlockArea, MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ", Return = "", Notes = "Reads data from the chunk into the block area object" }, + SetBiome = { Params = "RelX, RelZ, EMCSBiome", Return = "", Notes = "Sets the biome at the specified relative coords" }, + SetBlockMeta = { Params = "RelX, RelY, RelZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified relative coords" }, + SetBlockType = { Params = "RelX, RelY, RelZ, BlockType", Return = "", Notes = "Sets the block type at the specified relative coords" }, + SetBlockTypeMeta = { Params = "RelX, RelY, RelZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block type and meta at the specified relative coords" }, + SetHeight = { Params = "RelX, RelZ, Height", Return = "", Notes = "Sets the height at the specified relative coords" }, + SetUseDefaultBiomes = { Params = "bool", Return = "", Notes = "Sets the chunk to use default biome generator or not" }, + SetUseDefaultComposition = { Params = "bool", Return = "", Notes = "Sets the chunk to use default composition generator or not" }, + SetUseDefaultFinish = { Params = "bool", Return = "", Notes = "Sets the chunk to use default finishers or not" }, + SetUseDefaultHeight = { Params = "bool", Return = "", Notes = "Sets the chunk to use default height generator or not" }, + SetUseDefaultStructures = { Params = "bool", Return = "", Notes = "Sets the chunk to use default structures or not" }, + WriteBlockArea = { Params = "BlockArea, MinRelX, MinRelY, MinRelZ", Return = "", Notes = "Writes data from the block area into the chunk" }, + }, + Constants = + { + }, + }, + + cClientHandle = + { + Desc = [[A cClientHandle represents technical aspect of connected player - it's game client. +]], + Functions = + { + GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, + GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client" }, + GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" }, + GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" }, + GetViewDistance = { Params = "", Return = "number", Notes = "Returns the viewdistance (number of chunks loaded for the player in each direction)" }, + Kick = { Params = "Reason", Return = "", Notes = "Kicks the user with the specified reason" }, + SetUsername = { Params = "Name", Return = "", Notes = "Sets the username" }, + SetViewDistance = { Params = "ViewDistance", Return = "", Notes = "Sets the viewdistance (number of chunks loaded for the player in each direction)" }, + SendBlockChange = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sends a block to the client. This can be used to create fake blocks." }, + }, + Constants = + { + MAX = { Notes = "10" }, + MIN = { Notes = "4" }, + }, + }, + + cCraftingGrid = + { + Desc = [[cCraftingGrid represents the player's crafting grid. It is used only in {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect the items the player placed on their crafting grid. +]], + Functions = + { + Clear = { Params = "", Return = "", Notes = "Clears the entire grid" }, + ConsumeGrid = { Params = "{{cCraftingGrid|CraftingGrid}}", Return = "", Notes = "Consumes items specified in CraftingGrid from the current contents" }, + Dump = { Params = "", Return = "", Notes = "DEBUG build: Dumps the contents of the grid to the log. RELEASE build: no action" }, + GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the grid" }, + GetItem = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified coords" }, + GetWidth = { Params = "", Return = "number", Notes = "Returns the width of the grid" }, + SetItem = { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified coords" }, + SetItem = { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" }, + }, + Constants = + { + }, + }, + + cCraftingRecipe = + { + Desc = [[This class is used to represent a crafting recipe, either a built-in one, or one created dynamically in a plugin. It is used only as a parameter for {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect or modify a crafting recipe that a player views in their crafting window, either at a crafting table or the survival inventory screen. +

    +

    Internally, the class contains a {{cItem|cItem}} for the result. +]], + Functions = + { + Clear = { Params = "", Return = "", Notes = "Clears the entire recipe, both ingredients and results" }, + ConsumeIngredients = { Params = "CraftingGrid", Return = "", Notes = "Consumes ingredients specified in the given {{cCraftingGrid|cCraftingGrid}} class" }, + Dump = { Params = "", Return = "", Notes = "DEBUG build: dumps ingredients and result into server log. RELEASE build: no action" }, + GetIngredient = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the ingredient stored in the recipe at the specified coords" }, + GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" }, + GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" }, + GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" }, + SetIngredient = { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" }, + SetIngredient = { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" }, + SetResult = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" }, + SetResult = { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" }, + }, + Constants = + { + }, + }, + + cCuboid = + { + Desc = [[cCuboid offers some native support for cuboids. A cuboid simply consists of two {{vector3i|vector3i}}'s. It offers some extra functions for sorting and checking if a point is inside the cuboid. +]], + Functions = + { + }, + Constants = + { + p = { Notes = "{{Vector3i|Vector3i}}" }, + p = { Notes = "{{Vector3i|Vector3i}}" }, + Sort = { Notes = "void" }, + IsInside = { Notes = "bool" }, + IsInside = { Notes = "bool" }, + }, + }, + + cDispenserEntity = + { + Desc = [[This class represents a dispenser block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with a {{cDropperEntity|dropper}} entity. +

    +

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). +]], + Functions = + { + constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDispenserEntity", Notes = "Creates a new cDispenserEntity at the specified coords" }, + }, + Constants = + { + }, + }, + + cDropperEntity = + { + Desc = [[This class represents a dropper block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with the {{cDispenserEntity|dispenser}} entity. +

    +

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). +]], + Functions = + { + constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDropperEntity", Notes = "Creates a new cDropperEntity at the specified coords" }, + }, + Constants = + { + }, + }, + + cDropSpenser = + { + Desc = [[This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. +]], + Functions = + { + Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" }, + AddDropSpenserDir = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "BlockX, BlockY, BlockZ", Notes = "Adjusts the block coords to where the dropspenser items materialize" }, + SetRedstonePower = { Params = "IsPowered", Return = "", Notes = "Sets the redstone status of the dropspenser. If the redstone power goes from off to on, the dropspenser will be activated" }, + }, + Constants = + { + ContentsWidth = { Notes = "Width (X) of the cItemGrid representing the contents" }, + ContentsHeight = { Notes = "Height (Y) of the cItemGrid representing the contents" }, + }, + }, + + cEnchantments = + { + Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly. +

    +

    Enchantments can be initialized either programmatically by calling the individual functions (SetLevel()), or by using a string description of the enchantment combination. This string description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the enchantment, or its textual representation from the table below, and lvl is the desired enchantment level. The class can also create its string description from its current contents; however that string description will only have the numerical IDs. +]], + Functions = + { + constructor = { Params = "", Return = "cEnchantments", Notes = "Creates a new empty cEnchantments object" }, + constructor = { Params = "StringSpec", Return = "cEnchantments", Notes = "Creates a new cEnchantments object filled with enchantments based on the string description" }, + AddFromString = { Params = "StringSpec", Return = "", Notes = "Adds the enchantments in the string description into the object. If a specified enchantment already existed, it is overwritten." }, + Clear = { Params = "", Return = "", Notes = "Removes all enchantments" }, + GetLevel = { Params = "EnchantmentNumID", Return = "number", Notes = "Returns the level of the specified enchantment stored in this object; 0 if not stored" }, + IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if the object stores no enchantments" }, + SetLevel = { Params = "EnchantmentNumID, Level", Return = "", Notes = "Sets the level for the specified enchantment, adding it if not stored before or removing it if level < = 0" }, + StringToEnchantmentID = { Params = "EnchantmentTextID", Return = "number", Notes = "(static) Returns the enchantment numerical ID, -1 if not understood. Case insensitive" }, + ToString = { Params = "", Return = "string", Notes = "Returns the string description of all the enchantments stored in this object, in numerical-ID form" }, + }, + Constants = + { + }, + }, + + cEntity = + { + Desc = [[A cEntity object represents an object in the world, it has a position and orientation. cEntity is an abstract class, and can not be instantiated directly, instead, all entities are implemented as subclasses. The cEntity class works as the common interface for the operations that all (most) entities support. +

    +

    All cEntity objects have an Entity Type so it can be determined what kind of entity it is efficiently. Entities also have a class inheritance awareness, they know their class name, their parent class' name and can decide if there is a class within their inheritance chain. Since these functions operate on strings, they are slightly slower than checking the entity type directly, on the other hand, they are more specific (compare etMob vs "cSpider" class name). +

    +

    Note that you should not store a cEntity object between two hooks' calls, because MCServer may remove that entity in between the calls. If you need to refer to an entity later, use its UniqueID and {{cWorld|cWorld}}'s entity manipulation functions to access the entity. +]], + Functions = + { + Destroy = { Params = "", Return = "", Notes = "Schedules the entity to be destroyed" }, + GetChunkX = { Params = "", Return = "number", Notes = "Returns the X-coord of the chunk in which the entity is placed" }, + GetChunkY = { Params = "", Return = "number", Notes = "Returns the Y-coord of the chunk in which the entity is placed" }, + GetChunkZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the chunk in which the entity is placed" }, + GetClass = { Params = "", Return = "string", Notes = "Returns the classname of the entity, such as \"spider\" or \"pickup\"" }, + GetClassStatic = { Params = "", Return = "string", Notes = "Returns the entity classname that this class implements. Each descendant overrides this function. Is static" }, + GetEntityType = { Params = "", Return = "cEntity.eEntityType", Notes = "Returns the type of the entity, one of the etXXX constants" }, + GetLookVector = { Params = "", Return = "Vector3f", Notes = "Returns the vector that defines the direction in which the entity is looking" }, + GetParentClass = { Params = "", Return = "string", Notes = "Returns the name of the direct parent class for this entity" }, + GetPitch = { Params = "", Return = "number", Notes = "Returns the pitch (nose-down rotation) of the entity" }, + GetPosX = { Params = "", Return = "number", Notes = "Returns the X-coord of the entity's pivot" }, + GetPosY = { Params = "", Return = "number", Notes = "Returns the Y-coord of the entity's pivot" }, + GetPosZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the entity's pivot" }, + GetPosition = { Params = "", Return = "Vector3d", Notes = "Returns the entity's pivot position as a 3D vector" }, + GetRoll = { Params = "", Return = "number", Notes = "Returns the roll (sideways rotation) of the entity" }, + GetRot = { Params = "", Return = "Vector3f", Notes = "Returns the entire rotation vector (Rotation, Pitch, Roll)" }, + GetRotation = { Params = "", Return = "number", Notes = "Returns the rotation (direction) of the entity" }, + GetSpeed = { Params = "", Return = "Vector3d", Notes = "Returns the complete speed vector of the entity" }, + GetSpeedX = { Params = "", Return = "number", Notes = "Returns the X-part of the speed vector" }, + GetSpeedY = { Params = "", Return = "number", Notes = "Returns the Y-part of the speed vector" }, + GetSpeedZ = { Params = "", Return = "number", Notes = "Returns the Z-part of the speed vector" }, + GetUniqueID = { Params = "", Return = "number", Notes = "Returns the ID that uniquely identifies the entity" }, + GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world where the entity resides" }, + IsA = { Params = "ClassName", Return = "bool", Notes = "Returns true if the entity class is a descendant of the specified class name, or the specified class itself" }, + IsCrouched = { Params = "", Return = "bool", Notes = "Returns true if the entity is crouched. False for entities that don't support crouching" }, + IsDestroyed = { Params = "", Return = "bool", Notes = "Returns true if the entity has been destroyed and is awaiting removal from the internal structures" }, + IsMinecart = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a minecart" }, + IsMob = { Params = "", Return = "bool", Notes = "Returns true if the entity represents any mob" }, + IsOnFire = { Params = "", Return = "bool", Notes = "Returns true if the entity is on fire" }, + IsPickup = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a pickup" }, + IsPlayer = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a player" }, + IsTNT = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a TNT entity" }, + IsRclking = { Params = "", Return = "bool", Notes = "Currently unimplemented" }, + IsSprinting = { Params = "", Return = "bool", Notes = "Returns true if the entity is sprinting. ENtities that cannot sprint return always false" }, + SetPitch = { Params = "number", Return = "", Notes = "Sets the pitch (nose-down rotation) of the entity" }, + SetPosX = { Params = "number", Return = "", Notes = "Sets the X-coord of the entity's pivot" }, + SetPosY = { Params = "number", Return = "", Notes = "Sets the Y-coord of the entity's pivot" }, + SetPosZ = { Params = "number", Return = "", Notes = "Sets the Z-coord of the entity's pivot" }, + SetPosition = { Params = "X, Y, Z", Return = "", Notes = "Sets all three coords of the entity's pivot" }, + SetPosition = { Params = "{{Vector3d|Vector3d}}", Return = "", Notes = ":::" }, + SetRoll = { Params = "number", Return = "", Notes = "Sets the roll (sideways rotation) of the entity" }, + SetRot = { Params = "{{Vector3f|Vector3f}}", Return = "", Notes = "Sets the entire rotation vector (Rotation, Pitch, Roll)" }, + SetRotation = { Params = "number", Return = "", Notes = "Sets the rotation (direction) of the entity" }, + }, + Constants = + { + etEntity = { Notes = "N" }, + etPlayer = { Notes = "{{cPlayer|cPlayer" }, + etPickup = { Notes = "{{cPickup|cPickup" }, + etMob = { Notes = "{{cMonster|cMonster}} and descendan" }, + etFallingBlock = { Notes = "{{cFallingBlock|cFallingBlock" }, + etMinecart = { Notes = "{{cMinecart|cMinecart" }, + etTNT = { Notes = "{{cTNTEntity|cTNTEntity" }, + }, + }, + + cFurnaceEntity = + { + Desc = [[This class represents a furnace block entity in the world. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks) +]], + Functions = + { + constructor = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "cFurnaceEntity", Notes = "Creates a new cFurnaceEntity at the specified coords and the specified block type / meta" }, + GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" }, + GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" }, + GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" }, + GetInputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the input slot" }, + GetOutputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the output slot" }, + GetTimeCooked = { Params = "", Return = "number", Notes = "Returns the time that the current item has been cooking, in ticks" }, + HasFuelTimeLeft = { Params = "", Return = "bool", Notes = "Returns true if there's time before the current fuel is depleted" }, + SetFuelSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the fuel slot" }, + SetInputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the input slot" }, + SetOutputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the output slot" }, + }, + Constants = + { + fsInput = { Notes = "Index of the input slot, when using the GetSlot() / SetSlot() functions" }, + fsFuel = { Notes = "Index of the fuel slot, when using the GetSlot() / SetSlot() functions" }, + fsOutput = { Notes = "Index of the output slot, when using the GetSlot() / SetSlot() functions" }, + ContentsWidth = { Notes = "Width (X) of the {{cItemGrid|cItemGrid}} representing the contents" }, + ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid|cItemGrid}} representing the contents" }, + }, + }, + + cGroup = + { + Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat. +]], + Functions = + { + }, + Constants = + { + SetName = { Notes = "void" }, + GetName = { Notes = "String" }, + SetColor = { Notes = "void" }, + GetColor = { Notes = "String" }, + AddCommand = { Notes = "void" }, + HasCommand = { Notes = "bool" }, + AddPermission = { Notes = "void" }, + InheritFrom = { Notes = "void" }, + }, + }, + + cIniFile = + { + Desc = [[The cIniFile is a class that makes it simple to read from and write to INI files. MCServer uses mostly INI files for settings and options. +]], + Functions = + { + }, + Constants = + { + cIniFile = { Notes = "{{cIniFile|cIniFile}}" }, + CaseSensitive = { Notes = "void" }, + CaseInsensitive = { Notes = "void" }, + Path = { Notes = "void" }, + Path = { Notes = "String" }, + SetPath = { Notes = "void" }, + ReadFile = { Notes = "bool" }, + WriteFile = { Notes = "bool" }, + Erase = { Notes = "void" }, + Clear = { Notes = "void" }, + Reset = { Notes = "void" }, + FindKey = { Notes = "long i" }, + FindValue = { Notes = "long i" }, + NumKeys = { Notes = "unsigned i" }, + GetNumKeys = { Notes = "unsigned i" }, + AddKeyName = { Notes = "unsigned int" }, + KeyName = { Notes = "Stri" }, + GetKeyName = { Notes = "Stri" }, + NumValues = { Notes = "unsigned int" }, + GetNumValues = { Notes = "unsigned int" }, + NumValues = { Notes = "unsigned int" }, + GetNumValues = { Notes = "unsigned int" }, + ValueName = { Notes = "Stri" }, + GetValueName = { Notes = "Stri" }, + ValueName = { Notes = "Stri" }, + GetValueName = { Notes = "Stri" }, + GetValue = { Notes = "Stri" }, + GetValue = { Notes = "Stri" }, + GetValueI = { Notes = "i" }, + GetValueB = { Notes = "bo" }, + GetValueF = { Notes = "doub" }, + GetValueSet = { Notes = "Stri" }, + GetValueSetI = { Notes = "i" }, + GetValueSetB = { Notes = "bo" }, + GetValueSetF = { Notes = "doub" }, + SetValue = { Notes = "bool" }, + SetValue = { Notes = "bool" }, + SetValueI = { Notes = "bool" }, + SetValueB = { Notes = "bool" }, + SetValueF = { Notes = "bool" }, + DeleteValueByID = { Notes = "bool" }, + DeleteValue = { Notes = "bool" }, + DeleteKey = { Notes = "bool" }, + NumHeaderComments = { Notes = "unsigned int" }, + HeaderComment = { Notes = "void" }, + HeaderComment = { Notes = "Stri" }, + DeleteHeaderComment = { Notes = "bool" }, + DeleteHeaderComments = { Notes = "void" }, + NumKeyComments = { Notes = "unsigned i" }, + NumKeyComments = { Notes = "unsigned i" }, + KeyComment = { Notes = "bool" }, + KeyComment = { Notes = "bool" }, + KeyComment = { Notes = "Stri" }, + KeyComment = { Notes = "Stri" }, + DeleteKeyComment = { Notes = "bool" }, + DeleteKeyComment = { Notes = "bool" }, + DeleteKeyComments = { Notes = "bool" }, + DeleteKeyComments = { Notes = "bool" }, + }, + }, + + cInventory = + { + Desc = [[This object is used to store the items that a {{cPlayer|cPlayer}} has. It also keeps track of what item the player has currently selected in their hotbar. +Internally, the class uses three {{cItemGrid|cItemGrid}} objects to store the contents: +

  • Armor
  • +
  • Inventory
  • +
  • Hotbar
  • +These ItemGrids are available in the API and can be manipulated by the plugins, too. +]], + Functions = + { + AddItem = { Params = "{{cItem|cItem}}, [AllowNewStacks]", Return = "number", Notes = "Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Returns the number of items added" }, + AddItems = { Params = "{{cItems|cItems}}, [AllowNewStacks]", Return = "number", Notes = "Same as AddItem, but for several items at once" }, + ChangeSlotCount = { Params = "SlotNum, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum" }, + Clear = { Params = "", Return = "", Notes = "Empties all slots" }, + CopyToItems = { Params = "{{cItems|cItems}}", Return = "", Notes = "Copies all non-empty slots into the cItems object provided; original cItems contents are preserved" }, + DamageEquippedItem = { Params = "[DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the currently equipped it" }, + DamageItem = { Params = "SlotNum, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, + GetArmorGrid = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the ItemGrid representing the armor grid (1 x 4 slots)" }, + GetArmorSlot = { Params = "ArmorSlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the specified armor slot contents. Note that the returned item is read-only" }, + GetEquippedBoots = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the \"boots\" slot of the armor grid. Note that the returned item is read-only" }, + GetEquippedChestplate = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the \"chestplate\" slot of the armor grid. Note that the returned item is read-only" }, + GetEquippedHelmet = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the \"helmet\" slot of the armor grid. Note that the returned item is read-only" }, + GetEquippedItem = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the currently selected item from the hotbar. Note that the returned item is read-only" }, + GetEquippedLeggings = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the \"leggings\" slot of the armor grid. Note that the returned item is read-only" }, + GetEquippedSlotNum = { Params = "", Return = "number", Notes = "Returns the hotbar slot number for the currently selected item" }, + GetHotbarGrid = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the ItemGrid representing the hotbar grid (9 x 1 slots)" }, + GetHotbarSlot = { Params = "HotBarSlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the specified hotbar slot contents. Note that the returned item is read-only" }, + GetInventoryGrid = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the ItemGrid representing the main inventory (9 x 3 slots)" }, + GetInventorySlot = { Params = "InventorySlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the specified main inventory slot contents. Note that the returned item is read-only" }, + GetOwner = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player whose inventory this object represents" }, + GetSlot = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the contents of the specified slot. Note that the returned item is read-only" }, + HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" }, + HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" }, + HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" }, + RemoveOneEquippedItem = { Params = "", Return = "", Notes = "Removes one item from the hotbar's currently selected slot" }, + SetArmorSlot = { Params = "ArmorSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified armor slot contents" }, + SetEquippedSlotNum = { Params = "EquippedSlotNum", Return = "", Notes = "Sets the currently selected hotbar slot number" }, + SetHotbarSlot = { Params = "HotbarSlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified hotbar slot contents" }, + SetInventorySlot = { Params = "InventorySlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified main inventory slot contents" }, + SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot contents" }, + }, + Constants = + { + invArmorCount = { Notes = "4" }, + invArmorOffset = { Notes = "0" }, + invInventoryCount = { Notes = "" }, + invInventoryOffset = { Notes = "4" }, + invHotbarCount = { Notes = "9" }, + invHotbarOffset = { Notes = "" }, + invNumSlots = { Notes = "" }, + }, + }, + + cItem = + { + Desc = [[cItem is what defines an item or stack of items in the game, it contains the item ID, damage, quantity and enchantments. Each slot in a {{cEnchantments|cEnchantments}} class +]], + Functions = + { + constructor = { Params = "", Return = "cItem", Notes = "Creates a new empty cItem obje" }, + constructor = { Params = "ItemType, Count, Damage, EnchantmentString", Return = "cItem", Notes = "Creates a new cItem object of the specified type, count (1 by default), damage (0 by default) and enchantments (non-enchanted by default)" }, + constructor = { Params = "cItem", Return = "cItem", Notes = "Creates an exact copy of the cItem object in the parameter" }, + Clear = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, + CopyOne = { Params = "", Return = "cItem", Notes = "Creates a copy of this object, with its count set to 1" }, + DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" }, + Empty = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, + GetMaxDamage = { Params = "", Return = "number", Notes = "Returns the maximum value for damage that this item can get before breaking; zero if damage is not accounted for for this item type" }, + IsDamageable = { Params = "", Return = "bool", Notes = "Returns true if this item does account for its damage" }, + IsEnchantable = { Params = "ItemType", Return = "bool", Notes = "(static) Returns true if the specified ItemType is an enchantable item, as defined by the 1.2.5 network protocol (deprecated)" }, + IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" }, + IsSameType = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is of the same ItemType as the one stored in the object" }, + IsStackableWith = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is stackable with the one stored in the object" }, + }, + Constants = + { + }, + }, + + cItemGrid = + { + Desc = [[This class represents a 2D array of items. It is used as the underlying storage and API for all cases that use a grid of items: +
  • Chest contents
  • +
  • (TODO) Chest minecart contents
  • +
  • Dispenser contents
  • +
  • Dropper contents
  • +
  • (TODO) Furnace contents (?)
  • +
  • (TODO) Hopper contents
  • +
  • (TODO) Hopper minecart contents
  • +
  • Player Inventory areas
  • +
  • (TODO) Trapped chest contents
  • +

    +

    The items contained in this object are accessed either by a pair of XY coords, or a slot number (x + Width * y). There are functions available for converting between the two formats. +]], + Functions = + { + AddItem = { Params = "{{cItem|cItem}}, [AllowNewStacks]", Return = "number", Notes = "Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Returns the number of items added" }, + AddItems = { Params = "{{cItems|cItems}}, [AllowNewStacks]", Return = "number", Notes = "Same as AddItem, but for several items at once" }, + ChangeSlotCount = { Params = "SlotNum, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum" }, + ChangeSlotCount = { Params = "X, Y, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid slot coords" }, + Clear = { Params = "", Return = "", Notes = "Empties all slots" }, + CopyToItems = { Params = "{{cItems|cItems}}", Return = "", Notes = "Copies all non-empty slots into the cItems object provided; original cItems contents are preserved" }, + DamageItem = { Params = "SlotNum, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, + DamageItem = { Params = "X, Y, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, + EmptySlot = { Params = "SlotNum", Return = "", Notes = "Destroys the item in the specified slot" }, + EmptySlot = { Params = "X, Y", Return = "", Notes = "Destroys the item in the specified slot" }, + GetFirstEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the first empty slot, -1 if all slots are full" }, + GetHeight = { Params = "", Return = "number", Notes = "Returns the Y dimension of the grid" }, + GetLastEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the last empty slot, -1 if all slots are full" }, + GetNextEmptySlot = { Params = "StartFrom", Return = "number", Notes = "Returns the SlotNumber of the first empty slot following StartFrom, -1 if all the following slots are full" }, + GetNumSlots = { Params = "", Return = "number", Notes = "Returns the total number of slots in the grid (Width * Height)" }, + GetSlot = { Params = "SlotNumber", Return = "{{cItem|cItem}}", Notes = "Returns the item in the specified slot. Note that the item is read-only" }, + GetSlot = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the item in the specified slot. Note that the item is read-only" }, + GetSlotCoords = { Params = "SlotNum", Return = "number, number", Notes = "Returns the X and Y coords for the specified SlotNumber. Returns \"-1, -1\" on invalid SlotNumber" }, + GetSlotNum = { Params = "X, Y", Return = "number", Notes = "Returns the SlotNumber for the specified slot coords. Returns -1 on invalid coords" }, + GetWidth = { Params = "", Return = "number", Notes = "Returns the X dimension of the grid" }, + HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" }, + HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" }, + HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" }, + IsSlotEmpty = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, + IsSlotEmpty = { Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, + RemoveOneItem = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, + RemoveOneItem = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, + SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, + SetSlot = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, + }, + Constants = + { + }, + }, + + citems = + { + Desc = [[]], + Functions = + { + constructor = { Params = "", Return = "cItems", Notes = "Creates a new cItems object" }, + Add = { Params = "Index, {{cItem|cItem}}", Return = "", Notes = "Adds a new item to the end of the collection" }, + Add = { Params = "Index, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Adds a new item to the end of the collection" }, + Clear = { Params = "", Return = "", Notes = "Removes all items from the collection" }, + Delete = { Params = "Index", Return = "", Notes = "Deletes item at the specified index" }, + Get = { Params = "Index", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified index" }, + Set = { Params = "Index, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified index to the specified item" }, + Set = { Params = "Index, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified index to the specified item" }, + Size = { Params = "", Return = "number", Notes = "Returns the number of items in the collection" }, + }, + Constants = + { + }, + }, + + cLadder = + { + Desc = [[cLadder just represents ladders and their specific - rotation. +]], + Functions = + { + }, + Constants = + { + DirectionToMetaData = { Notes = "char" }, + MetaDataToDirection = { Notes = "char" }, + }, + }, + + cluachunk = + { + Desc = [[]], + Functions = + { + }, + Constants = + { + }, + }, + + Callbacks = + { + Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set. +

    +

    This class inherits from the {{cWindow|cWindow}} class, so all cWindow's functions and constants can be used, in addition to the cLuaWindow-specific functions listed below. +

    +

    The contents of this window are represented by a {{cWindow|cWindow}}:GetSlot() etc. or {{cPlayer|cPlayer}}:GetInventory() to access the player inventory. +

    +

    When creating a new cLuaWindow object, you need to specify both the window type and the contents' width and height. Note that MCServer accepts any combination of these, but opening a window for a player may crash their client if the contents' dimensions don't match the client's expectations. +

    +

    To open the window for a player, call {{cPlayer|cPlayer}}:OpenWindow(). Multiple players can open window of the same cLuaWindow object. All players see the same items in the window's contents (like chest, unlike crafting table). +The object calls the following functions at the appropriate time: +==== OnClosing Callback ==== +This callback, settabel via the SetOnClosing() function, will be called when the player tries to close the window, or the window is closed for any other reason (such as a player disconnecting). + +function OnWindowClosing(a_Window, a_Player, a_CanRefuse) + +The a_Window parameter is the cLuaWindow object representing the window, a_Player is the player for whom the window is about to close. a_CanRefuse specifies whether the callback can refuse the closing. If the callback returns true and a_CanRefuse is true, the window is not closed (internally, the server sends a new OpenWindow packet to the client). +==== OnSlotChanged Callback ==== +This callback, settable via the SetOnSlotChanged() function, will be called whenever the contents of any slot in the window's contents (i. e. NOT in the player inventory!) changes. + +function OnWindowSlotChanged(a_Window, a_SlotNum) + +The a_Window parameter is the cLuaWindow object representing the window, a_SlotNum is the slot number. There is no reference to a {{cWorld|cWorld}}:DoWithPlayer(). +

    +

    Any returned values are ignored. +]], + Functions = + { + constructor = { Params = "WindowType, ContentsWidth, ContentsHeight, Title", Return = "", Notes = "Creates a new object of this class" }, + GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the internal storage in this window" }, + SetOnClosing = { Params = "OnClosingCallback", Return = "", Notes = "Sets the function that the window will call when it is about to be closed by a player" }, + SetOnSlotChanged = { Params = "OnSlotChangedCallback", Return = "", Notes = "Sets the function that the window will call when a slot is changed by a player" }, + }, + Constants = + { + }, + }, + + cMCLogger = + { + Desc = [[cMCLogger gives you a bit more complex way to log things. +]], + Functions = + { + }, + Constants = + { + LogSimple = { Notes = "void" }, + }, + }, + + cPacket = + { + Desc = [[This packet is received by clients when they are digging blocks +]], + Functions = + { + }, + Constants = + { + m = { Notes = "char" }, + m = { Notes = "int" }, + m = { Notes = "char" }, + m = { Notes = "int" }, + m = { Notes = "char" }, + }, + }, + + cPacket = + { + Desc = [[This packet is received by clients when they are placing blocks +]], + Functions = + { + }, + Constants = + { + m = { Notes = "int" }, + m = { Notes = "char" }, + m = { Notes = "int" }, + m = { Notes = "char" }, + m = { Notes = "short int" }, + m = { Notes = "char" }, + m = { Notes = "short int" }, + }, + }, + + cPacket = + { + Desc = [[This packet is received when a client logs in +]], + Functions = + { + }, + Constants = + { + m = { Notes = "int" }, + m = { Notes = "String" }, + m = { Notes = "String" }, + m = { Notes = "int" }, + m = { Notes = "int" }, + m = { Notes = "char" }, + m = { Notes = "char" }, + m = { Notes = "char" }, + }, + }, + + cPawn = + { + Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}} +]], + Functions = + { + }, + Constants = + { + TeleportToEntity = { Notes = "void" }, + TeleportTo = { Notes = "void" }, + Heal = { Notes = "void" }, + TakeDamage = { Notes = "void" }, + KilledBy = { Notes = "void" }, + GetHealth = { Notes = "int" }, + }, + }, + + cPickup = + { + Desc = [[cPickup is a pickup object representation. It is also commonly known as "drops". With this class you could create your own "drop" or modify automatically created. +]], + Functions = + { + }, + Constants = + { + cPickup = { Notes = "[[cPickup}}" }, + GetItem = { Notes = "{{cItem|cItem}}" }, + CollectedBy = { Notes = "bool" }, + }, + }, + + cPlayer = + { + Desc = [[cPlayer describes a human player in the server. cPlayer inherits all functions and members of {{cPawn|cPawn}} +]], + Functions = + { + }, + Constants = + { + GetEyeHeight = { Notes = "double" }, + GetEyePosition = { Notes = "{{Vector3d|Vector3d}}" }, + GetFlying = { Notes = "bool" }, + GetStance = { Notes = "double" }, + GetInventory = { Notes = "{{cInventory|cInventory}}" }, + TeleportTo = { Notes = "void" }, + GetGameMode = { Notes = "{{eGameMode|eGameMode}}" }, + GetIP = { Notes = "String" }, + GetLastBlockActionTime = { Notes = "float" }, + GetLastBlockActionCnt = { Notes = "int" }, + SetLastBlockActionCnt = { Notes = "void" }, + SetLastBlockActionTime = { Notes = "void" }, + SetGameMode = { Notes = "void" }, + MoveTo = { Notes = "void" }, + GetClientHandle = { Notes = "{{cClientHandle|cClientHandle}}" }, + SendMessage = { Notes = "void" }, + GetName = { Notes = "String" }, + SetName = { Notes = "void" }, + AddToGroup = { Notes = "void" }, + CanUseCommand = { Notes = "bool" }, + HasPermission = { Notes = "bool" }, + IsInGroup = { Notes = "bool" }, + GetColor = { Notes = "String" }, + TossItem = { Notes = "void" }, + Heal = { Notes = "void" }, + TakeDamage = { Notes = "void" }, + KilledBy = { Notes = "void" }, + Respawn = { Notes = "void" }, + SetVisible = { Notes = "void" }, + IsVisible = { Notes = "bool" }, + MoveToWorld = { Notes = "bool" }, + LoadPermissionsFromDisk = { Notes = "void" }, + GetGroups = { Notes = "list<{{cGroup|cGroup}}>" }, + GetResolvedPermissions = { Notes = "String" }, + }, + }, + + cPlugin = + { + Desc = [[cPlugin describes a Lua plugin. This page is dedicated to new-style plugins and contain their functions. +]], + Functions = + { + }, + Constants = + { + GetName = { Notes = "String" }, + SetName = { Notes = "void" }, + GetVersion = { Notes = "int" }, + SetVersion = { Notes = "void" }, + GetFileName = { Notes = "String" }, + CreateWebPlugin = { Notes = "{{cWebPlugin|cWebPlugin}}" }, + }, + }, + + cPluginManager = + { + Desc = [[This class is used for generic plugin-related functionality. The plugin manager has a list of all plugins, can enable or disable plugins, manages hook and in-game console commands. +

    +

    There is one instance of cPluginManager in MCServer, to get it, call either {{GetPluginManager|GetPluginManager}}() or cPluginManager:Get() function. +]], + Functions = + { + AddHook = { Params = "{{cPlugin|Plugin}}, HookType", Return = "", Notes = "Adds processing of the specified hook" }, + BindCommand = { Params = "Command, Permission, Callback, HelpString", Return = "", Notes = "Binds an in-game command with the specified callback function, permission and help string" }, + BindConsoleCommand = { Params = "Command, Callback, HelpString", Return = "", Notes = "Binds a console command with the specified callback function and help string" }, + DisablePlugin = { Params = "PluginName", Return = "", Notes = "Disables a plugin specified by its name" }, + ExecuteCommand = { Params = "Player, Command", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed" }, + ExecuteConsoleCommand = { Params = "Command", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." }, + FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, + ForceExecuteCommand = { Params = "Player, Command", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, + ForEachCommand = { Params = "Callback", Return = "", Notes = "Calls the Callback function for each command that has been bound using BindCommand()" }, + ForEachConsoleCommand = { Params = "Callback", Return = "", Notes = "Calls the Callback function for each command that has been bound using BindConsoleCommand()" }, + Get = { Params = "", Return = "cPluginManager", Notes = "Returns the single instance of the plugin manager" }, + GetAllPlugins = { Params = "", Return = "PluginTable", Notes = "Returns a table of all plugins, [name => cPlugin] pairs" }, + GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" }, + GetNumPlugins = { Params = "", Return = "number", Notes = "Returns the number of plugins, including the disabled ones" }, + GetPlugin = { Params = "PluginName", Return = "{{cPlugin|cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" }, + IsCommandBound = { Params = "Command", Return = "boolean", Notes = "Returns true if in-game Command is already bound (by any plugin)" }, + IsConsoleCommandBound = { Params = "Command", Return = "boolean", Notes = "Returns true if console Command is already bound (by any plugin)" }, + LoadPlugin = { Params = "PluginFolder", Return = "", Notes = "Loads a plugin from the specified folder" }, + ReloadPlugins = { Params = "", Return = "", Notes = "Reloads all active plugins" }, + }, + Constants = + { + }, + }, + + cplugin_newlua = + { + Desc = [[]], + Functions = + { + }, + Constants = + { + }, + }, + + cRoot = + { + Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} +]], + Functions = + { + }, + Constants = + { + }, + }, + + cServer = + { + Desc = [[cServer is typically only used by plugins to broadcast a chat message to all players in the server. Natively however, cServer accepts connections from clients and adds those clients to the game. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Data = + { + Desc = [[

  • Inherits {{cBlockEntity|cBlockEntity}}
  • +A sign entity represents a sign in the world. +Sign entities are saved and loaded from disk when the chunk they reside in is saved or loaded +

    +

    Here's some raw C++ code showing how sign entities are saved + +void cSignEntity::WriteToFile(FILE* a_File) +{ + fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File ); + fwrite( &m_PosX, sizeof( int ), 1, a_File ); + fwrite( &m_PosY, sizeof( int ), 1, a_File ); + fwrite( &m_PosZ, sizeof( int ), 1, a_File ); +

    +

    for( int i = 0; i < 4; i++ ) + { + short Size = m_Line[i].size(); + fwrite( &Size, sizeof(short), 1, a_File ); + fwrite( m_Line[i].c_str(), Size * sizeof(char), 1, a_File ); + } +} + +]], + Functions = + { + }, + Constants = + { + }, + }, + + cStringMap = + { + Desc = [[cStringMap is an object that maps strings with strings, it's also known as a dictionary +]], + Functions = + { + }, + Constants = + { + }, + }, + + cTCPLink = + { + Desc = [[OBSOLETE, Do not use! +]], + Functions = + { + }, + Constants = + { + }, + }, + + cTracer = + { + Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want. +

    +

    The cTracer is still a work in progress +]], + Functions = + { + }, + Constants = + { + }, + }, + + cWindow = + { + Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window. +

    +

    Note that one cWindow object can be used for multiple players at the same time, and therefore the slot contents are player-specific (e. g. crafting grid, or player inventory). Thus the GetSlot() and SetSlot() functions need to have the {{cPlayer|cPlayer}} parameter that specifies the player for which the contents are to be queried. +]], + Functions = + { + GetWindowID = { Params = "", Return = "number", Notes = "Returns the ID of the window, as used by the network protocol" }, + GetWindowTitle = { Params = "", Return = "string", Notes = "Returns the window title that will be displayed to the player" }, + GetWindowType = { Params = "", Return = "number", Notes = "Returns the type of the window, one of the constants in the table above" }, + IsSlotInPlayerHotbar = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player hotbar" }, + IsSlotInPlayerInventory = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory or in the hotbar. Note that this returns false for armor slots!" }, + IsSlotInPlayerMainInventory = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory" }, + SetSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the contents of the specified slot for the specified player. Ignored if the slot number is invalid" }, + SetWindowTitle = { Params = "string", Return = "", Notes = "Sets the window title that will be displayed to the player" }, + }, + Constants = + { + Inventory = { Notes = "" }, + Chest = { Notes = "0" }, + Workbench = { Notes = "1" }, + Furnace = { Notes = "2" }, + DropSpenser = { Notes = "3" }, + Enchantment = { Notes = "4" }, + Brewery = { Notes = "5" }, + NPCTrade = { Notes = "6" }, + Beacon = { Notes = "7" }, + Anvil = { Notes = "8" }, + Hopper = { Notes = "9" }, + }, + }, + + cWorld = + { + Desc = [[cWorld is the game world, at the moment there can only be one world. The world manages all {{cChunk | Chunks}}, {{cPlayer | Players}} and the time. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Coordinates = + { + Desc = [[The PAK format is highly compact format that has a slightly better compression ratio and saving / loading times than the {{dataformatanvil | Anvil}} format. +I use this function to convert block coordinates to indices which I use to access the arrays of blocks + +unsigned int cChunk::MakeIndex(int x, int y, int z ) +{ + if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 ) + return y + (z * 128) + (x * 128 * 16); + return 0; +} + +]], + Functions = + { + }, + Constants = + { + }, + }, + + eGameMode = + { + Desc = [[

    +

    {{eGameMode|eGameMode}} is an enum that defines what game mode a player is in. It can be one of these two values. +

    +

    ^ eGameMode ^ +| eGameMode_Survival | +| eGameMode_Creative | +]], + Functions = + { + }, + Constants = + { + }, + }, + + Initialize = + { + Desc = [[The Initialize() function is the main entrypoint to a plugin. Within this function the plugin is expected to register any hook callbacks, commands, read settings, add webadmin tabs etc. MCServer calls this function after all the files in the plugin directory have been read and the global values and commands have been executed by the Lua engine, so all the global variables and functions are accessible. +

    +

    Typically, plugins will also store the Plugin parameter into a global variable so that it is accessible later. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Documented = + { + Desc = [[

    +

    A plugin is a script written in Lua that can modify the game in multiple ways. +A list of items regarding plugins that have been documented +

    +

    {{indexmenu>:api:plugin#1}} +]], + Functions = + { + }, + Constants = + { + }, + }, + + TakeDamageInfo = + { + Desc = [[The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the {{OnTakeDamage|OnTakeDamage}}() hook and in the {{cEntity|cEntity}}'s TakeDamage() function. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Vector3 = + { + Desc = [[Vector3 is a family of classes that all represent a point in space +

  • {{vector3f|vector3f}}
  • +
  • Uses floating point values
  • +
  • {{vector3d|vector3d}}
  • +
  • Uses double precision floating point values
  • +
  • {{vector3i|vector3i}}
  • +
  • Uses fixed point (integer) values
  • +]], + Functions = + { + }, + Constants = + { + }, + }, + + Vector3d = + { + Desc = [[A Vector3d object uses double precision floating point values to describe a point in space. Vector3d is part of the {{vector3|vector3}} family. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Vector3f = + { + Desc = [[A Vector3f object uses floating point values to describe a point in space. Vector3f is part of the {{vector3|vector3}} family. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Vector3i = + { + Desc = [[A Vector3i object uses integer values to describe a point in space. Vector3i is part of the {{vector3|vector3}} family. +]], + Functions = + { + }, + Constants = + { + }, + }, + + Documented = + { + Desc = [[

    +

    WebPlugins provide an interface for the server through a webpage, to be able to use WebPlugins you need to enable WebAdmin in webadmin.ini{{ :api:webadmin.png?200| A WebPlugin in action}} + +[WebAdmin] +Enabled=1 +Port=8080 + +A list of items regarding WebPlugins that have been documented +

    +

    {{indexmenu>:api:webplugin#1}} +]], + Functions = + { + }, + Constants = + { + }, + }, + }, + IgnoreFunctions = { "globals.assert", "globals.collectgarbage", "globals.xpcall", - } + }, } ; + diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 5d0070be3..3988857c9 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -26,9 +26,6 @@ function Initialize(Plugin) -- dump all available API functions and objects: -- DumpAPITxt(); - -- DEBUG: Convert the wiki dump into APIDesc - ConvertWikiToDesc(); - -- Dump all available API object in HTML format into a subfolder: DumpAPIHtml(); @@ -339,150 +336,3 @@ end --- This function converts the wiki dump, as provided by FakeTruth, into the APIDesc format. --- Dump available in forum: http://forum.mc-server.org/showthread.php?tid=1214&pid=9892#pid9892 --- The dump is expected unpacked as "wikipages/api/*.txt", in the executable folder --- Only Windows-style paths are supported for now, since this is a one-time action -function ConvertWikiToDesc() - local fout = io.open("APIDesc.wiki.lua", "w"); - fout:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); - for filename in io.popen([[dir wikipages\\api\\*.txt /b]]):lines() do - -- Read file - local fin = io.open("wikipages\\api\\" .. filename, "r"); - local ClassName = filename:match("[^\.]*"); - local AddNextTime = ""; - if (fin ~= nil) then - -- Read and parse the info from the file - local state = 0; - local Desc = ""; - local Constants = {}; - local Functions = {}; - local ConstructorNumber = 1; - for line in fin:lines() do - -- Replace wiki-style markup: - line = line:gsub("%[%[.-:.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Plugin:Hook|LinkText]] - line = line:gsub("%[%[.-:.-:(.-)%]%]", "{{%1|%1}}"); -- Replaces [[API:Plugin:Hook]] - line = line:gsub("%[%[.-:(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[API:Class|LinkText]] - line = line:gsub("%[%[.-:(.-)%]%]", "{{%1|%1}}"); -- Replaces [[API:Class]] - line = line:gsub("%[%[(.-)|(.-)%]%]", "{{%1|%2}}"); -- Replaces [[Class|LinkText]] - line = line:gsub("%[%[(.-)%]%]", "{{%1|%1}}"); -- Replaces [[Class]] - - if (line:find("======") ~= nil) then - state = 1; -- The following is the class description - ClassName = line:gsub("======", ""); - ClassName = ClassName:match("%w+"); - if (ClassName == nil) then - -- Reset to default - ClassName = filename:match("[^\.]*"); - end - AddNextTime = ""; - elseif (line:find("===== Constants") ~= nil) then - state = 2; -- The following is the constants description - elseif (line:find("===== Functions") ~= nil) then - state = 3; -- The following is the functions description - elseif (line:find("===== Class [Dd]efinition ==") ~= nil) then - state = 4; -- The following contains both functions' and constants' descriptions - elseif (line:find("=====") ~= nil) then - state = 5; -- The following is an unknown text, skip it entirely - - elseif (state == 1) then - -- Class description: - if (line == "") then - AddNextTime = "

    \n\t\t

    "; -- Replace empty lines with paragraph delimiters; add only when there's a followup text on next line - else - -- Replace wiki-style bullets with

  • tag: - if (line:find("^ +%*")) then - line = line:gsub("^ +%* *", "
  • ") .. "
  • "; - end - Desc = Desc .. AddNextTime .. line .. "\n"; - AddNextTime = ""; - end - - elseif (state == 2) then - -- Constants: - line = line:gsub("| ", "\n"); - local Split = StringSplitAndTrim(line, "\n"); - if (#Split >= 3) then - -- Split[1] is always "", because the line starts with a "|" - local notes = Split[3] or ""; - notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" - local name = (Split[2] or ""); - name = name:match("%a+"); - if ((name ~= "") and (name ~= nil)) then - table.insert(Constants, {Name = name, Notes = notes}); - end - end - - elseif (state == 3) then - -- Functions: - line = string.gsub(line, "| ", "\n"); - local Split = StringSplitAndTrim(line, "\n"); - if (#Split >= 5) then - -- Split[1] is always "", because the line starts with a "|" - local notes = Split[5] or ""; - notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" - local name = (Split[2] or ""); - if ((name == "( )") or (name == "()")) then - name = "constructor" .. ConstructorNumber; -- Special name is used for the constructor in the wiki - ConstructorNumber = ConstructorNumber + 1; - end - name = name:match("%a+"); - if ((name ~= "") and (name ~= nil)) then - table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); - end - end - - elseif (state == 4) then - -- Constants and functions interspersed: - line = line:gsub("| ", "\n"); - local Split = StringSplitAndTrim(line, "\n"); - if (#Split >= 5) then - -- Split[1] is always "", because the line starts with a "|" - local notes = Split[5] or ""; - notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" - local name = (Split[2] or ""); - if ((name == "( )") or (name == "()")) then - name = "constructor" .. ConstructorNumber; -- Special name is used for the constructor in the wiki - ConstructorNumber = ConstructorNumber + 1; - end - name = name:match("%a+"); - if ((name ~= "") and (name ~= nil)) then - table.insert(Functions, {Name = name, Params = Split[3], Return = Split[4], Notes = notes}); - end - elseif (#Split >= 3) then - -- Split[1] is always "", because the line starts with a "|" - local notes = Split[3] or ""; - notes = notes:sub(1, notes:len() - 2); -- Remove the trailing " |" - local name = (Split[2] or ""); - name = name:match("%a+"); - if ((name ~= "") and (name ~= nil)) then - table.insert(Constants, {Name = name, Notes = notes}); - end - end - end - end -- for line - fin:close(); - - -- Write the info into the output file: - fout:write("\t\t" .. ClassName .. " =\n\t\t{\n\t\t\tDesc = [[" .. Desc .. "]],\n\t\t\tFunctions =\n\t\t\t{\n"); - for i, func in ipairs(Functions) do - fout:write(string.format("\t\t\t\t%s = { Params = %q, Return = %q, Notes = %q },\n", - func.Name, func.Params, func.Return, func.Notes - )); - end - fout:write("\t\t\t},\n\t\t\tConstants =\n\t\t\t{\n"); - for i, cons in ipairs(Constants) do - fout:write(string.format("\t\t\t\t%s = { Notes = %q },\n", - cons.Name, cons.Notes - )); - end - fout:write("\t\t\t},\n\t\t},\n\n"); - end -- if fin ~= nil - end -- for file - fout:write("\t}\n}\n\n\n\n\n\n"); - fout:close(); -end - - - - -- cgit v1.2.3 From 80bdd2284bee2e396e9c33a6d0b756f3de700ab6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 12 Sep 2013 20:59:17 +0200 Subject: APIDump: Read through and fixed the first few classes desc. --- MCServer/Plugins/APIDump/APIDesc.lua | 163 +++++++++++++++-------------------- 1 file changed, 71 insertions(+), 92 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 929cc600b..4e887a47b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -113,19 +113,23 @@ g_APIDesc = cBlockEntity = { - Desc = [[Block entities are simply blocks in the world that have persistent data, such as the text for a sign or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. The cBlockEntity class acts as a common ancestor for all the individual block entities. -]], + Desc = [[ + Block entities are simply blocks in the world that have persistent data, such as the text for a sign + or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. + The cBlockEntity class acts as a common ancestor for all the individual block entities. + ]], + Functions = { GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" }, - GetChunkX = { Params = "", Return = "number", Notes = "Returns the chunk X-coord of the block entity's chunk" }, - GetChunkZ = { Params = "", Return = "number", Notes = "Returns the chunk Z-coord of the block entity's chunk" }, - GetPosX = { Params = "", Return = "number", Notes = "Returns the block X-coord of the block entity's block" }, - GetPosY = { Params = "", Return = "number", Notes = "Returns the block Y-coord of the block entity's block" }, - GetPosZ = { Params = "", Return = "number", Notes = "Returns the block Z-coord of the block entity's block" }, - GetRelX = { Params = "", Return = "number", Notes = "Returns the relative X coord of the block entity's block within the chunk" }, - GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" }, - GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" }, + GetChunkX = { Params = "", Return = "number", Notes = "Returns the chunk X-coord of the block entity's chunk" }, + GetChunkZ = { Params = "", Return = "number", Notes = "Returns the chunk Z-coord of the block entity's chunk" }, + GetPosX = { Params = "", Return = "number", Notes = "Returns the block X-coord of the block entity's block" }, + GetPosY = { Params = "", Return = "number", Notes = "Returns the block Y-coord of the block entity's block" }, + GetPosZ = { Params = "", Return = "number", Notes = "Returns the block Z-coord of the block entity's block" }, + GetRelX = { Params = "", Return = "number", Notes = "Returns the relative X coord of the block entity's block within the chunk" }, + GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" }, + GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" }, }, Constants = { @@ -134,8 +138,16 @@ g_APIDesc = cBlockEntityWithItems = { - Desc = [[This class is a common ancestor for all {{cItemGrid|cItemGrid}} object for storing the items; this ItemGrid is accessible through the API. The storage is a grid of items, items in it can be addressed either by a slot number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage is monitored for changes and the changes are immediately sent to clients of the UI window. -]], + Desc = [[ + This class is a common ancestor for all {{cBlockEntity|block entities}} that provide item storage. + Internally, the object has a {{cItemGrid|cItemGrid}} object for storing the items; this ItemGrid is + accessible through the API. The storage is a grid of items, items in it can be addressed either by a slot + number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage + is monitored for changes and the changes are immediately sent to clients of the UI window. + ]], + + Inherits = "cBlockEntity", + Functions = { GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, @@ -151,71 +163,33 @@ g_APIDesc = cChatColor = { - Desc = [[A cChatColor represents possible chat colors in form of constant strings. -]], + Desc = [[ + A wrapper class for constants representing colors or effects. + ]], + Functions = { + MakeColor = { Params = "ColorCodeConstant", Return = "string", Notes = "Creates the complete color-code-sequence from the color or effect constant" }, }, Constants = { - Color = { Notes = "|" }, - Delimiter = { Notes = "|" }, - Black = { Notes = "0" }, - Navy = { Notes = "1" }, - Green = { Notes = "2" }, - Blue = { Notes = "3" }, - Red = { Notes = "4" }, - Purple = { Notes = "5" }, - Gold = { Notes = "6" }, - LightGray = { Notes = "7" }, - Gray = { Notes = "8" }, - DarkPurple = { Notes = "9" }, - LightGreen = { Notes = "a" }, - LightBlue = { Notes = "b" }, - Rose = { Notes = "c" }, - LightPurple = { Notes = "d" }, - Yellow = { Notes = "e" }, - White = { Notes = "f" }, - Random = { Notes = "k" }, - Bold = { Notes = "l" }, - Strikethrough = { Notes = "m" }, - Underlined = { Notes = "n" }, - Italic = { Notes = "o" }, - Plain = { Notes = "r" }, - MakeColor = { Notes = "String" }, + Color = { Notes = "The first character of the color-code-sequence, §" }, + Delimiter = { Notes = "The first character of the color-code-sequence, §" }, + Random = { Notes = "Random letters and symbols animate instead of the text" }, + Plain = { Notes = "Resets all formatting to normal" }, }, }, - Data = - { - Desc = [[
  • Inherits {{cBlockEntity|cBlockEntity}}
  • -A chest entity represents a chest in the world, currently only single chests exist in MCServer -Chest entities are saved and loaded from disk when the chunk they reside in is saved or loaded -

    -

    Here's some raw C++ code showing how chest entities are saved - -void cChestEntity::WriteToFile(FILE* a_File) -{ - fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File ); - fwrite( &m_PosX, sizeof( int ), 1, a_File ); - fwrite( &m_PosY, sizeof( int ), 1, a_File ); - fwrite( &m_PosZ, sizeof( int ), 1, a_File ); -

    -

    unsigned int NumSlots = c_ChestHeight*c_ChestWidth; - fwrite( &NumSlots, sizeof(unsigned int), 1, a_File ); - for(unsigned int i = 0; i < NumSlots; i++) - { - cItem* Item = GetSlot( i ); - if( Item ) + cChestEntity = { - fwrite( &Item->m_ItemID, sizeof(Item->m_ItemID), 1, a_File ); - fwrite( &Item->m_ItemCount, sizeof(Item->m_ItemCount), 1, a_File ); - fwrite( &Item->m_ItemHealth, sizeof(Item->m_ItemHealth), 1, a_File ); - } - } -} - -]], + Desc = [[ + A chest entity is a {{cBlockEntityWithItems|cBlockEntityWithItems}} descendant that represents a chest + in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate + in any way. + ]], + + Inherits = "cBlockEntityWithItems", + Functions = { }, @@ -226,33 +200,38 @@ void cChestEntity::WriteToFile(FILE* a_File) cChunkDesc = { - Desc = [[The cChunkDesc class is a container for chunk data while the chunk is being generated. As such, it is only used as a parameter for the {{onchunkgenerating|OnChunkGenerating}} and {{OnChunkGenerated|OnChunkGenerated}} hooks and cannot be constructed on its own. Plugins can use this class in both those hooks to manipulate generated chunks. -]], + Desc = [[ + The cChunkDesc class is a container for chunk data while the chunk is being generated. As such, it is + only used as a parameter for the {{OnChunkGenerating|OnChunkGenerating}} and + {{OnChunkGenerated|OnChunkGenerated}} hooks and cannot be constructed on its own. Plugins can use this + class in both those hooks to manipulate generated chunks. + ]], + Functions = { - FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" }, - GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" }, - GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, - GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, - GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, - GetHeight = { Params = "RelX, RelZ", Return = "number", Notes = "Returns the height at the specified relative coords" }, - IsUsingDefaultBiomes = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default biome generator" }, + FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" }, + GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" }, + GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, + GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, + GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, + GetHeight = { Params = "RelX, RelZ", Return = "number", Notes = "Returns the height at the specified relative coords" }, + IsUsingDefaultBiomes = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default biome generator" }, IsUsingDefaultComposition = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default composition generator" }, - IsUsingDefaultFinish = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default finishers" }, - IsUsingDefaultHeight = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default height generator" }, - IsUsingDefaultStructures = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default structures" }, - ReadBlockArea = { Params = "BlockArea, MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ", Return = "", Notes = "Reads data from the chunk into the block area object" }, - SetBiome = { Params = "RelX, RelZ, EMCSBiome", Return = "", Notes = "Sets the biome at the specified relative coords" }, - SetBlockMeta = { Params = "RelX, RelY, RelZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified relative coords" }, - SetBlockType = { Params = "RelX, RelY, RelZ, BlockType", Return = "", Notes = "Sets the block type at the specified relative coords" }, - SetBlockTypeMeta = { Params = "RelX, RelY, RelZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block type and meta at the specified relative coords" }, - SetHeight = { Params = "RelX, RelZ, Height", Return = "", Notes = "Sets the height at the specified relative coords" }, - SetUseDefaultBiomes = { Params = "bool", Return = "", Notes = "Sets the chunk to use default biome generator or not" }, - SetUseDefaultComposition = { Params = "bool", Return = "", Notes = "Sets the chunk to use default composition generator or not" }, - SetUseDefaultFinish = { Params = "bool", Return = "", Notes = "Sets the chunk to use default finishers or not" }, - SetUseDefaultHeight = { Params = "bool", Return = "", Notes = "Sets the chunk to use default height generator or not" }, - SetUseDefaultStructures = { Params = "bool", Return = "", Notes = "Sets the chunk to use default structures or not" }, - WriteBlockArea = { Params = "BlockArea, MinRelX, MinRelY, MinRelZ", Return = "", Notes = "Writes data from the block area into the chunk" }, + IsUsingDefaultFinish = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default finishers" }, + IsUsingDefaultHeight = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default height generator" }, + IsUsingDefaultStructures = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default structures" }, + ReadBlockArea = { Params = "BlockArea, MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ", Return = "", Notes = "Reads data from the chunk into the block area object" }, + SetBiome = { Params = "RelX, RelZ, EMCSBiome", Return = "", Notes = "Sets the biome at the specified relative coords" }, + SetBlockMeta = { Params = "RelX, RelY, RelZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified relative coords" }, + SetBlockType = { Params = "RelX, RelY, RelZ, BlockType", Return = "", Notes = "Sets the block type at the specified relative coords" }, + SetBlockTypeMeta = { Params = "RelX, RelY, RelZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block type and meta at the specified relative coords" }, + SetHeight = { Params = "RelX, RelZ, Height", Return = "", Notes = "Sets the height at the specified relative coords" }, + SetUseDefaultBiomes = { Params = "bool", Return = "", Notes = "Sets the chunk to use default biome generator or not" }, + SetUseDefaultComposition = { Params = "bool", Return = "", Notes = "Sets the chunk to use default composition generator or not" }, + SetUseDefaultFinish = { Params = "bool", Return = "", Notes = "Sets the chunk to use default finishers or not" }, + SetUseDefaultHeight = { Params = "bool", Return = "", Notes = "Sets the chunk to use default height generator or not" }, + SetUseDefaultStructures = { Params = "bool", Return = "", Notes = "Sets the chunk to use default structures or not" }, + WriteBlockArea = { Params = "BlockArea, MinRelX, MinRelY, MinRelZ", Return = "", Notes = "Writes data from the block area into the chunk" }, }, Constants = { -- cgit v1.2.3 From 1f1216d56ddb5e3dcb13192bf5ebbca62a088ed4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 10:22:04 +0200 Subject: APIDump: Added support for inheritance --- MCServer/Plugins/APIDump/main.lua | 97 +++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 29 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 3988857c9..3ec6a1ccd 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -205,7 +205,7 @@ function DumpAPIHtml() ]]); for i, cls in ipairs(API) do f:write("

  • " .. cls.Name .. "
  • \n"); - WriteHtmlClass(cls); + WriteHtmlClass(cls, API); end f:write(""); f:close(); @@ -223,6 +223,7 @@ function ReadDescriptions(a_API) local APIDesc = g_APIDesc.Classes[cls.Name]; if (APIDesc ~= nil) then cls.Desc = APIDesc.Desc; + cls.Inherits = APIDesc.Inherits; if (APIDesc.Functions ~= nil) then -- Assign function descriptions: @@ -267,7 +268,7 @@ end -function WriteHtmlClass(a_ClassAPI) +function WriteHtmlClass(a_ClassAPI, a_AllAPI) local cf, err = io.open("API/" .. a_ClassAPI.Name .. ".html", "w"); if (cf == nil) then return; @@ -275,10 +276,49 @@ function WriteHtmlClass(a_ClassAPI) local function LinkifyString(a_String) -- TODO: Make a link out of anything with the special linkifying syntax {{link|title}} - -- a_String:gsub("{{([^|]*)|[^}]*}}", "%2"); + -- a_String:gsub("{{([^|]*)|([^}])*}}", "%2"); return a_String; end + -- Returns the ClassAPI for the inherited class, or nil if not found + local function FindInheritedClassAPI(a_AllAPI, a_InheritedClassName) + if (a_InheritedClassName == nil) then + return nil; + end + for i, cls in ipairs(a_AllAPI) do + if (cls.Name == a_InheritedClassName) then + return cls; + end + end + return nil; + end + + -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid + local function WriteFunctions(a_Functions, a_InheritedName) + if (#a_Functions == 0) then + return; + end + if (a_InheritedName ~= nil) then + cf:write("

    Functions inherited from " .. a_InheritedName .. "

    "); + end + cf:write("\n"); + for i, func in ipairs(a_Functions) do + cf:write(""); + cf:write(""); + cf:write(""); + cf:write("\n"); + end + cf:write("
    NameParametersReturn valueNotes
    " .. func.Name .. "" .. LinkifyString(func.Params or "").. "" .. LinkifyString(func.Return or "").. "" .. LinkifyString(func.Notes or "") .. "
    \n"); + end + + -- Build an array of inherited classes chain: + local InheritanceChain = {}; + local CurrInheritance = FindInheritedClassAPI(a_AllAPI, a_ClassAPI.Inherits); + while (CurrInheritance ~= nil) do + table.insert(InheritanceChain, CurrInheritance); + CurrInheritance = FindInheritedClassAPI(a_AllAPI, CurrInheritance.Inherits); + end + cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[ @@ -287,45 +327,44 @@ function WriteHtmlClass(a_ClassAPI) ]]); -- Write the table of contents: - if (#a_ClassAPI.Constants > 0) then - cf:write("
  • Constants
  • \n"); - end - if (#a_ClassAPI.Functions > 0) then - cf:write("
  • Functions
  • \n"); + if (a_ClassAPI.Inherits ~= nil) then + cf:write("
  • Inheritance
  • \n"); end + cf:write("
  • Constants
  • \n"); + cf:write("
  • Functions
  • \n"); cf:write(""); -- Write the class description: - cf:write("

    " .. a_ClassAPI.Name .. "

    \n"); + cf:write("

    " .. a_ClassAPI.Name .. " class

    \n"); if (a_ClassAPI.Desc ~= nil) then cf:write("

    "); cf:write(a_ClassAPI.Desc); cf:write("

    \n"); end; - -- Write the constants: - if (#a_ClassAPI.Constants > 0) then - cf:write("

    Constants

    \n"); - cf:write("\n"); - for i, cons in ipairs(a_ClassAPI.Constants) do - cf:write(""); - cf:write(""); - cf:write("\n"); + -- Write the inheritance, if available: + if (a_ClassAPI.Inherits ~= nil) then + cf:write("

    Inheritance

    \n"); + for i, cls in ipairs(InheritanceChain) do + cf:write("
  • " .. cls.Name .. "
  • "); end - cf:write("
    NameValueNotes
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "") .. "
    \n"); end - -- Write the functions: - if (#a_ClassAPI.Functions > 0) then - cf:write("

    Functions

    \n"); - cf:write("\n"); - for i, func in ipairs(a_ClassAPI.Functions) do - cf:write(""); - cf:write(""); - cf:write(""); - cf:write("\n"); - end - cf:write("
    NameParametersReturn valueNotes
    " .. func.Name .. "" .. LinkifyString(func.Params or "").. "" .. LinkifyString(func.Return or "").. "" .. LinkifyString(func.Notes or "") .. "
    \n"); + -- Write the constants: + cf:write("

    Constants

    \n"); + cf:write("\n"); + for i, cons in ipairs(a_ClassAPI.Constants) do + cf:write(""); + cf:write(""); + cf:write("\n"); + end + cf:write("
    NameValueNotes
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "") .. "
    \n"); + + -- Write the functions, including the inherited ones: + cf:write("

    Functions

    \n"); + WriteFunctions(a_ClassAPI.Functions, nil); + for i, cls in ipairs(InheritanceChain) do + WriteFunctions(cls.Functions, cls.Name); end cf:write(""); -- cgit v1.2.3 From 24e70d534b8cf6afac421ea616824c5731a8c0e5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 10:51:01 +0200 Subject: APIDump: Added descendants specified through inheritance. --- MCServer/Plugins/APIDump/main.lua | 86 +++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 27 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 3ec6a1ccd..79559eab4 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -87,6 +87,7 @@ function CreateAPITables() }, Constants = { } + Descendants = {}, -- Will be filled by ReadDescriptions(), array of class APIs (references to other member in the tree) }}, { Name = "cBlockArea", @@ -113,25 +114,27 @@ function CreateAPITables() }; --]] - local Globals = {Functions = {}, Constants = {}}; + local Globals = {Functions = {}, Constants = {}, Descendants = {}}; local API = {}; local function Add(a_APIContainer, a_ClassName, a_ClassObj) if (type(a_ClassObj) == "function") then table.insert(a_APIContainer.Functions, {Name = a_ClassName}); - elseif (type(a_ClassObj) == "number") then + elseif ( + (type(a_ClassObj) == "number") or + (type(a_ClassObj) == "string") + ) then table.insert(a_APIContainer.Constants, {Name = a_ClassName, Value = a_ClassObj}); end end local function SortClass(a_ClassAPI) - -- Sort the function list and constant lists: - table.sort(a_ClassAPI.Functions, + table.sort(a_ClassAPI.Functions, -- Sort function list function(f1, f2) return (f1.Name < f2.Name); end ); - table.sort(a_ClassAPI.Constants, + table.sort(a_ClassAPI.Constants, -- Sort constant list function(c1, c2) return (c1.Name < c2.Name); end @@ -139,7 +142,7 @@ function CreateAPITables() end; local function ParseClass(a_ClassName, a_ClassObj) - local res = {Name = a_ClassName, Functions = {}, Constants = {}}; + local res = {Name = a_ClassName, Functions = {}, Constants = {}, Descendants = {}}; for i, v in pairs(a_ClassObj) do Add(res, i, v); end @@ -223,7 +226,16 @@ function ReadDescriptions(a_API) local APIDesc = g_APIDesc.Classes[cls.Name]; if (APIDesc ~= nil) then cls.Desc = APIDesc.Desc; - cls.Inherits = APIDesc.Inherits; + + -- Process inheritance: + if (APIDesc.Inherits ~= nil) then + for j, icls in ipairs(a_API) do + if (icls.Name == APIDesc.Inherits) then + table.insert(icls.Descendants, cls); + cls.Inherits = icls; + end + end + end if (APIDesc.Functions ~= nil) then -- Assign function descriptions: @@ -261,7 +273,16 @@ function ReadDescriptions(a_API) end -- if (APIDesc.Constants ~= nil) end - end -- for i, class + end -- for i, cls + + -- Sort the descendants lists: + for i, cls in ipairs(a_API) do + table.sort(cls.Descendants, + function(c1, c2) + return (c1.Name < c2.Name); + end + ); + end -- for i, cls end @@ -280,19 +301,6 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) return a_String; end - -- Returns the ClassAPI for the inherited class, or nil if not found - local function FindInheritedClassAPI(a_AllAPI, a_InheritedClassName) - if (a_InheritedClassName == nil) then - return nil; - end - for i, cls in ipairs(a_AllAPI) do - if (cls.Name == a_InheritedClassName) then - return cls; - end - end - return nil; - end - -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid local function WriteFunctions(a_Functions, a_InheritedName) if (#a_Functions == 0) then @@ -310,13 +318,26 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end cf:write("\n"); end + + local function WriteDescendants(a_Descendants) + if (#a_Descendants == 0) then + return; + end + cf:write("
      "); + for i, desc in ipairs(a_Descendants) do + cf:write("
    • " .. desc.Name .. ""); + WriteDescendants(desc.Descendants); + cf:write("
    • \n"); + end + cf:write("
    \n"); + end -- Build an array of inherited classes chain: local InheritanceChain = {}; - local CurrInheritance = FindInheritedClassAPI(a_AllAPI, a_ClassAPI.Inherits); + local CurrInheritance = a_ClassAPI.Inherits; while (CurrInheritance ~= nil) do table.insert(InheritanceChain, CurrInheritance); - CurrInheritance = FindInheritedClassAPI(a_AllAPI, CurrInheritance.Inherits); + CurrInheritance = CurrInheritance.Inherits; end cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[ @@ -326,8 +347,10 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
      ]]); + local HasInheritance = ((#a_ClassAPI.Descendants > 0) or (a_ClassAPI.Inherits ~= nil)); + -- Write the table of contents: - if (a_ClassAPI.Inherits ~= nil) then + if (HasInheritance) then cf:write("
    • Inheritance
    • \n"); end cf:write("
    • Constants
    • \n"); @@ -343,10 +366,19 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end; -- Write the inheritance, if available: - if (a_ClassAPI.Inherits ~= nil) then + if (HasInheritance) then cf:write("

      Inheritance

      \n"); - for i, cls in ipairs(InheritanceChain) do - cf:write("
    • " .. cls.Name .. "
    • "); + if (#InheritanceChain > 0) then + cf:write("

      This class inherits from the following parent classes:

        \n"); + for i, cls in ipairs(InheritanceChain) do + cf:write("
      • " .. cls.Name .. "
      • \n"); + end + cf:write("

      \n"); + end + if (#a_ClassAPI.Descendants > 0) then + cf:write("

      This class has the following descendants:\n"); + WriteDescendants(a_ClassAPI.Descendants); + cf:write("

      \n"); end end -- cgit v1.2.3 From 9352af683dfb6fc80847e2842aabf881d91df4c1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 11:22:27 +0200 Subject: APIDump: Linkification works. --- MCServer/Plugins/APIDump/main.lua | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 79559eab4..b16df3c04 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -295,10 +295,9 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) return; end + -- Make a link out of anything with the special linkifying syntax {{link|title}} local function LinkifyString(a_String) - -- TODO: Make a link out of anything with the special linkifying syntax {{link|title}} - -- a_String:gsub("{{([^|]*)|([^}])*}}", "%2"); - return a_String; + return (a_String:gsub("{{([^|]*)|([^}]*)}}", "%2")); -- The extra parenthesis remove the extra values returned by gsub() end -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid @@ -361,7 +360,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write("

      " .. a_ClassAPI.Name .. " class

      \n"); if (a_ClassAPI.Desc ~= nil) then cf:write("

      "); - cf:write(a_ClassAPI.Desc); + cf:write(LinkifyString(a_ClassAPI.Desc)); cf:write("

      \n"); end; -- cgit v1.2.3 From b91c4a09861a49d531b5df5806f86edc58dcfb94 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 11:22:52 +0200 Subject: APIDump: Fixed cItem's description. --- MCServer/Plugins/APIDump/APIDesc.lua | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4e887a47b..d2f6f3437 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -621,25 +621,30 @@ These ItemGrids are available in the API and can be manipulated by the plugins, }, Constants = { - invArmorCount = { Notes = "4" }, - invArmorOffset = { Notes = "0" }, - invInventoryCount = { Notes = "" }, - invInventoryOffset = { Notes = "4" }, - invHotbarCount = { Notes = "9" }, - invHotbarOffset = { Notes = "" }, - invNumSlots = { Notes = "" }, + invArmorCount = { Notes = "Number of slots in the Armor part" }, + invArmorOffset = { Notes = "Starting slot number of the Armor part" }, + invInventoryCount = { Notes = "Number of slots in the main inventory part" }, + invInventoryOffset = { Notes = "Starting slot number of the main inventory part" }, + invHotbarCount = { Notes = "Number of slots in the Hotbar part" }, + invHotbarOffset = { Notes = "Starting slot number of the Hotbar part" }, + invNumSlots = { Notes = "Total number of slots in a cInventory" }, }, }, cItem = { - Desc = [[cItem is what defines an item or stack of items in the game, it contains the item ID, damage, quantity and enchantments. Each slot in a {{cEnchantments|cEnchantments}} class -]], + Desc = [[ + cItem is what defines an item or stack of items in the game, it contains the item ID, damage, + quantity and enchantments. Each slot in a {{cInventory|cInventory}} class or a + {{cItemGrid|cItemGrid}} class is a cItem and each cPickup contains a cItem. The enchantments + are contained in a {{cEnchantments|cEnchantments}} class + ]], + Functions = { - constructor = { Params = "", Return = "cItem", Notes = "Creates a new empty cItem obje" }, - constructor = { Params = "ItemType, Count, Damage, EnchantmentString", Return = "cItem", Notes = "Creates a new cItem object of the specified type, count (1 by default), damage (0 by default) and enchantments (non-enchanted by default)" }, - constructor = { Params = "cItem", Return = "cItem", Notes = "Creates an exact copy of the cItem object in the parameter" }, + constructor1 = { Params = "", Return = "cItem", Notes = "Creates a new empty cItem obje" }, + constructor2 = { Params = "ItemType, Count, Damage, EnchantmentString", Return = "cItem", Notes = "Creates a new cItem object of the specified type, count (1 by default), damage (0 by default) and enchantments (non-enchanted by default)" }, + constructor3 = { Params = "cItem", Return = "cItem", Notes = "Creates an exact copy of the cItem object in the parameter" }, Clear = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, CopyOne = { Params = "", Return = "cItem", Notes = "Creates a copy of this object, with its count set to 1" }, DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" }, -- cgit v1.2.3 From af8f7eb96379044f62fff5bf42591025564feb88 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 14:05:18 +0200 Subject: APIDump: Added support for ignoring functions; ignoring the lua/tolua internals. --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + MCServer/Plugins/APIDump/main.lua | 43 ++++++++++++++++++++++++------------ 2 files changed, 30 insertions(+), 14 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index d2f6f3437..c5ae0f890 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1309,6 +1309,7 @@ A list of items regarding WebPlugins that have been documented "globals.assert", "globals.collectgarbage", "globals.xpcall", + "%a+\.__%a+", -- AnyClass.__Anything }, } ; diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index b16df3c04..5f8dc64b7 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -117,14 +117,14 @@ function CreateAPITables() local Globals = {Functions = {}, Constants = {}, Descendants = {}}; local API = {}; - local function Add(a_APIContainer, a_ClassName, a_ClassObj) - if (type(a_ClassObj) == "function") then - table.insert(a_APIContainer.Functions, {Name = a_ClassName}); + local function Add(a_APIContainer, a_ObjName, a_ObjValue) + if (type(a_ObjValue) == "function") then + table.insert(a_APIContainer.Functions, {Name = a_ObjName}); elseif ( - (type(a_ClassObj) == "number") or - (type(a_ClassObj) == "string") + (type(a_ObjValue) == "number") or + (type(a_ObjValue) == "string") ) then - table.insert(a_APIContainer.Constants, {Name = a_ClassName, Value = a_ClassObj}); + table.insert(a_APIContainer.Constants, {Name = a_ObjName, Value = a_ObjValue}); end end @@ -153,12 +153,7 @@ function CreateAPITables() for i, v in pairs(_G) do if (type(v) == "table") then - -- It is a table - probably a class - local StartLetter = GetChar(i, 0); - if (StartLetter == "c") then - -- Starts with a "c", handle it as a MCS API class - table.insert(API, ParseClass(i, v)); - end + table.insert(API, ParseClass(i, v)); else Add(Globals, i, v); end @@ -221,7 +216,18 @@ end function ReadDescriptions(a_API) + -- Returns true if the function (specified by its fully qualified name) is to be ignored + local function IsFunctionIgnored(a_FnName) + for i, name in ipairs(g_APIDesc.IgnoreFunctions) do + if (a_FnName:match(name)) then + return true; + end + end + return false; + end + local UnexportedDocumented = {}; -- List of API objects that are documented but not exported, simply a list of names + for i, cls in ipairs(a_API) do local APIDesc = g_APIDesc.Classes[cls.Name]; if (APIDesc ~= nil) then @@ -272,9 +278,18 @@ function ReadDescriptions(a_API) end end -- if (APIDesc.Constants ~= nil) - end + -- Remove ignored functions: + local NewFunctions = {}; + for j, fn in ipairs(cls.Functions) do + if (not(IsFunctionIgnored(cls.Name .. "." .. fn.Name))) then + table.insert(NewFunctions, fn); + end + end -- for j, fn + cls.Functions = NewFunctions; + + end -- if (APIDesc ~= nil) end -- for i, cls - + -- Sort the descendants lists: for i, cls in ipairs(a_API) do table.sort(cls.Descendants, -- cgit v1.2.3 From d2deb381c2ef9ef9b39a587cd53271ddcd51b511 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 16:04:32 +0200 Subject: APIDump: Constructors are renamed and can have documentation --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + MCServer/Plugins/APIDump/main.lua | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index c5ae0f890..e7b759505 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -43,6 +43,7 @@ g_APIDesc = ]], Functions = { + constructor = { Params = "", Return = "cBlockArea", Notes = "Creates a new empty cBlockArea object" }, Clear = { Params = "", Return = "", Notes = "Clears the object, resets it to zero size" }, CopyFrom = { Params = "BlockAreaSrc", Return = "", Notes = "Copies contents from BlockAreaSrc into self" }, CopyTo = { Params = "BlockAreaDst", Return = "", Notes = "Copies contents from self into BlockAreaDst." }, diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 5f8dc64b7..136a8d12f 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -246,8 +246,12 @@ function ReadDescriptions(a_API) if (APIDesc.Functions ~= nil) then -- Assign function descriptions: for j, func in ipairs(cls.Functions) do - -- func is {"FuncName"}, add Parameters, Return and Notes from g_APIDesc - local FnDesc = APIDesc.Functions[func.Name]; + local FnName = func.Name; + if (FnName == ".call") then + FnName = "constructor"; + func.Name = "() (constructor)"; + end + local FnDesc = APIDesc.Functions[FnName]; if (FnDesc ~= nil) then func.Params = FnDesc.Params; func.Return = FnDesc.Return; -- cgit v1.2.3 From e3888bb1474ef4d747c9da47b83a49e519a2d3dc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 16:26:17 +0200 Subject: APIDump: Basic CSS file makes tables visible --- MCServer/Plugins/APIDump/main.css | 23 +++++++++++++++++++++++ MCServer/Plugins/APIDump/main.lua | 12 ++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 MCServer/Plugins/APIDump/main.css (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css new file mode 100644 index 000000000..f9cdfc3ce --- /dev/null +++ b/MCServer/Plugins/APIDump/main.css @@ -0,0 +1,23 @@ +table +{ + background-color: #fff; + border-spacing: 0px; + border-collapse: collapse; + border-color: gray; +} + +tr +{ + display: table-row; + vertical-align: inherit; + border-color: inherit; +} + +td, th +{ + display: table-cell; + vertical-align: inherit; + padding: 3px; + border: 1px solid #ccc; +} + diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 136a8d12f..09f198da4 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -208,6 +208,18 @@ function DumpAPIHtml() f:write("
    "); f:close(); + -- Copy the CSS file to the output folder (overwrite any existing): + cssf = io.open("API/main.css", "w"); + if (cssf ~= nil) then + cssfi = io.open(g_Plugin:GetLocalDirectory() .. "/main.css", "r"); + if (cssfi ~= nil) then + local CSS = cssfi:read("*all"); + cssf:write(CSS); + cssfi:close(); + end + cssf:close(); + end + LOG("API subfolder written"); end -- cgit v1.2.3 From ddda753f5272f95c6cec60c0492d61215c948488 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 16:29:24 +0200 Subject: APIDump: Fixed link in cBlockArea's docs --- MCServer/Plugins/APIDump/APIDesc.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e7b759505..7fb001b76 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -14,7 +14,7 @@ g_APIDesc = { Desc = [[ This class is used when multiple adjacent blocks are to be manipulated. Because of chunking - and multithreading, manipulating single blocks using {{api:cWorld|cWorld:SetBlock}}() is a rather + and multithreading, manipulating single blocks using {{cWorld|cWorld:SetBlock}}() is a rather time-consuming operation (locks for exclusive access need to be obtained, chunk lookup is done for each block), so whenever you need to manipulate multiple adjacent blocks, it's better to wrap the operation into a cBlockArea access. cBlockArea is capable of reading / writing across chunk @@ -36,9 +36,9 @@ g_APIDesc =

    Typical usage:

    • Create cBlockArea object
    • -
    • Read an area from the world
    • +
    • Read an area from the world / load from file / create anew
    • Modify blocks inside cBlockArea
    • -
    • Write the area back to a world
    • +
    • Write the area back to a world / save to file

    ]], Functions = -- cgit v1.2.3 From a9969408e45f320a9add45763d864f5b54ef98e1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 13 Sep 2013 16:38:39 +0200 Subject: APIDump: Ignoring some Lua internal stuff from API-scanning. --- MCServer/Plugins/APIDump/main.lua | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 09f198da4..daa5d1236 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -152,10 +152,16 @@ function CreateAPITables() end for i, v in pairs(_G) do - if (type(v) == "table") then - table.insert(API, ParseClass(i, v)); - else - Add(Globals, i, v); + if ( + (v ~= _G) and -- don't want the global namespace + (v ~= _G.packages) and -- don't want any packages + (v ~= _G[".get"]) + ) then + if (type(v) == "table") then + table.insert(API, ParseClass(i, v)); + else + Add(Globals, i, v); + end end end SortClass(Globals); -- cgit v1.2.3 From 024b0803747dc639477df3863171f0227dd548c4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 08:27:31 +0200 Subject: APIDump: Ignored functions are removed from undocumented classes, too. --- MCServer/Plugins/APIDump/main.lua | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index daa5d1236..2a4a83be9 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -299,17 +299,16 @@ function ReadDescriptions(a_API) -- TODO end end -- if (APIDesc.Constants ~= nil) - - -- Remove ignored functions: - local NewFunctions = {}; - for j, fn in ipairs(cls.Functions) do - if (not(IsFunctionIgnored(cls.Name .. "." .. fn.Name))) then - table.insert(NewFunctions, fn); - end - end -- for j, fn - cls.Functions = NewFunctions; - end -- if (APIDesc ~= nil) + + -- Remove ignored functions: + local NewFunctions = {}; + for j, fn in ipairs(cls.Functions) do + if (not(IsFunctionIgnored(cls.Name .. "." .. fn.Name))) then + table.insert(NewFunctions, fn); + end + end -- for j, fn + cls.Functions = NewFunctions; end -- for i, cls -- Sort the descendants lists: -- cgit v1.2.3 From efe0273c09a2a659083bd51a4a9bd069e335ed67 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 08:31:34 +0200 Subject: APIDump: Added more globally-ignored functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7fb001b76..faa24c07c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1310,7 +1310,10 @@ A list of items regarding WebPlugins that have been documented "globals.assert", "globals.collectgarbage", "globals.xpcall", - "%a+\.__%a+", -- AnyClass.__Anything + "%a+\.__%a+", -- AnyClass.__Anything + "%a+\.\.collector", -- AnyClass..collector + "%a+\.new", -- AnyClass.new + "%a+.new_local", -- AnyClass.new_local }, } ; -- cgit v1.2.3 From badacdb7c6ccc4200d67b4d0ef4c69f9087422ff Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 08:38:39 +0200 Subject: APIDump: Added special-function renaming (constructor, operators). --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + MCServer/Plugins/APIDump/main.lua | 26 +++++++++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index faa24c07c..1578e01ed 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1251,6 +1251,7 @@ A list of items regarding plugins that have been documented ]], Functions = { + operator_plus = {Params = "{{Vector3d}}", Return = "{{Vector3d}}", Notes = "Returns the sum of this vector with the specified vector" }, }, Constants = { diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 2a4a83be9..446763905 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -247,6 +247,26 @@ function ReadDescriptions(a_API) local UnexportedDocumented = {}; -- List of API objects that are documented but not exported, simply a list of names for i, cls in ipairs(a_API) do + -- Rename special functions: + for j, fn in ipairs(cls.Functions) do + if (fn.Name == ".call") then + fn.DocID = "constructor"; + fn.Name = "() (constructor)"; + elseif (fn.Name == ".add") then + fn.DocID = "operator_plus"; + fn.Name = "operator +"; + elseif (fn.Name == ".div") then + fn.DocID = "operator_div"; + fn.Name = "operator /"; + elseif (fn.Name == ".mul") then + fn.DocID = "operator_mul"; + fn.Name = "operator *"; + elseif (fn.Name == ".sub") then + fn.DocID = "operator_sub"; + fn.Name = "operator -"; + end + end + local APIDesc = g_APIDesc.Classes[cls.Name]; if (APIDesc ~= nil) then cls.Desc = APIDesc.Desc; @@ -264,11 +284,7 @@ function ReadDescriptions(a_API) if (APIDesc.Functions ~= nil) then -- Assign function descriptions: for j, func in ipairs(cls.Functions) do - local FnName = func.Name; - if (FnName == ".call") then - FnName = "constructor"; - func.Name = "() (constructor)"; - end + local FnName = func.DocID or func.Name; local FnDesc = APIDesc.Functions[FnName]; if (FnDesc ~= nil) then func.Params = FnDesc.Params; -- cgit v1.2.3 From 694878d2e87bf1c3dcd7cd4fce76532483b905a1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 08:41:48 +0200 Subject: APIDump: Linkifications works for simple {{link}} too. --- MCServer/Plugins/APIDump/main.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 446763905..e7f652bd5 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -349,7 +349,9 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Make a link out of anything with the special linkifying syntax {{link|title}} local function LinkifyString(a_String) - return (a_String:gsub("{{([^|]*)|([^}]*)}}", "%2")); -- The extra parenthesis remove the extra values returned by gsub() + local txt = a_String:gsub("{{([^|]*)|([^}]*)}}", "%2") -- {{link|title}} + txt = txt:gsub("{{([^|]*)}}", "%1") -- {{LinkAndTitle}} + return txt; end -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid -- cgit v1.2.3 From d2c2d4ba52242acc85e15872340b492a9dad1201 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 16:20:54 +0200 Subject: APIDump: Moved sorting after the renaming. --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + MCServer/Plugins/APIDump/main.lua | 45 +++++++++++++++++++----------------- 2 files changed, 25 insertions(+), 21 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1578e01ed..1ee9e9a8d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1315,6 +1315,7 @@ A list of items regarding WebPlugins that have been documented "%a+\.\.collector", -- AnyClass..collector "%a+\.new", -- AnyClass.new "%a+.new_local", -- AnyClass.new_local + "%a+.delete", -- AnyClass.delete }, } ; diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index e7f652bd5..0c9d683fb 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -128,26 +128,11 @@ function CreateAPITables() end end - local function SortClass(a_ClassAPI) - table.sort(a_ClassAPI.Functions, -- Sort function list - function(f1, f2) - return (f1.Name < f2.Name); - end - ); - table.sort(a_ClassAPI.Constants, -- Sort constant list - function(c1, c2) - return (c1.Name < c2.Name); - end - ); - end; - local function ParseClass(a_ClassName, a_ClassObj) local res = {Name = a_ClassName, Functions = {}, Constants = {}, Descendants = {}}; for i, v in pairs(a_ClassObj) do Add(res, i, v); end - - SortClass(res); return res; end @@ -164,12 +149,6 @@ function CreateAPITables() end end end - SortClass(Globals); - table.sort(API, - function(c1, c2) - return (c1.Name < c2.Name); - end - ); return API, Globals; end @@ -182,6 +161,15 @@ function DumpAPIHtml() LOG("Dumping all available functions and constants to API subfolder..."); local API, Globals = CreateAPITables(); + + -- Sort the classes by name: + table.sort(API, + function (c1, c2) + return (string.lower(c1.Name) < string.lower(c2.Name)); + end + ); + + -- Add Globals into the API: Globals.Name = "Globals"; table.insert(API, Globals); @@ -325,6 +313,20 @@ function ReadDescriptions(a_API) end end -- for j, fn cls.Functions = NewFunctions; + + -- Sort the functions (they may have been renamed): + table.sort(cls.Functions, + function(f1, f2) + return (f1.Name < f2.Name); + end + ); + + -- Sort the constants: + table.sort(cls.Constants, + function(c1, c2) + return (c1.Name < c2.Name); + end + ); end -- for i, cls -- Sort the descendants lists: @@ -359,6 +361,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) if (#a_Functions == 0) then return; end + if (a_InheritedName ~= nil) then cf:write("

    Functions inherited from " .. a_InheritedName .. "

    "); end -- cgit v1.2.3 From 0b10f5f79523686a61ccd42deb0e008004565a82 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 16:27:12 +0200 Subject: APIDump: Do not dump the g_APIDesc and APIDump's functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 14 +++++++++++--- MCServer/Plugins/APIDump/main.lua | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1ee9e9a8d..7e033f2af 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1308,14 +1308,22 @@ A list of items regarding WebPlugins that have been documented IgnoreFunctions = { - "globals.assert", - "globals.collectgarbage", - "globals.xpcall", + "Globals.assert", + "Globals.collectgarbage", + "Globals.xpcall", "%a+\.__%a+", -- AnyClass.__Anything "%a+\.\.collector", -- AnyClass..collector "%a+\.new", -- AnyClass.new "%a+.new_local", -- AnyClass.new_local "%a+.delete", -- AnyClass.delete + + -- Functions global in the APIDump plugin: + "Initialize", + "DumpAPITxt", + "CreateAPITables", + "DumpAPIHtml", + "ReadDescriptions", + "WriteHtmlClass", }, } ; diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 0c9d683fb..35b99eb8b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -140,7 +140,8 @@ function CreateAPITables() if ( (v ~= _G) and -- don't want the global namespace (v ~= _G.packages) and -- don't want any packages - (v ~= _G[".get"]) + (v ~= _G[".get"]) and + (v ~= g_APIDesc) ) then if (type(v) == "table") then table.insert(API, ParseClass(i, v)); -- cgit v1.2.3 From de77eaaecdb36dacfb2a616a07588670f2375006 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 16:52:15 +0200 Subject: APIDump: Added support for overloaded functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 28 +++++++++++++++++------- MCServer/Plugins/APIDump/main.lua | 42 +++++++++++++++++++++++++++++++----- 2 files changed, 57 insertions(+), 13 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7e033f2af..7d1ea4cce 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -152,10 +152,16 @@ g_APIDesc = Functions = { GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, - GetSlot = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, - GetSlot = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, - SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, - SetSlot = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, + GetSlot = + { + { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, + { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, + }, + SetSlot = + { + { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, + { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, + }, }, Constants = { @@ -297,10 +303,16 @@ g_APIDesc = GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" }, GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" }, GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" }, - SetIngredient = { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" }, - SetIngredient = { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" }, - SetResult = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" }, - SetResult = { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" }, + SetIngredient = + { + { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" }, + { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" }, + }, + SetResult = + { + { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the result item" }, + { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" }, + }, }, Constants = { diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 35b99eb8b..e1aa39dd2 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -269,20 +269,42 @@ function ReadDescriptions(a_API) end end end + + cls.Undocumented = {}; -- This will contain all the API objects that are not documented + + local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation + + local function AddFunction(a_Name, a_Params, a_Return, a_Notes) + table.insert(DoxyFunctions, {Name = a_Name, Params = a_Params, Return = a_Return, Notes = a_Notes}); + end if (APIDesc.Functions ~= nil) then -- Assign function descriptions: for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; local FnDesc = APIDesc.Functions[FnName]; - if (FnDesc ~= nil) then - func.Params = FnDesc.Params; - func.Return = FnDesc.Return; - func.Notes = FnDesc.Notes; + if (FnDesc == nil) then + -- No description for this API function + AddFunction(func.Name); + table.insert(cls.Undocumented, func.Name); + else + -- Description is available + if (FnDesc[1] == nil) then + -- Single function definition + AddFunction(func.Name, FnDesc.Params, FnDesc.Return, FnDesc.Notes); + else + -- Multiple function overloads + for k, desc in ipairs(FnDesc) do + AddFunction(func.Name, desc.Params, desc.Return, desc.Notes); + end -- for k, desc - FnDesc[] + end FnDesc.IsExported = true; end end -- for j, func + -- Replace functions with their described and overload-expanded versions: + cls.Functions = DoxyFunctions; + -- Add all non-exported function descriptions to UnexportedDocumented: for j, func in pairs(APIDesc.Functions) do -- TODO @@ -293,7 +315,10 @@ function ReadDescriptions(a_API) -- Assign constant descriptions: for j, cons in ipairs(cls.Constants) do local CnDesc = APIDesc.Constants[cons.Name]; - if (CnDesc ~= nil) then + if (CnDesc == nil) then + -- Not documented + table.insert(cls.Undocumented, cons.Name); + else cons.Notes = CnDesc.Notes; CnDesc.IsExported = true; end @@ -318,6 +343,13 @@ function ReadDescriptions(a_API) -- Sort the functions (they may have been renamed): table.sort(cls.Functions, function(f1, f2) + if (f1.Name == f2.Name) then + -- Same name, either comparing the same function to itself, or two overloads, in which case compare the params + if ((f1.Params == nil) or (f2.Params == nil)) then + return 0; + end + return (f1.Params < f2.Params); + end return (f1.Name < f2.Name); end ); -- cgit v1.2.3 From 85c4a1ebcacbf8647d106ab541a6484620a34d24 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 17:28:22 +0200 Subject: APIDump: Added support for additional info exported with each class. --- MCServer/Plugins/APIDump/APIDesc.lua | 78 +++++++++++++++++++++++++++++++++++- MCServer/Plugins/APIDump/main.lua | 14 +++++++ 2 files changed, 91 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7d1ea4cce..7ff169bbc 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -110,7 +110,83 @@ g_APIDesc = msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" }, msLake = { Notes = "Special mode for merging lake images" }, }, - }, + + AdditionalInfo = { + { + Header = "Merge strategies", + Contents = + [[ +

    The strategy parameter specifies how individual blocks are combined together, using the table below. +

    + + + + + + + + + + + + + + + + + + + +
    area blockresult
    this Src msOverwrite msFillAir msImprint
    air air air air air
    A air air A A
    air B B B B
    A B B A B
    + +

    + So to sum up: +

      +
    1. msOverwrite completely overwrites all blocks with the Src's blocks
    2. +
    3. msFillAir overwrites only those blocks that were air
    4. +
    5. msImprint overwrites with only those blocks that are non-air
    6. +
    +

    + +

    + Special strategies: +

    + +

    + msLake (evaluate top-down, first match wins): +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    area block Notes
    this Src result
    A sponge A Sponge is the NOP block
    * air air Air always gets hollowed out, even under the oceans
    water * water Water is never overwritten
    lava * lava Lava is never overwritten
    * water water Water always overwrites anything
    * lava lava Lava always overwrites anything
    dirt stone stone Stone overwrites dirt
    grass stone stone ... and grass
    mycelium stone stone ... and mycelium
    A stone A ... but nothing else
    A * A Everything else is left as it is
    + ]], + }, -- Merge strategies + }, -- AdditionalInfo + }, -- cBlockArea cBlockEntity = { diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index e1aa39dd2..758df8341 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -259,6 +259,7 @@ function ReadDescriptions(a_API) local APIDesc = g_APIDesc.Classes[cls.Name]; if (APIDesc ~= nil) then cls.Desc = APIDesc.Desc; + cls.AdditionalInfo = APIDesc.AdditionalInfo; -- Process inheritance: if (APIDesc.Inherits ~= nil) then @@ -444,6 +445,11 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end cf:write("
  • Constants
  • \n"); cf:write("
  • Functions
  • \n"); + if (a_ClassAPI.AdditionalInfo ~= nil) then + for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do + cf:write("
  • " .. additional.Header .. "
  • \n"); + end + end cf:write(""); -- Write the class description: @@ -488,6 +494,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) WriteFunctions(cls.Functions, cls.Name); end + -- Write the additional infos: + if (a_ClassAPI.AdditionalInfo ~= nil) then + for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do + cf:write("

    " .. additional.Header .. "

    \n"); + cf:write(additional.Contents); + end + end + cf:write(""); cf:close(); end -- cgit v1.2.3 From ec18331e664e2860ad075fa6b3610eec68e98321 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 17:43:06 +0200 Subject: APIDump: Added an example on how to fill in the documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 63 +++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7ff169bbc..af5828405 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -10,6 +10,41 @@ g_APIDesc = { Classes = { + --[[ + -- What the APIDump plugin understands / how to document stuff: + ExampleClassName = + { + Desc = "Description, exported as the first paragraph of the class page. Usually enclosed within double brackets." + + Functions = + { + FunctionName = { Params = "Parameter list", Return = "Return values list", Notes = "Notes" ), + OverloadedFunctionName = -- When a function supports multiple parameter variants + { + { Params = "Parameter list 1", Return = "Return values list 1", Notes = "Notes 1" }, + { Params = "Parameter list 2", Return = "Return values list 2", Notes = "Notes 2" }, + } + } , + + Constants = + { + ConstantName = { Notes = "Notes about the constant" }, + } , + + AdditionalInfo = -- Paragraphs to be exported after the function definitions table + { + { + Header = "Header 1", + Contents = "Contents of the additional section 1", + }, + { + Header = "Header 2", + Contents = "Contents of the additional section 2", + } + }, + }, + ]]-- + cBlockArea = { Desc = [[ @@ -111,7 +146,8 @@ g_APIDesc = msLake = { Notes = "Special mode for merging lake images" }, }, - AdditionalInfo = { + AdditionalInfo = + { { Header = "Merge strategies", Contents = @@ -323,8 +359,10 @@ g_APIDesc = cClientHandle = { - Desc = [[A cClientHandle represents technical aspect of connected player - it's game client. -]], + Desc = [[ + A cClientHandle represents technical aspect of a connected player - their game client connection. + ]], + Functions = { GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, @@ -346,8 +384,13 @@ g_APIDesc = cCraftingGrid = { - Desc = [[cCraftingGrid represents the player's crafting grid. It is used only in {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect the items the player placed on their crafting grid. -]], + Desc = [[ + cCraftingGrid represents the player's crafting grid. It is used only in + {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and + {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect the items the player placed + on their crafting grid. + ]], + Functions = { Clear = { Params = "", Return = "", Notes = "Clears the entire grid" }, @@ -356,8 +399,11 @@ g_APIDesc = GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the grid" }, GetItem = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified coords" }, GetWidth = { Params = "", Return = "number", Notes = "Returns the width of the grid" }, - SetItem = { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified coords" }, - SetItem = { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" }, + SetItem = + { + { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified coords" }, + { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" }, + }, }, Constants = { @@ -366,7 +412,8 @@ g_APIDesc = cCraftingRecipe = { - Desc = [[This class is used to represent a crafting recipe, either a built-in one, or one created dynamically in a plugin. It is used only as a parameter for {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect or modify a crafting recipe that a player views in their crafting window, either at a crafting table or the survival inventory screen. + Desc = [[ + This class is used to represent a crafting recipe, either a built-in one, or one created dynamically in a plugin. It is used only as a parameter for {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect or modify a crafting recipe that a player views in their crafting window, either at a crafting table or the survival inventory screen.

    Internally, the class contains a {{cItem|cItem}} for the result. ]], -- cgit v1.2.3 From 3ed9e148e8d13b0e6e3115a5d1ad2c87bdcfb443 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 17:56:51 +0200 Subject: APIDump: Added cArrowEntity documentation --- MCServer/Plugins/APIDump/APIDesc.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index af5828405..f29ce7f27 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -42,9 +42,38 @@ g_APIDesc = Contents = "Contents of the additional section 2", } }, + + Inherits = "ParentClassName", -- Only present if the class inherits from another API class }, ]]-- + cArrowEntity = + { + Desc = [[ + Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}. + ]], + + Functions = + { + CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" }, + GetDamageCoeff = { Params = "", Return = "number", Notes = "Returns the damage coefficient stored within the arrow. The damage dealt by this arrow is multiplied by this coeff" }, + GetPickupState = { Params = "", Return = "PickupState", Notes = "Returns the pickup state (one of the psXXX constants, above)" }, + IsCritical = { Params = "", Return = "bool", Notes = "Returns true if the arrow should deal critical damage. Based on the bow charge when the arrow was shot." }, + SetDamageCoeff = { Params = "number", Return = "", Notes = "Sets the damage coefficient. The damage dealt by this arrow is multiplied by this coeff" }, + SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" }, + SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" }, + }, + + Constants = + { + psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" }, + psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" }, + psNoPickup = { Notes = "The arrow cannot be picked up at all" }, + }, + + Inherits = "cProjectileEntity", + }, + cBlockArea = { Desc = [[ -- cgit v1.2.3 From 62b74d00544f71791a5b53194637265afe968686 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 21:47:11 +0200 Subject: APIDump: Added a simple header to the class index. --- MCServer/Plugins/APIDump/main.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 758df8341..68c8b63bc 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -193,14 +193,15 @@ function DumpAPIHtml() f:write([[MCServer API - class index - +

    MCServer API - class index

    +

    The following classes are available in the MCServer Lua scripting language:

      ]]); for i, cls in ipairs(API) do f:write("
    • " .. cls.Name .. "
    • \n"); WriteHtmlClass(cls, API); end - f:write("
    "); + f:write("

    "); f:close(); -- Copy the CSS file to the output folder (overwrite any existing): -- cgit v1.2.3 From 66aee0ec687f30f8e9c847a7f3cecb8ed8a31525 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 22:15:58 +0200 Subject: APIDump: Implemented creating the list of undocumented API objects. --- MCServer/Plugins/APIDump/main.lua | 68 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 68c8b63bc..a38dad44d 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -216,6 +216,47 @@ function DumpAPIHtml() cssf:close(); end + -- List the undocumented objects: + f = io.open("API/undocumented.lua", "w"); + if (f ~= nil) then + f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); + f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); + for i, cls in ipairs(API) do + local HasWrittenClassHeader = false; + local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); + local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); + if (HasFunctions or HasConstants) then + f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); + if ((cls.Desc == nil) or (cls.Desc == "")) then + f:write("\t\t\tDesc = \"\"\n"); + end + end + + if (HasFunctions) then + f:write("\t\t\tFunctions =\n\t\t\t{\n"); + table.sort(cls.UndocumentedFunctions); + for j, fn in ipairs(cls.UndocumentedFunctions) do + f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); + end -- for j, fn - cls.Undocumented[] + f:write("\t\t\t},\n\n"); + end + + if (HasConstants) then + f:write("\t\t\tConstants =\n\t\t\t{\n"); + table.sort(cls.UndocumentedConstants); + for j, cn in ipairs(cls.UndocumentedConstants) do + f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); + end -- for j, fn - cls.Undocumented[] + f:write("\t\t\t},\n\n"); + end + + if (HasFunctions or HasConstants) then + f:write("\t\t},\n\n"); + end + end -- for i, cls - API[] + f:close(); + end + LOG("API subfolder written"); end @@ -226,6 +267,9 @@ end function ReadDescriptions(a_API) -- Returns true if the function (specified by its fully qualified name) is to be ignored local function IsFunctionIgnored(a_FnName) + if (g_APIDesc.IgnoreFunctions == nil) then + return false; + end for i, name in ipairs(g_APIDesc.IgnoreFunctions) do if (a_FnName:match(name)) then return true; @@ -234,6 +278,19 @@ function ReadDescriptions(a_API) return false; end + -- Returns true if the constant (specified by its fully qualified name) is to be ignored + local function IsConstantIgnored(a_CnName) + if (g_APIDesc.IgnoreConstants == nil) then + return false; + end; + for i, name in ipairs(g_APIDesc.IgnoreConstants) do + if (a_CnName:match(name)) then + return true; + end + end + return false; + end + local UnexportedDocumented = {}; -- List of API objects that are documented but not exported, simply a list of names for i, cls in ipairs(a_API) do @@ -272,7 +329,8 @@ function ReadDescriptions(a_API) end end - cls.Undocumented = {}; -- This will contain all the API objects that are not documented + cls.UndocumentedFunctions = {}; -- This will contain names of all the functions that are not documented + cls.UndocumentedConstants = {}; -- This will contain names of all the constants that are not documented local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation @@ -288,7 +346,9 @@ function ReadDescriptions(a_API) if (FnDesc == nil) then -- No description for this API function AddFunction(func.Name); - table.insert(cls.Undocumented, func.Name); + if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + table.insert(cls.UndocumentedFunctions, FnName); + end else -- Description is available if (FnDesc[1] == nil) then @@ -319,7 +379,9 @@ function ReadDescriptions(a_API) local CnDesc = APIDesc.Constants[cons.Name]; if (CnDesc == nil) then -- Not documented - table.insert(cls.Undocumented, cons.Name); + if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then + table.insert(cls.UndocumentedConstants, cons.Name); + end else cons.Notes = CnDesc.Notes; CnDesc.IsExported = true; -- cgit v1.2.3 From 24daabdbfc217a5ddf4eb409c52382ccc59ef41f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 22:34:19 +0200 Subject: APIDump: Added creating the list of unexported-documented API objects. --- MCServer/Plugins/APIDump/main.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index a38dad44d..280e3034c 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -257,6 +257,29 @@ function DumpAPIHtml() f:close(); end + -- List the unexported documented API objects: + f = io.open("API/unexported-documented.txt", "w"); + if (f ~= nil) then + for clsname, cls in pairs(g_APIDesc.Classes) do + if not(cls.IsExported) then + -- The whole class is not exported + f:write("class\t" .. clsname .. "\n"); + else + for fnname, fnapi in pairs(cls.Functions) do + if not(fnapi.IsExported) then + f:write("func\t" .. clsname .. "." .. fnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + for cnname, cnapi in pairs(cls.Constants) do + if not(cnapi.IsExported) then + f:write("const\t" .. clsname .. "." .. cnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end + end -- for i, cls - g_APIDesc.Classes[] + f:close(); + end + LOG("API subfolder written"); end @@ -316,6 +339,7 @@ function ReadDescriptions(a_API) local APIDesc = g_APIDesc.Classes[cls.Name]; if (APIDesc ~= nil) then + APIDesc.IsExported = true; cls.Desc = APIDesc.Desc; cls.AdditionalInfo = APIDesc.AdditionalInfo; -- cgit v1.2.3 From 57414e45b659d2b7c3f3c355929018f8eaee37a2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 23:03:03 +0200 Subject: APIDump: Fixed cLuaWindow documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 126 ++++++++++++++++++----------------- 1 file changed, 64 insertions(+), 62 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f29ce7f27..f006f89b4 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -912,18 +912,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, }, }, - cluachunk = - { - Desc = [[]], - Functions = - { - }, - Constants = - { - }, - }, - - Callbacks = + cLuaWindow = { Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set.

    @@ -934,21 +923,6 @@ These ItemGrids are available in the API and can be manipulated by the plugins,

    When creating a new cLuaWindow object, you need to specify both the window type and the contents' width and height. Note that MCServer accepts any combination of these, but opening a window for a player may crash their client if the contents' dimensions don't match the client's expectations.

    To open the window for a player, call {{cPlayer|cPlayer}}:OpenWindow(). Multiple players can open window of the same cLuaWindow object. All players see the same items in the window's contents (like chest, unlike crafting table). -The object calls the following functions at the appropriate time: -==== OnClosing Callback ==== -This callback, settabel via the SetOnClosing() function, will be called when the player tries to close the window, or the window is closed for any other reason (such as a player disconnecting). - -function OnWindowClosing(a_Window, a_Player, a_CanRefuse) - -The a_Window parameter is the cLuaWindow object representing the window, a_Player is the player for whom the window is about to close. a_CanRefuse specifies whether the callback can refuse the closing. If the callback returns true and a_CanRefuse is true, the window is not closed (internally, the server sends a new OpenWindow packet to the client). -==== OnSlotChanged Callback ==== -This callback, settable via the SetOnSlotChanged() function, will be called whenever the contents of any slot in the window's contents (i. e. NOT in the player inventory!) changes. - -function OnWindowSlotChanged(a_Window, a_SlotNum) - -The a_Window parameter is the cLuaWindow object representing the window, a_SlotNum is the slot number. There is no reference to a {{cWorld|cWorld}}:DoWithPlayer(). -

    -

    Any returned values are ignored. ]], Functions = { @@ -960,7 +934,69 @@ The a_Window parameter is the cLuaWindow object representing the window, a_SlotN Constants = { }, - }, + AdditionalInfo = + { + { + Header = "Callbacks", + Contents = [[ + The object calls the following functions at the appropriate time: + ]], + }, + { + Header = "OnClosing Callback", + Contents = [[ + This callback, settable via the SetOnClosing() function, will be called when the player tries to close the window, or the window is closed for any other reason (such as a player disconnecting).

    +
    +function OnWindowClosing(a_Window, a_Player, a_CanRefuse)
    +
    +

    + The a_Window parameter is the cLuaWindow object representing the window, a_Player is the player for whom the window is about to close. a_CanRefuse specifies whether the callback can refuse the closing. If the callback returns true and a_CanRefuse is true, the window is not closed (internally, the server sends a new OpenWindow packet to the client). + ]], + }, + { + Header = "OnSlotChanged Callback", + Contents = [[ + This callback, settable via the SetOnSlotChanged() function, will be called whenever the contents of any slot in the window's contents (i. e. NOT in the player inventory!) changes.

    +
    +function OnWindowSlotChanged(a_Window, a_SlotNum)
    +
    +

    The a_Window parameter is the cLuaWindow object representing the window, a_SlotNum is the slot number. There is no reference to a {{cPlayer}}, because the slot change needn't originate from the player action. To get or set the slot, you'll need to retrieve a cPlayer object, for example by calling {{cWorld|cWorld}}:DoWithPlayer(). +

    +

    Any returned values are ignored. + ]], + }, + { + Header = "Example", + Contents = [[ + This example is taken from the Debuggers plugin, used to test the API functionality. It opens a window and refuse to close it 3 times. It also logs slot changes to the server console. +

    +-- Callback that refuses to close the window twice, then allows:
    +local Attempt = 1;
    +local OnClosing = function(Window, Player, CanRefuse)
    +	Player:SendMessage("Window closing attempt #" .. Attempt .. "; CanRefuse = " .. tostring(CanRefuse));
    +	Attempt = Attempt + 1;
    +	return CanRefuse and (Attempt <= 3);  -- refuse twice, then allow, unless CanRefuse is set to true
    +end
    +
    +-- Log the slot changes:
    +local OnSlotChanged = function(Window, SlotNum)
    +	LOG("Window \"" .. Window:GetWindowTitle() .. "\" slot " .. SlotNum .. " changed.");
    +end
    +
    +-- Set window contents:
    +-- a_Player is a cPlayer object received from the outside of this code fragment
    +local Window = cLuaWindow(cWindow.Hopper, 3, 3, "TestWnd");
    +Window:SetSlot(a_Player, 0, cItem(E_ITEM_DIAMOND, 64));
    +Window:SetOnClosing(OnClosing);
    +Window:SetOnSlotChanged(OnSlotChanged);
    +
    +-- Open the window:
    +a_Player:OpenWindow(Window);
    +
    + ]], + }, + }, -- AdditionalInfo + }, -- cLuaWindow cMCLogger = { @@ -1363,22 +1399,6 @@ unsigned int cChunk::MakeIndex(int x, int y, int z ) }, }, - Documented = - { - Desc = [[

    -

    A plugin is a script written in Lua that can modify the game in multiple ways. -A list of items regarding plugins that have been documented -

    -

    {{indexmenu>:api:plugin#1}} -]], - Functions = - { - }, - Constants = - { - }, - }, - TakeDamageInfo = { Desc = [[The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the {{OnTakeDamage|OnTakeDamage}}() hook and in the {{cEntity|cEntity}}'s TakeDamage() function. @@ -1391,24 +1411,6 @@ A list of items regarding plugins that have been documented }, }, - Vector3 = - { - Desc = [[Vector3 is a family of classes that all represent a point in space -

  • {{vector3f|vector3f}}
  • -
  • Uses floating point values
  • -
  • {{vector3d|vector3d}}
  • -
  • Uses double precision floating point values
  • -
  • {{vector3i|vector3i}}
  • -
  • Uses fixed point (integer) values
  • -]], - Functions = - { - }, - Constants = - { - }, - }, - Vector3d = { Desc = [[A Vector3d object uses double precision floating point values to describe a point in space. Vector3d is part of the {{vector3|vector3}} family. -- cgit v1.2.3 From c3ad5bbf91a2b47e5f2944a9751f4cfc02381a02 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 23:21:10 +0200 Subject: APIDump: Fixed dumping when APIDesc doesn't contain Constants section. --- MCServer/Plugins/APIDump/main.lua | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 280e3034c..7a7cc84c2 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -265,16 +265,20 @@ function DumpAPIHtml() -- The whole class is not exported f:write("class\t" .. clsname .. "\n"); else - for fnname, fnapi in pairs(cls.Functions) do - if not(fnapi.IsExported) then - f:write("func\t" .. clsname .. "." .. fnname .. "\n"); - end - end -- for j, fn - cls.Functions[] - for cnname, cnapi in pairs(cls.Constants) do - if not(cnapi.IsExported) then - f:write("const\t" .. clsname .. "." .. cnname .. "\n"); - end - end -- for j, fn - cls.Functions[] + if (cls.Functions ~= nil) then + for fnname, fnapi in pairs(cls.Functions) do + if not(fnapi.IsExported) then + f:write("func\t" .. clsname .. "." .. fnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end + if (cls.Constants ~= nil) then + for cnname, cnapi in pairs(cls.Constants) do + if not(cnapi.IsExported) then + f:write("const\t" .. clsname .. "." .. cnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end end end -- for i, cls - g_APIDesc.Classes[] f:close(); -- cgit v1.2.3 From 2c7e7f24be5adb63def195352723e54fd9d783d7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 23:24:13 +0200 Subject: APIDump: Removed most unexported-documented classes. Also fixed most functions that were erroneously parsed as constants by the automatic wiki import. --- MCServer/Plugins/APIDump/APIDesc.lua | 285 +++++++---------------------------- 1 file changed, 53 insertions(+), 232 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f006f89b4..458555c43 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -473,19 +473,22 @@ g_APIDesc = cCuboid = { - Desc = [[cCuboid offers some native support for cuboids. A cuboid simply consists of two {{vector3i|vector3i}}'s. It offers some extra functions for sorting and checking if a point is inside the cuboid. -]], + Desc = [[ + cCuboid offers some native support for integral-boundary cuboids. A cuboid simply consists of two + {{vector3i}}-s. It offers some extra functions for sorting and checking if a point is inside the + cuboid. + ]], Functions = { - }, - Constants = - { - p = { Notes = "{{Vector3i|Vector3i}}" }, - p = { Notes = "{{Vector3i|Vector3i}}" }, Sort = { Notes = "void" }, IsInside = { Notes = "bool" }, IsInside = { Notes = "bool" }, }, + Variables = + { + p1 = { Notes = "{{Vector3i}} of one corner. Usually the lesser of the two coords in each set" }, + p2 = { Notes = "{{Vector3i}} of the other corner. Usually the larger of the two coords in each set" }, + }, }, cDispenserEntity = @@ -501,6 +504,7 @@ g_APIDesc = Constants = { }, + Inherits = "cDropSpenserEntity", }, cDropperEntity = @@ -516,9 +520,10 @@ g_APIDesc = Constants = { }, + Inherits = "cDropSpenserEntity", }, - cDropSpenser = + cDropSpenserEntity = { Desc = [[This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. ]], @@ -533,6 +538,8 @@ g_APIDesc = ContentsWidth = { Notes = "Width (X) of the cItemGrid representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the cItemGrid representing the contents" }, }, + + Inherits = "cBlockEntity"; }, cEnchantments = @@ -657,9 +664,6 @@ g_APIDesc = Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat. ]], Functions = - { - }, - Constants = { SetName = { Notes = "void" }, GetName = { Notes = "String" }, @@ -670,6 +674,9 @@ g_APIDesc = AddPermission = { Notes = "void" }, InheritFrom = { Notes = "void" }, }, + Constants = + { + }, }, cIniFile = @@ -678,10 +685,7 @@ g_APIDesc = ]], Functions = { - }, - Constants = - { - cIniFile = { Notes = "{{cIniFile|cIniFile}}" }, + constructor = { Return = "{{cIniFile|cIniFile}}" }, CaseSensitive = { Notes = "void" }, CaseInsensitive = { Notes = "void" }, Path = { Notes = "void" }, @@ -740,6 +744,9 @@ g_APIDesc = DeleteKeyComments = { Notes = "bool" }, DeleteKeyComments = { Notes = "bool" }, }, + Constants = + { + }, }, cInventory = @@ -807,9 +814,12 @@ These ItemGrids are available in the API and can be manipulated by the plugins, Functions = { - constructor1 = { Params = "", Return = "cItem", Notes = "Creates a new empty cItem obje" }, - constructor2 = { Params = "ItemType, Count, Damage, EnchantmentString", Return = "cItem", Notes = "Creates a new cItem object of the specified type, count (1 by default), damage (0 by default) and enchantments (non-enchanted by default)" }, - constructor3 = { Params = "cItem", Return = "cItem", Notes = "Creates an exact copy of the cItem object in the parameter" }, + constructor = + { + { Params = "", Return = "cItem", Notes = "Creates a new empty cItem obje" }, + { Params = "ItemType, Count, Damage, EnchantmentString", Return = "cItem", Notes = "Creates a new cItem object of the specified type, count (1 by default), damage (0 by default) and enchantments (non-enchanted by default)" }, + { Params = "cItem", Return = "cItem", Notes = "Creates an exact copy of the cItem object in the parameter" }, + } , Clear = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, CopyOne = { Params = "", Return = "cItem", Notes = "Creates a copy of this object, with its count set to 1" }, DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" }, @@ -878,9 +888,13 @@ These ItemGrids are available in the API and can be manipulated by the plugins, }, }, - citems = + cItems = { - Desc = [[]], + Desc = [[ + This class represents a numbered collection (array) of {{cItem}} objects. The array indices start at + zero, each consecutive item gets a consecutive index. This class is used for spawning multiple + pickups or for mass manipulating an inventory. + ]], Functions = { constructor = { Params = "", Return = "cItems", Notes = "Creates a new cItems object" }, @@ -898,20 +912,6 @@ These ItemGrids are available in the API and can be manipulated by the plugins, }, }, - cLadder = - { - Desc = [[cLadder just represents ladders and their specific - rotation. -]], - Functions = - { - }, - Constants = - { - DirectionToMetaData = { Notes = "char" }, - MetaDataToDirection = { Notes = "char" }, - }, - }, - cLuaWindow = { Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set. @@ -998,83 +998,11 @@ a_Player:OpenWindow(Window); }, -- AdditionalInfo }, -- cLuaWindow - cMCLogger = - { - Desc = [[cMCLogger gives you a bit more complex way to log things. -]], - Functions = - { - }, - Constants = - { - LogSimple = { Notes = "void" }, - }, - }, - - cPacket = - { - Desc = [[This packet is received by clients when they are digging blocks -]], - Functions = - { - }, - Constants = - { - m = { Notes = "char" }, - m = { Notes = "int" }, - m = { Notes = "char" }, - m = { Notes = "int" }, - m = { Notes = "char" }, - }, - }, - - cPacket = - { - Desc = [[This packet is received by clients when they are placing blocks -]], - Functions = - { - }, - Constants = - { - m = { Notes = "int" }, - m = { Notes = "char" }, - m = { Notes = "int" }, - m = { Notes = "char" }, - m = { Notes = "short int" }, - m = { Notes = "char" }, - m = { Notes = "short int" }, - }, - }, - - cPacket = - { - Desc = [[This packet is received when a client logs in -]], - Functions = - { - }, - Constants = - { - m = { Notes = "int" }, - m = { Notes = "String" }, - m = { Notes = "String" }, - m = { Notes = "int" }, - m = { Notes = "int" }, - m = { Notes = "char" }, - m = { Notes = "char" }, - m = { Notes = "char" }, - }, - }, - cPawn = { Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}} ]], Functions = - { - }, - Constants = { TeleportToEntity = { Notes = "void" }, TeleportTo = { Notes = "void" }, @@ -1083,6 +1011,10 @@ a_Player:OpenWindow(Window); KilledBy = { Notes = "void" }, GetHealth = { Notes = "int" }, }, + Constants = + { + }, + Inherits = "cEntity", }, cPickup = @@ -1090,14 +1022,15 @@ a_Player:OpenWindow(Window); Desc = [[cPickup is a pickup object representation. It is also commonly known as "drops". With this class you could create your own "drop" or modify automatically created. ]], Functions = - { - }, - Constants = { cPickup = { Notes = "[[cPickup}}" }, GetItem = { Notes = "{{cItem|cItem}}" }, CollectedBy = { Notes = "bool" }, }, + Constants = + { + }, + Inherits = "cEntity", }, cPlayer = @@ -1105,9 +1038,6 @@ a_Player:OpenWindow(Window); Desc = [[cPlayer describes a human player in the server. cPlayer inherits all functions and members of {{cPawn|cPawn}} ]], Functions = - { - }, - Constants = { GetEyeHeight = { Notes = "double" }, GetEyePosition = { Notes = "{{Vector3d|Vector3d}}" }, @@ -1144,6 +1074,10 @@ a_Player:OpenWindow(Window); GetGroups = { Notes = "list<{{cGroup|cGroup}}>" }, GetResolvedPermissions = { Notes = "String" }, }, + Constants = + { + }, + Inherits = "cPawn", }, cPlugin = @@ -1151,9 +1085,6 @@ a_Player:OpenWindow(Window); Desc = [[cPlugin describes a Lua plugin. This page is dedicated to new-style plugins and contain their functions. ]], Functions = - { - }, - Constants = { GetName = { Notes = "String" }, SetName = { Notes = "void" }, @@ -1162,6 +1093,9 @@ a_Player:OpenWindow(Window); GetFileName = { Notes = "String" }, CreateWebPlugin = { Notes = "{{cWebPlugin|cWebPlugin}}" }, }, + Constants = + { + }, }, cPluginManager = @@ -1197,17 +1131,6 @@ a_Player:OpenWindow(Window); }, }, - cplugin_newlua = - { - Desc = [[]], - Functions = - { - }, - Constants = - { - }, - }, - cRoot = { Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} @@ -1232,29 +1155,11 @@ a_Player:OpenWindow(Window); }, }, - Data = + cSignEntity = { - Desc = [[
  • Inherits {{cBlockEntity|cBlockEntity}}
  • + Desc = [[ A sign entity represents a sign in the world. Sign entities are saved and loaded from disk when the chunk they reside in is saved or loaded -

    -

    Here's some raw C++ code showing how sign entities are saved - -void cSignEntity::WriteToFile(FILE* a_File) -{ - fwrite( &m_BlockType, sizeof( ENUM_BLOCK_ID ), 1, a_File ); - fwrite( &m_PosX, sizeof( int ), 1, a_File ); - fwrite( &m_PosY, sizeof( int ), 1, a_File ); - fwrite( &m_PosZ, sizeof( int ), 1, a_File ); -

    -

    for( int i = 0; i < 4; i++ ) - { - short Size = m_Line[i].size(); - fwrite( &Size, sizeof(short), 1, a_File ); - fwrite( m_Line[i].c_str(), Size * sizeof(char), 1, a_File ); - } -} - ]], Functions = { @@ -1262,6 +1167,8 @@ void cSignEntity::WriteToFile(FILE* a_File) Constants = { }, + + Inherits = "cBlockEntity"; }, cStringMap = @@ -1276,18 +1183,6 @@ void cSignEntity::WriteToFile(FILE* a_File) }, }, - cTCPLink = - { - Desc = [[OBSOLETE, Do not use! -]], - Functions = - { - }, - Constants = - { - }, - }, - cTracer = { Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want. @@ -1347,58 +1242,6 @@ void cSignEntity::WriteToFile(FILE* a_File) }, }, - Coordinates = - { - Desc = [[The PAK format is highly compact format that has a slightly better compression ratio and saving / loading times than the {{dataformatanvil | Anvil}} format. -I use this function to convert block coordinates to indices which I use to access the arrays of blocks - -unsigned int cChunk::MakeIndex(int x, int y, int z ) -{ - if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 ) - return y + (z * 128) + (x * 128 * 16); - return 0; -} - -]], - Functions = - { - }, - Constants = - { - }, - }, - - eGameMode = - { - Desc = [[

    -

    {{eGameMode|eGameMode}} is an enum that defines what game mode a player is in. It can be one of these two values. -

    -

    ^ eGameMode ^ -| eGameMode_Survival | -| eGameMode_Creative | -]], - Functions = - { - }, - Constants = - { - }, - }, - - Initialize = - { - Desc = [[The Initialize() function is the main entrypoint to a plugin. Within this function the plugin is expected to register any hook callbacks, commands, read settings, add webadmin tabs etc. MCServer calls this function after all the files in the plugin directory have been read and the global values and commands have been executed by the Lua engine, so all the global variables and functions are accessible. -

    -

    Typically, plugins will also store the Plugin parameter into a global variable so that it is accessible later. -]], - Functions = - { - }, - Constants = - { - }, - }, - TakeDamageInfo = { Desc = [[The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the {{OnTakeDamage|OnTakeDamage}}() hook and in the {{cEntity|cEntity}}'s TakeDamage() function. @@ -1447,28 +1290,6 @@ unsigned int cChunk::MakeIndex(int x, int y, int z ) { }, }, - - Documented = - { - Desc = [[

    -

    WebPlugins provide an interface for the server through a webpage, to be able to use WebPlugins you need to enable WebAdmin in webadmin.ini{{ :api:webadmin.png?200| A WebPlugin in action}} - -[WebAdmin] -Enabled=1 -Port=8080 - -A list of items regarding WebPlugins that have been documented -

    -

    {{indexmenu>:api:webplugin#1}} -]], - Functions = - { - }, - Constants = - { - }, - }, - }, -- cgit v1.2.3 From 7ec598d8d4a8b9d466c32a285029ca6bdbbc6bad Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 23:36:55 +0200 Subject: APIDump: Added most missing classes as empty templates. --- MCServer/Plugins/APIDump/APIDesc.lua | 94 +++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 458555c43..527ed82e7 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -308,6 +308,13 @@ g_APIDesc = { }, }, + + cBoundingBox = + { + Desc = "", + Functions = {}, + Constants = {}, + }, cChatColor = { @@ -631,6 +638,14 @@ g_APIDesc = }, }, + cFireChargeEntity = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cProjectileEntity", + } , + cFurnaceEntity = { Desc = [[This class represents a furnace block entity in the world. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks) @@ -657,8 +672,16 @@ g_APIDesc = ContentsWidth = { Notes = "Width (X) of the {{cItemGrid|cItemGrid}} representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid|cItemGrid}} representing the contents" }, }, + Inherits = "cBlockEntityWithItems" }, + cGhastFireballEntity = + { + Desc = "", + Functions = {}, + Constants = {}, + } , + cGroup = { Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat. @@ -912,6 +935,13 @@ These ItemGrids are available in the API and can be manipulated by the plugins, }, }, + cLineBlockTracer = + { + Desc = "", + Functions = {}, + Constants = {}, + }, + cLuaWindow = { Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set. @@ -998,6 +1028,14 @@ a_Player:OpenWindow(Window); }, -- AdditionalInfo }, -- cLuaWindow + cMonster = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cPawn", + }, + cPawn = { Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}} @@ -1098,6 +1136,14 @@ a_Player:OpenWindow(Window); }, }, + cPluginLua = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cPlugin", + }, + cPluginManager = { Desc = [[This class is used for generic plugin-related functionality. The plugin manager has a list of all plugins, can enable or disable plugins, manages hook and in-game console commands. @@ -1131,6 +1177,14 @@ a_Player:OpenWindow(Window); }, }, + cProjectileEntity = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cEntity", + }, + cRoot = { Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} @@ -1182,7 +1236,31 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa { }, }, - + + cThrownEggEntity = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cProjectileEntity", + }, + + cThrownEnderPearlEntity = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cProjectileEntity", + }, + + cThrownSnowballEntity = + { + Desc = "", + Functions = {}, + Constants = {}, + Inherits = "cProjectileEntity", + }, + cTracer = { Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want. @@ -1197,6 +1275,20 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa }, }, + cWebAdmin = + { + Desc = "", + Functions = {}, + Constants = {}, + }, + + cWebPlugin = + { + Desc = "", + Functions = {}, + Constants = {}, + }, + cWindow = { Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window. -- cgit v1.2.3 From b8a37c4f46216c4a92ad8c23ed73da96c2a1b722 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 14 Sep 2013 23:47:37 +0200 Subject: APIDump: Undescribed classes are listed as undocumented. Previously class that was not listed in APIDesc was not listed in Undocumented. --- MCServer/Plugins/APIDump/main.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 7a7cc84c2..212cd54ed 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -222,7 +222,6 @@ function DumpAPIHtml() f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); for i, cls in ipairs(API) do - local HasWrittenClassHeader = false; local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); if (HasFunctions or HasConstants) then @@ -318,8 +317,6 @@ function ReadDescriptions(a_API) return false; end - local UnexportedDocumented = {}; -- List of API objects that are documented but not exported, simply a list of names - for i, cls in ipairs(a_API) do -- Rename special functions: for j, fn in ipairs(cls.Functions) do @@ -394,11 +391,6 @@ function ReadDescriptions(a_API) -- Replace functions with their described and overload-expanded versions: cls.Functions = DoxyFunctions; - - -- Add all non-exported function descriptions to UnexportedDocumented: - for j, func in pairs(APIDesc.Functions) do - -- TODO - end end -- if (APIDesc.Functions ~= nil) if (APIDesc.Constants ~= nil) then @@ -415,13 +407,23 @@ function ReadDescriptions(a_API) CnDesc.IsExported = true; end end -- for j, cons - - -- Add all non-exported constant descriptions to UnexportedDocumented: - for j, cons in pairs(APIDesc.Constants) do - -- TODO - end end -- if (APIDesc.Constants ~= nil) - end -- if (APIDesc ~= nil) + else + -- Class is not documented at all, add all its members to Undocumented lists: + cls.UndocumentedFunctions = {}; + cls.UndocumentedConstants = {}; + for j, func in ipairs(cls.Functions) do + local FnName = func.DocID or func.Name; + if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + table.insert(cls.UndocumentedFunctions, FnName); + end + end -- for j, func - cls.Functions[] + for j, cons in ipairs(cls.Constants) do + if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then + table.insert(cls.UndocumentedConstants, cons.Name); + end + end -- for j, cons - cls.Constants[] + end -- else if (APIDesc ~= nil) -- Remove ignored functions: local NewFunctions = {}; -- cgit v1.2.3 From 518e61e75124d174552c11747e940366d5f14fbb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 15 Sep 2013 20:29:42 +0200 Subject: APIDump: Fixed linkification with multiple links in one string. --- MCServer/Plugins/APIDump/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 212cd54ed..73acd3e69 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -478,8 +478,8 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Make a link out of anything with the special linkifying syntax {{link|title}} local function LinkifyString(a_String) - local txt = a_String:gsub("{{([^|]*)|([^}]*)}}", "%2") -- {{link|title}} - txt = txt:gsub("{{([^|]*)}}", "%1") -- {{LinkAndTitle}} + local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", "%2") -- {{link|title}} + txt = txt:gsub("{{([^|}]*)}}", "%1") -- {{LinkAndTitle}} return txt; end -- cgit v1.2.3 From f0ab45f65c57ef6f2523fd678ea830f629324073 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 15 Sep 2013 20:31:46 +0200 Subject: APIDump: Added a first part of cWorld documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 120 ++++++++++++++++++++++++++++++++++- 1 file changed, 118 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 527ed82e7..53ec87572 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1324,10 +1324,126 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa cWorld = { - Desc = [[cWorld is the game world, at the moment there can only be one world. The world manages all {{cChunk | Chunks}}, {{cPlayer | Players}} and the time. -]], + Desc = [[ + cWorld is the game world. It is the hub of all the information managed by individual classes, + providing convenient access to them. MCServer supports multiple worlds in any combination of + world types. You can have two overworlds, three nethers etc. To enumerate all world the server + provides, use the {{cRoot}}:ForEachWorld() function.

    +

    + The world data is held in individual chunks. Each chunk consists of 16 (x) * 16 (z) * 256 (y) + blocks, each block is specified by its block type (8-bit) and block metadata (4-bit). + Additionally, each block has two light values calculated - skylight (how much daylight it receives) + and blocklight (how much light from light-emissive blocks it receives), both 4-bit.

    +

    + Each world runs several separate threads used for various housekeeping purposes, the most important + of those is the Tick thread. This thread updates the game logic 20 times per second, and it is + the thread where all the gameplay actions are evaluated. Liquid physics, entity interactions, + player ovement etc., all are applied in this thread.

    +

    + Additional threads include the generation thread (generates new chunks as needed, storage thread + (saves and loads chunk from the disk), lighting thread (updates block light values) and the + chunksender thread (compresses chunks to send to the clients).

    +

    + The world provides access to all its {{cPlayer|players}}, {{cEntity|entities}} and {{cBlockEntity|block + entities}}. Because of multithreading issues, individual objects cannot be retrieved for indefinite + handling, but rather must be modified in callbacks, within which they are guaranteed to stay valid.

    +

    + Physics for individual blocks are handled by the simulators. These will fire in each tick for all + blocks that have been scheduled for simulator update ("simulator wakeup"). The simulators include + liquid physics, falling blocks, fire spreading and extinguishing and redstone.

    +

    + Game time is also handled by the world. It provides the time-of-day and the total world age. + ]], + Functions = { + BroadcastChat = { Params = "Message, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the Message to all players in this world, except the optional ExceptClient" }, + BroadcastSoundEffect = { Params = "SoundName, X, Y, Z, Volume, Pitch, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the specified sound effect to all players in this world, except the optional ExceptClient" }, + BroadcastSoundParticleEffect = { Params = "EffectID, X, Y, Z, EffectData, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the specified effect to all players in this world, except the optional ExceptClient" }, + CastThunderbolt = { Params = "X, Y, Z", Return = "", Notes = "Creates a thunderbolt at the specified coords" }, + ChangeWeather = { Params = "", Return = "", Notes = "Forces the weather to change in the next game tick. Weather is changed according to the normal rules: wSunny <-> wRain <-> wStorm" }, + CreateProjectile = { Params = "X, Y, Z, {{cProjectile|ProjectileKind}}, {{cEntity|Creator}}, [{{Vector3d|Speed}}]", Return = "", Notes = "Creates a new projectile of the specified kind at the specified coords. The projectile's creator is set to Creator (may be nil). Optional speed indicates the initial speed for the projectile." }, + DigBlock = { Params = "X, Y, Z", Return = "", Notes = "Replaces the specified block with air, without dropping the usual pickups for the block. Wakes up the simulators for the block and its neighbors." }, + DoExplosionAt = { Params = "Force, X, Y, Z, CanCauseFire, Source, SourceData", Return = "", Notes = "Creates an explosion of the specified relative force in the specified position. If CanCauseFire is set, the explosion will set blocks on fire, too. The Source parameter specifies the source of the explosion, one of the esXXX constants. The SourceData parameter is specific to each source type, usually it provides more info about the source." }, + DoWithChestAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a chest at the specified coords, calls the CallbackFunction with the {{cChestEntity}} parameter representing the chest. The CallbackFunction has the following signature:

    function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
    The function returns false if there is no chest, or if there is, it returns the bool value that the callback has returned." }, + DoWithDispenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dispenser at the specified coords, calls the CallbackFunction with the {{cDispenserEntity}} parameter representing the dispenser. The CallbackFunction has the following signature:
    function Callback({{cDispenserEntity|DispenserEntity}}, [CallbackData])
    The function returns false if there is no dispenser, or if there is, it returns the bool value that the callback has returned." }, + DoWithDropSpenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper or a dispenser at the specified coords, calls the CallbackFunction with the {{cDropSpenserEntity}} parameter representing the dropper or dispenser. The CallbackFunction has the following signature:
    function Callback({{cDropSpenserEntity|DropSpenserEntity}}, [CallbackData])
    Note that this can be used to access both dispensers and droppers in a similar way. The function returns false if there is neither dispenser nor dropper, or if there is, it returns the bool value that the callback has returned." }, + DoWithDropperAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper at the specified coords, calls the CallbackFunction with the {{cDropperEntity}} parameter representing the dropper. The CallbackFunction has the following signature:
    function Callback({{cDropperEntity|DropperEntity}}, [CallbackData])
    The function returns false if there is no dropper, or if there is, it returns the bool value that the callback has returned." }, + DoWithEntityByID = { Params = "EntityID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If an entity with the specified ID exists, calls the callback with the {{cEntity}} parameter representing the entity. The CallbackFunction has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The function returns false if the entity was not found, and it returns the same bool value that the callback has returned if the entity was found." }, + DoWithFurnaceAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a furnace at the specified coords, calls the CallbackFunction with the {{cFurnaceEntity}} parameter representing the furnace. The CallbackFunction has the following signature:
    function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
    The function returns false if there is no furnace, or if there is, it returns the bool value that the callback has returned." }, + DoWithPlayer = { Params = "PlayerName, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of the specified name (exact match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." }, + FastSetBlock = { Params = "X, Y, Z, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, + FindAndDoWithPlayer = { Params = "PlayerNameHint, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of a name similar to the specified name (weighted-match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The function returns false if the player was not found, or whatever bool value the callback returned if the player was found. Note that the name matching is very loose, so it is a good idea to check the player name in the callback function." }, + ForEachChestInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
    function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
    The callback should return false or no value to continue with the next chest, or true to abort the enumeration." }, + ForEachEntity = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, + ForEachEntityInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the specified chunk. Returns true if all the entities have been processed (including when there are zero entities), or false if the chunk is not loaded or the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, + ForEachFurnaceInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each furnace in the chunk. Returns true if all furnaces in the chunk have been processed (including when there are zero furnaces), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
    function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
    The callback should return false or no value to continue with the next furnace, or true to abort the enumeration." }, + ForEachPlayer = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each player in the loaded world. Returns true if all the players have been processed (including when there are zero players), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The callback should return false or no value to continue with the next player, or true to abort the enumeration." }, + GenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk in the chunk generator. Ignored if the chunk is already generated (use RegenerateChunk() to force chunk re-generation)." }, + GetBiomeAt = { Params = "BlockX, BlockZ", Return = "eBiome", Notes = "Returns the biome at the specified coords. Reads the biome from the chunk, if it is loaded, otherwise it uses the chunk generator to provide the biome value." }, + GetBlock = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + GetBlockBlockLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the amount of block light at the specified coords, or 0 if the appropriate chunk is not loaded." }, + GetBlockInfo = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta, BlockSkyLight, BlockBlockLight", Notes = "Returns the complete block info for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, + GetBlockMeta = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta", Notes = "Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, + GetClassStatic = { Params = "", Return = "", Notes = "" }, + GetDimension = { Params = "", Return = "", Notes = "" }, + GetGameMode = { Params = "", Return = "", Notes = "" }, + GetGeneratorQueueLength = { Params = "", Return = "", Notes = "" }, + GetHeight = { Params = "", Return = "", Notes = "" }, + GetIniFileName = { Params = "", Return = "", Notes = "" }, + GetLightingQueueLength = { Params = "", Return = "", Notes = "" }, + GetMaxCactusHeight = { Params = "", Return = "", Notes = "" }, + GetMaxSugarcaneHeight = { Params = "", Return = "", Notes = "" }, + GetName = { Params = "", Return = "", Notes = "" }, + GetNumChunks = { Params = "", Return = "", Notes = "" }, + GetSignLines = { Params = "", Return = "", Notes = "" }, + GetSpawnX = { Params = "", Return = "", Notes = "" }, + GetSpawnY = { Params = "", Return = "", Notes = "" }, + GetSpawnZ = { Params = "", Return = "", Notes = "" }, + GetStorageLoadQueueLength = { Params = "", Return = "", Notes = "" }, + GetStorageSaveQueueLength = { Params = "", Return = "", Notes = "" }, + GetTicksUntilWeatherChange = { Params = "", Return = "", Notes = "" }, + GetTime = { Params = "", Return = "", Notes = "" }, + GetTimeOfDay = { Params = "", Return = "", Notes = "" }, + GetWeather = { Params = "", Return = "", Notes = "" }, + GetWorldAge = { Params = "", Return = "", Notes = "" }, + GrowCactus = { Params = "", Return = "", Notes = "" }, + GrowMelonPumpkin = { Params = "", Return = "", Notes = "" }, + GrowRipePlant = { Params = "", Return = "", Notes = "" }, + GrowSugarcane = { Params = "", Return = "", Notes = "" }, + GrowTree = { Params = "", Return = "", Notes = "" }, + GrowTreeByBiome = { Params = "", Return = "", Notes = "" }, + GrowTreeFromSapling = { Params = "", Return = "", Notes = "" }, + IsBlockDirectlyWatered = { Params = "", Return = "", Notes = "" }, + IsDeepSnowEnabled = { Params = "", Return = "", Notes = "" }, + IsGameModeAdventure = { Params = "", Return = "", Notes = "" }, + IsGameModeCreative = { Params = "", Return = "", Notes = "" }, + IsGameModeSurvival = { Params = "", Return = "", Notes = "" }, + IsPVPEnabled = { Params = "", Return = "", Notes = "" }, + QueueBlockForTick = { Params = "", Return = "", Notes = "" }, + QueueSaveAllChunks = { Params = "", Return = "", Notes = "" }, + QueueSetBlock = { Params = "", Return = "", Notes = "" }, + RegenerateChunk = { Params = "", Return = "", Notes = "" }, + SaveAllChunks = { Params = "", Return = "", Notes = "" }, + SendBlockTo = { Params = "", Return = "", Notes = "" }, + SetBlock = { Params = "", Return = "", Notes = "" }, + SetBlockMeta = { Params = "", Return = "", Notes = "" }, + SetNextBlockTick = { Params = "", Return = "", Notes = "" }, + SetSignLines = { Params = "", Return = "", Notes = "" }, + SetTicksUntilWeatherChange = { Params = "", Return = "", Notes = "" }, + SetTimeOfDay = { Params = "", Return = "", Notes = "" }, + SetWeather = { Params = "", Return = "", Notes = "" }, + SetWorldTime = { Params = "", Return = "", Notes = "" }, + SpawnItemPickups = { Params = "", Return = "", Notes = "" }, + SpawnMob = { Params = "", Return = "", Notes = "" }, + SpawnPrimedTNT = { Params = "", Return = "", Notes = "" }, + TryGetHeight = { Params = "", Return = "", Notes = "" }, + UnloadUnusedChunks = { Params = "", Return = "", Notes = "" }, + UpdateSign = { Params = "", Return = "", Notes = "" }, + WakeUpSimulators = { Params = "", Return = "", Notes = "" }, + WakeUpSimulatorsInArea = { Params = "", Return = "", Notes = "" }, }, Constants = { -- cgit v1.2.3 From 7ecd728f1e126903bc9f7b71d554998aa2e2fc84 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 15 Sep 2013 22:30:17 +0200 Subject: APIDump: Next batch of cWorld documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 69 ++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 53ec87572..7a62b1554 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1387,41 +1387,40 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa GetBlockMeta = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta", Notes = "Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, - GetClassStatic = { Params = "", Return = "", Notes = "" }, - GetDimension = { Params = "", Return = "", Notes = "" }, - GetGameMode = { Params = "", Return = "", Notes = "" }, - GetGeneratorQueueLength = { Params = "", Return = "", Notes = "" }, - GetHeight = { Params = "", Return = "", Notes = "" }, - GetIniFileName = { Params = "", Return = "", Notes = "" }, - GetLightingQueueLength = { Params = "", Return = "", Notes = "" }, - GetMaxCactusHeight = { Params = "", Return = "", Notes = "" }, - GetMaxSugarcaneHeight = { Params = "", Return = "", Notes = "" }, - GetName = { Params = "", Return = "", Notes = "" }, - GetNumChunks = { Params = "", Return = "", Notes = "" }, - GetSignLines = { Params = "", Return = "", Notes = "" }, - GetSpawnX = { Params = "", Return = "", Notes = "" }, - GetSpawnY = { Params = "", Return = "", Notes = "" }, - GetSpawnZ = { Params = "", Return = "", Notes = "" }, - GetStorageLoadQueueLength = { Params = "", Return = "", Notes = "" }, - GetStorageSaveQueueLength = { Params = "", Return = "", Notes = "" }, - GetTicksUntilWeatherChange = { Params = "", Return = "", Notes = "" }, - GetTime = { Params = "", Return = "", Notes = "" }, - GetTimeOfDay = { Params = "", Return = "", Notes = "" }, - GetWeather = { Params = "", Return = "", Notes = "" }, - GetWorldAge = { Params = "", Return = "", Notes = "" }, - GrowCactus = { Params = "", Return = "", Notes = "" }, - GrowMelonPumpkin = { Params = "", Return = "", Notes = "" }, - GrowRipePlant = { Params = "", Return = "", Notes = "" }, - GrowSugarcane = { Params = "", Return = "", Notes = "" }, - GrowTree = { Params = "", Return = "", Notes = "" }, - GrowTreeByBiome = { Params = "", Return = "", Notes = "" }, - GrowTreeFromSapling = { Params = "", Return = "", Notes = "" }, - IsBlockDirectlyWatered = { Params = "", Return = "", Notes = "" }, - IsDeepSnowEnabled = { Params = "", Return = "", Notes = "" }, - IsGameModeAdventure = { Params = "", Return = "", Notes = "" }, - IsGameModeCreative = { Params = "", Return = "", Notes = "" }, - IsGameModeSurvival = { Params = "", Return = "", Notes = "" }, - IsPVPEnabled = { Params = "", Return = "", Notes = "" }, + GetClassStatic = { Params = "", Return = "string", Notes = "Returns the name of the class, \"cWorld\"." }, + GetDimension = { Params = "", Return = "eDimension", Notes = "Returns the dimension of the world - dimOverworld, dimNether or dimEnd." }, + GetGameMode = { Params = "", Return = "eGameMode", Notes = "Returns the gamemode of the world - gmSurvival, gmCreative or gmAdventure." }, + GetGeneratorQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks that are queued in the chunk generator." }, + GetHeight = { Params = "BlockX, BlockZ", Return = "number", Notes = "Returns the maximum height of the particula block column in the world. If the chunk is not loaded, it waits for it to load / generate. WARNING: Do not use, Use TryGetHeight() instead for a non-waiting version, otherwise you run the risk of a deadlock!" }, + GetIniFileName = { Params = "", Return = "string", Notes = "Returns the name of the world.ini file that the world uses to store the information." }, + GetLightingQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks in the lighting thread's queue." }, + GetMaxCactusHeight = { Params = "", Return = "number", Notes = "Returns the configured maximum height to which cacti will grow naturally." }, + GetMaxSugarcaneHeight = { Params = "", Return = "number", Notes = "Returns the configured maximum height to which sugarcane will grow naturally." }, + GetName = { Params = "", Return = "string", Notes = "Returns the name of the world, as specified in the settings.ini file." }, + GetNumChunks = { Params = "", Return = "number", Notes = "Returns the number of chunks currently loaded." }, + GetSignLines = { Params = "BlockX, BlockY, BlockZ", Return = "IsValid, [Line1, Line2, Line3, Line4]", Notes = "Returns true and the lines of a sign at the specified coords, or false if there is no sign at the coords." }, + GetSpawnX = { Params = "", Return = "number", Notes = "Returns the X coord of the default spawn" }, + GetSpawnY = { Params = "", Return = "number", Notes = "Returns the Y coord of the default spawn" }, + GetSpawnZ = { Params = "", Return = "number", Notes = "Returns the Z coord of the default spawn" }, + GetStorageLoadQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks queued up for loading" }, + GetStorageSaveQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks queued up for saving" }, + GetTicksUntilWeatherChange = { Params = "", Return = "number", Notes = "Returns the number of ticks that will pass before the weather is changed" }, + GetTimeOfDay = { Params = "", Return = "number", Notes = "Returns the number of ticks that have passed from the sunrise, 0 .. 24000." }, + GetWeather = { Params = "", Return = "eWeather", Notes = "Returns the current weather in the world (wSunny, wRain, wStorm)." }, + GetWorldAge = { Params = "", Return = "number", Notes = "Returns the total age of the world, in ticks. The age always grows, cannot be set by plugins and is unrelated to TimeOfDay." }, + GrowCactus = { Params = "BlockX, BlockY, BlockZ, NumBlocksToGrow", Return = "", Notes = "Grows a cactus block at the specified coords, by up to the specified number of blocks. Adheres to the world's maximum cactus growth (GetMaxCactusHeight())." }, + GrowMelonPumpkin = { Params = "BlockX, BlockY, BlockZ, StemType", Return = "", Notes = "Grows a melon or pumpkin, based on the stem type specified (assumed to be in the coords provided). Checks for normal melon / pumpkin growth conditions - stem not having another produce next to it and suitable ground below." }, + GrowRipePlant = { Params = "BlockX, BlockY, BlockZ, IsByBonemeal", Return = "bool", Notes = "Grows the plant at the specified coords. If IsByBonemeal is true, checks first if the specified plant type is bonemealable in the settings. Returns true if the plant was grown, false if not." }, + GrowSugarcane = { Params = "BlockX, BlockY, BlockZ, NumBlocksToGrow", Return = "", Notes = "Grows a sugarcane block at the specified coords, by up to the specified number of blocks. Adheres to the world's maximum sugarcane growth (GetMaxSugarcaneHeight())." }, + GrowTree = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Grows a tree based at the specified coords. If there is a sapling there, grows the tree based on that sapling, otherwise chooses a tree image based on the biome." }, + GrowTreeByBiome = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Grows a tree based at the specified coords. The tree type is picked from types available for the biome at those coords." }, + GrowTreeFromSapling = { Params = "BlockX, BlockY, BlockZ, SaplingMeta", Return = "", Notes = "Grows a tree based at the specified coords. The tree type is determined from the sapling meta (the sapling itself needn't be present)." }, + IsBlockDirectlyWatered = { Params = "BlockX, BlockY, BlockZ", Return = "bool", Notes = "Returns true if the specified block has a water block right next to it (on the X/Z axes)" }, + IsDeepSnowEnabled = { Params = "", Return = "bool", Notes = "Returns whether the configuration has DeepSnow enabled." }, + IsGameModeAdventure = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmAdventure." }, + IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmCreative." }, + IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmSurvival." }, + IsPVPEnabled = { Params = "", Return = "bool", Notes = "Returns whether PVP is enabled in the world settings." }, QueueBlockForTick = { Params = "", Return = "", Notes = "" }, QueueSaveAllChunks = { Params = "", Return = "", Notes = "" }, QueueSetBlock = { Params = "", Return = "", Notes = "" }, -- cgit v1.2.3 From 8aacae5e371912353855d5a13ccdf2af346dab07 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Sep 2013 10:16:04 +0200 Subject: APIDump: All cWorld functions are documented. --- MCServer/Plugins/APIDump/APIDesc.lua | 69 +++++++++++++++++++++++------------- 1 file changed, 44 insertions(+), 25 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7a62b1554..a71a35099 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1372,7 +1372,11 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa DoWithEntityByID = { Params = "EntityID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If an entity with the specified ID exists, calls the callback with the {{cEntity}} parameter representing the entity. The CallbackFunction has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The function returns false if the entity was not found, and it returns the same bool value that the callback has returned if the entity was found." }, DoWithFurnaceAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a furnace at the specified coords, calls the CallbackFunction with the {{cFurnaceEntity}} parameter representing the furnace. The CallbackFunction has the following signature:
    function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
    The function returns false if there is no furnace, or if there is, it returns the bool value that the callback has returned." }, DoWithPlayer = { Params = "PlayerName, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of the specified name (exact match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." }, - FastSetBlock = { Params = "X, Y, Z, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, + FastSetBlock = + { + { Params = "X, Y, Z, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, + { Params = "{{Vector3i|BlockCoords}}, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, + }, FindAndDoWithPlayer = { Params = "PlayerNameHint, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of a name similar to the specified name (weighted-match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The function returns false if the player was not found, or whatever bool value the callback returned if the player was found. Note that the name matching is very loose, so it is a good idea to check the player name in the callback function." }, ForEachChestInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
    function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
    The callback should return false or no value to continue with the next chest, or true to abort the enumeration." }, ForEachEntity = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, @@ -1381,10 +1385,18 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa ForEachPlayer = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each player in the loaded world. Returns true if all the players have been processed (including when there are zero players), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The callback should return false or no value to continue with the next player, or true to abort the enumeration." }, GenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk in the chunk generator. Ignored if the chunk is already generated (use RegenerateChunk() to force chunk re-generation)." }, GetBiomeAt = { Params = "BlockX, BlockZ", Return = "eBiome", Notes = "Returns the biome at the specified coords. Reads the biome from the chunk, if it is loaded, otherwise it uses the chunk generator to provide the biome value." }, - GetBlock = { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + GetBlock = + { + { Params = "BlockX, BlockY, BlockZ", Return = "BLOCKTYPE", Notes = "Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + { Params = "{{Vector3i|BlockCoords}}", Return = "BLOCKTYPE", Notes = "Returns the block type of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + }, GetBlockBlockLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the amount of block light at the specified coords, or 0 if the appropriate chunk is not loaded." }, GetBlockInfo = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta, BlockSkyLight, BlockBlockLight", Notes = "Returns the complete block info for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, - GetBlockMeta = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + GetBlockMeta = + { + { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + { Params = "{{Vector3i|BlockCoords}}", Return = "number", Notes = "Returns the block metadata of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, + }, GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta", Notes = "Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, GetClassStatic = { Params = "", Return = "string", Notes = "Returns the name of the class, \"cWorld\"." }, @@ -1421,28 +1433,35 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmCreative." }, IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmSurvival." }, IsPVPEnabled = { Params = "", Return = "bool", Notes = "Returns whether PVP is enabled in the world settings." }, - QueueBlockForTick = { Params = "", Return = "", Notes = "" }, - QueueSaveAllChunks = { Params = "", Return = "", Notes = "" }, - QueueSetBlock = { Params = "", Return = "", Notes = "" }, - RegenerateChunk = { Params = "", Return = "", Notes = "" }, - SaveAllChunks = { Params = "", Return = "", Notes = "" }, - SendBlockTo = { Params = "", Return = "", Notes = "" }, - SetBlock = { Params = "", Return = "", Notes = "" }, - SetBlockMeta = { Params = "", Return = "", Notes = "" }, - SetNextBlockTick = { Params = "", Return = "", Notes = "" }, - SetSignLines = { Params = "", Return = "", Notes = "" }, - SetTicksUntilWeatherChange = { Params = "", Return = "", Notes = "" }, - SetTimeOfDay = { Params = "", Return = "", Notes = "" }, - SetWeather = { Params = "", Return = "", Notes = "" }, - SetWorldTime = { Params = "", Return = "", Notes = "" }, - SpawnItemPickups = { Params = "", Return = "", Notes = "" }, - SpawnMob = { Params = "", Return = "", Notes = "" }, - SpawnPrimedTNT = { Params = "", Return = "", Notes = "" }, - TryGetHeight = { Params = "", Return = "", Notes = "" }, - UnloadUnusedChunks = { Params = "", Return = "", Notes = "" }, - UpdateSign = { Params = "", Return = "", Notes = "" }, - WakeUpSimulators = { Params = "", Return = "", Notes = "" }, - WakeUpSimulatorsInArea = { Params = "", Return = "", Notes = "" }, + QueueBlockForTick = { Params = "BlockX, BlockY, BlockZ, TicksToWait", Return = "", Notes = "Queues the specified block to be ticked after the specified number of gameticks." }, + QueueSaveAllChunks = { Params = "", Return = "", Notes = "Queues all chunks to be saved in the world storage thread" }, + QueueSetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta, TickDelay", Return = "", Notes = "Queues the block to be set to the specified blocktype and meta after the specified amount of game ticks. Uses SetBlock() for the actual setting, so simulators are woken up and block entities are handled correctly." }, + RegenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk to be re-generated, overwriting the current data. To queue a chunk for generating only if it doesn't exist, use the GenerateChunk() instead." }, + SendBlockTo = { Params = "BlockX, BlockY, BlockZ, {{cPlayer|Player}}", Return = "", Notes = "Sends the block at the specified coords to the specified player's client, as an UpdateBlock packet." }, + SetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, replaces the block entities for the previous block type, creates a new block entity for the new block, if appropriate, and wakes up the simulators. This is the preferred way to set blocks, as opposed to FastSetBlock(), which is only to be used under special circumstances." }, + SetBlockMeta = + { + { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." }, + { Params = "{{Vector3i|BlockCoords}}, BlockMeta", Return = "", Notes = "Sets the meta for the block at the specified coords." }, + }, + SetNextBlockTick = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Sets the blockticking to start at the specified block in the next tick." }, + SetSignLines = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil. Same as UpdateSign()." }, + SetTicksUntilWeatherChange = { Params = "NumTicks", Return = "", Notes = "Sets the number of ticks after which the weather will be changed." }, + SetTimeOfDay = { Params = "TimeOfDayTicks", Return = "", Notes = "Sets the time of day, expressed as number of ticks past sunrise, in the range 0 .. 24000." }, + SetWeather = { Params = "Weather", Return = "", Notes = "Sets the current weather (wSunny, wRain, wStorm) and resets the TicksUntilWeatherChange to the default value for the new weather. The normal weather-changing hooks are called for the change." }, + SpawnItemPickups = + { + { Params = "{{cItems|Pickups}}, X, Y, Z, FlyAwaySpeed", Return = "", Notes = "Spawns the specified pickups at the position specified. The FlyAway speed is used to initialize the random speed in which the pickups fly away from the spawn position." }, + { Params = "{{cItems|Pickups}}, X, Y, Z, SpeedX, SpeedY, SpeedZ", Return = "", Notes = "Spawns the specified pickups at the position specified. All the pickups fly away from the spawn position using the specified speed." }, + }, + SpawnMob = { Params = "X, Y, Z, {{cMonster|MonsterType}}", Return = "EntityID", Notes = "Spawns the specified type of mob at the specified coords. Returns the EntityID of the creates entity, or -1 on failure. " }, + SpawnPrimedTNT = { Params = "X, Y, Z, FuseTimeSecs, InitialVelocityCoeff", Return = "", Notes = "Spawns a {{cTNTEntity|primed TNT entity}} at the specified coords, with the given fuse time. The entity gets a random speed multiplied by the InitialVelocityCoeff, 1 being the default value." }, + TryGetHeight = { Params = "BlockX, BlockZ", Return = "IsValid, Height", Notes = "Returns true and height of the highest non-air block if the chunk is loaded, or false otherwise." }, + UnloadUnusedChunks = { Params = "", Return = "", Notes = "Unloads chunks that are no longer needed, and are saved. NOTE: This API is deprecated and will be removed soon." }, + UpdateSign = { Params = "X, Y, Z, Line1, Line2, Line3, Line4, [{{cPlayer|Player}}]", Return = "", Notes = "Sets the sign text at the specified coords. The sign-updating hooks are called for the change. The Player parameter is used to indicate the player from whom the change has come, it may be nil. Same as SetSignLiens()" }, + UseBlockEntity = { Params = "{{cPlayer|Player}}, BlockX, BlockY, BlockZ", Return = "", Notes = "Makes the specified Player use the block entity at the specified coords (open chest UI, etc.) If the cords are in an unloaded chunk or there's no block entity, ignores the call." }, + WakeUpSimulators = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Wakes up the simulators for the specified block." }, + WakeUpSimulatorsInArea = { Params = "MinBlockX, MaxBlockX, MinBlockY, MaxBlockY, MinBlockZ, MaxBlockZ", Return = "", Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive)." }, }, Constants = { -- cgit v1.2.3 From 8ad8a25c2f3c46b4793a61ba95ab93af44625960 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Sep 2013 11:44:12 +0200 Subject: APIDump: Added callback examples to cWorld. --- MCServer/Plugins/APIDump/APIDesc.lua | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index a71a35099..444d697fa 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1466,6 +1466,66 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa Constants = { }, + AdditionalInfo = + { + { + Header = "Using callbacks", + Contents = [[ + To avoid problems with stale objects, the cWorld class will not let plugins get a direct pointer + to an {{cEntity|entity}}, {{cBlockEntity|block entity}} or a {{cPlayer|player}}. Such an object + could be modified or even destroyed by another thread while the plugin holds it, so it would be + rather unsafe.

    +

    + Instead, the cWorld provides access to these objects using callbacks. The plugin provides a + function that is called and receives the object as a parameter; cWorld guarantees that while + the callback is executing, the object will stay valid. If a plugin needs to "remember" the + object outside of the callback, it needs to store the entity ID, blockentity coords or player + name.

    +

    + The following code examples show how to use the callbacks

    +

    + This code teleports player Player to another player named ToName in the same world: +

    +-- Player is a cPlayer object
    +-- ToName is a string
    +-- World is a cWorld object
    +World:ForEachPlayer(
    +	function (a_OtherPlayer)
    +	if (a_OtherPlayer:GetName() == ToName) then
    +		Player:TeleportToEntity(a_OtherPlayer);
    +	end
    +);
    +

    +

    + This code fills each furnace in the chunk with 64 coals: +

    +-- Player is a cPlayer object
    +-- World is a cWorld object
    +World:ForEachFurnaceInChunk(Player:GetChunkX(), Player:GetChunkZ(),
    +	function (a_Furnace)
    +		a_Furnace:SetFuelSlot(cItem(E_ITEM_COAL, 64));
    +	end
    +);
    +

    +

    + This code teleports all spiders up by 100 blocks: +

    +-- World is a cWorld object
    +World:ForEachEntity(
    +	function (a_Entity)
    +		if not(a_Entity:IsMob()) then
    +			return;
    +		end
    +		local Monster = tolua.cast(a_Entity, "cMonster");  -- Get the cMonster out of cEntity, now that we know the entity represents one.
    +		if (Monster:GetMobType() == cMonster.mtSpider) then
    +			Monster:TeleportToCoords(Monster:GetPosX(), Monster:GetPosY() + 100, Monster:GetPosZ());
    +		end
    +	end
    +);
    +

    + ]], + }, + }, -- AdditionalInfo }, TakeDamageInfo = -- cgit v1.2.3 From d30bfc053d7e81f443a49741d67f372cf93400c3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Sep 2013 21:33:14 +0200 Subject: Updated the Core to the latest. Does this even matter in any way? --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index e3a45f343..3871f7afa 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit e3a45f34303331be77aceacf2ba53e503ad7284f +Subproject commit 3871f7afa326d3147b0f74653f7b836243a5c269 -- cgit v1.2.3 From b1dc792259397ce4f372fbbd51ec66a0d72d39fb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 16 Sep 2013 22:34:27 +0200 Subject: APIDump: Added a slight visual style to
     tags
    
    ---
     MCServer/Plugins/APIDump/main.css | 5 +++++
     1 file changed, 5 insertions(+)
    
    (limited to 'MCServer/Plugins')
    
    diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css
    index f9cdfc3ce..777f6d71a 100644
    --- a/MCServer/Plugins/APIDump/main.css
    +++ b/MCServer/Plugins/APIDump/main.css
    @@ -21,3 +21,8 @@ td, th
     	border: 1px solid #ccc;
     }
     
    +pre
    +{
    +	border: 1px solid #ccc;
    +	background-color: #eee;
    +}
    \ No newline at end of file
    -- 
    cgit v1.2.3
    
    
    From dd31eb92423cf2ec2637c96fc0a770e440dc32fd Mon Sep 17 00:00:00 2001
    From: madmaxoft 
    Date: Mon, 16 Sep 2013 22:42:49 +0200
    Subject: APIDump: Additional information is linkified, too.
    
    ---
     MCServer/Plugins/APIDump/main.lua | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)
    
    (limited to 'MCServer/Plugins')
    
    diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
    index 73acd3e69..7c200712d 100644
    --- a/MCServer/Plugins/APIDump/main.lua
    +++ b/MCServer/Plugins/APIDump/main.lua
    @@ -591,7 +591,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
     	if (a_ClassAPI.AdditionalInfo ~= nil) then
     		for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do
     			cf:write("

    " .. additional.Header .. "

    \n"); - cf:write(additional.Contents); + cf:write(LinkifyString(additional.Contents)); end end -- cgit v1.2.3 From a6e39332537eda0852598fb86ac0d427160f1409 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 17 Sep 2013 17:44:54 +0200 Subject: Documented cRoot. --- MCServer/Plugins/APIDump/APIDesc.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 444d697fa..da74d82cf 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1191,6 +1191,25 @@ a_Player:OpenWindow(Window); ]], Functions = { + Get = { Params = "", Return = "Root object", Notes = "This function returns the cRoot object " }, + BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server" }, + FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player" }, + ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player" }, + ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world" }, + GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" }, + GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world" }, + GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object" }, + GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object" }, + GetPluginManager = { Params = "", Return = "{{cPluginManager|cPluginManager}}", Notes = "Returns the cPluginManager object" }, + GetPrimaryServerVersion = { Params = "", Return = "Int", Notes = "Returns the servers primary server version" }, + GetProtocolVersionTextFromInt = { Params = "Protocol Version", Return = "string", Notes = "Returns the Minecraft version from the given Protocol" }, + GetServer = { Params = "", Return = "{{cServer|cServer}}", Notes = "Returns the cServer object" }, + GetTotalChunkCount = { Params = "", Return = "Int", Notes = "Returns the amount of loaded chunks" }, + GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object" }, + GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world" }, + QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' }, + SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds" }, + SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol Int" } }, Constants = { -- cgit v1.2.3 From fd52daec93d4053a0bfb04c380c1baa187ddb983 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 18 Sep 2013 12:04:07 +0200 Subject: APIDump: Small cRoot improvement. --- MCServer/Plugins/APIDump/APIDesc.lua | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index da74d82cf..587248a1a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1191,25 +1191,25 @@ a_Player:OpenWindow(Window); ]], Functions = { - Get = { Params = "", Return = "Root object", Notes = "This function returns the cRoot object " }, - BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server" }, - FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player" }, - ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player" }, - ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world" }, + Get = { Params = "", Return = "Root object", Notes = "This function returns the cRoot object." }, + BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server." }, + FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player." }, + ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature:
    function Callback({{cPlayer|cPlayer}})
    " }, + ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature:
    function Callback({{cWorld|cWorld}})
    " }, GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" }, - GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world" }, - GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object" }, - GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object" }, - GetPluginManager = { Params = "", Return = "{{cPluginManager|cPluginManager}}", Notes = "Returns the cPluginManager object" }, - GetPrimaryServerVersion = { Params = "", Return = "Int", Notes = "Returns the servers primary server version" }, - GetProtocolVersionTextFromInt = { Params = "Protocol Version", Return = "string", Notes = "Returns the Minecraft version from the given Protocol" }, - GetServer = { Params = "", Return = "{{cServer|cServer}}", Notes = "Returns the cServer object" }, - GetTotalChunkCount = { Params = "", Return = "Int", Notes = "Returns the amount of loaded chunks" }, - GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object" }, - GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world" }, + GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." }, + GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object." }, + GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object." }, + GetPluginManager = { Params = "", Return = "{{cPluginManager|cPluginManager}}", Notes = "Returns the cPluginManager object." }, + GetPrimaryServerVersion = { Params = "", Return = "number", Notes = "Returns the servers primary server version." }, + GetProtocolVersionTextFromInt = { Params = "Protocol Version", Return = "string", Notes = "Returns the Minecraft version from the given Protocol. If there is no version found, it returns 'Unknown protocol(Parameter)'" }, + GetServer = { Params = "", Return = "{{cServer|cServer}}", Notes = "Returns the cServer object." }, + GetTotalChunkCount = { Params = "", Return = "number", Notes = "Returns the amount of loaded chunks." }, + GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." }, + GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." }, QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' }, - SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds" }, - SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol Int" } + SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds." }, + SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol number." } }, Constants = { -- cgit v1.2.3 From e8b70f8a0ef9b7be89a5d93d4daa1f9d90fcd0aa Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 18 Sep 2013 21:33:55 +0200 Subject: APIDump: Updated cPluginManager documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 104 +++++++++++++++++++++++++++++------ 1 file changed, 88 insertions(+), 16 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 587248a1a..f5777b67e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1146,34 +1146,106 @@ a_Player:OpenWindow(Window); cPluginManager = { - Desc = [[This class is used for generic plugin-related functionality. The plugin manager has a list of all plugins, can enable or disable plugins, manages hook and in-game console commands. -

    -

    There is one instance of cPluginManager in MCServer, to get it, call either {{GetPluginManager|GetPluginManager}}() or cPluginManager:Get() function. + Desc = [[ + This class is used for generic plugin-related functionality. The plugin manager has a list of all + plugins, can enable or disable plugins, manages hooks and in-game console commands.

    +

    + There is one instance of cPluginManager in MCServer, to get it, call either + {{cRoot|cRoot}}:Get():GetPluginManager() or cPluginManager:Get() function.

    +

    + Note that some functions are "static", that means that they are called using a dot operator instead + of the colon operator. For example: +

    +cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
    +

    ]], Functions = { - AddHook = { Params = "{{cPlugin|Plugin}}, HookType", Return = "", Notes = "Adds processing of the specified hook" }, - BindCommand = { Params = "Command, Permission, Callback, HelpString", Return = "", Notes = "Binds an in-game command with the specified callback function, permission and help string" }, - BindConsoleCommand = { Params = "Command, Callback, HelpString", Return = "", Notes = "Binds a console command with the specified callback function and help string" }, - DisablePlugin = { Params = "PluginName", Return = "", Notes = "Disables a plugin specified by its name" }, - ExecuteCommand = { Params = "Player, Command", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed" }, - ExecuteConsoleCommand = { Params = "Command", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." }, + AddHook = + { + { Params = "HookType, [HookFunction]", Return = "", Notes = "(STATIC) Informs the plugin manager that it should call the specified function when the specified hook event occurs. If a function is not specified, a default function name is looked up, based on the hook type" }, + { Params = "{{cPlugin|Plugin}}, HookType, [HookFunction]", Return = "", Notes = "(STATIC, DEPRECATED) Informs the plugin manager that it should call the specified function when the specified hook event occurs. If a function is not specified, a default function name is looked up, based on the hook type. NOTE: This format is deprecated and the server outputs a warning if it is used!" }, + }, + BindCommand = + { + { Params = "Command, Permission, Callback, HelpString", Return = "", Notes = "(STATIC) Binds an in-game command with the specified callback function, permission and help string. By common convention, providing an empty string for HelpString will hide the command from the /help display." }, + { Params = "Command, Permission, Callback, HelpString", Return = "", Notes = "Binds an in-game command with the specified callback function, permission and help string. By common convention, providing an empty string for HelpString will hide the command from the /help display." }, + }, + BindConsoleCommand = + { + { Params = "Command, Callback, HelpString", Return = "", Notes = "(STATIC) Binds a console command with the specified callback function and help string. By common convention, providing an empty string for HelpString will hide the command from the \"help\" console command." }, + { Params = "Command, Callback, HelpString", Return = "", Notes = "Binds a console command with the specified callback function and help string. By common convention, providing an empty string for HelpString will hide the command from the \"help\" console command." }, + }, + DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." }, + ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." }, + ExecuteConsoleCommand = { Params = "CommandStr", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, - ForceExecuteCommand = { Params = "Player, Command", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, - ForEachCommand = { Params = "Callback", Return = "", Notes = "Calls the Callback function for each command that has been bound using BindCommand()" }, - ForEachConsoleCommand = { Params = "Callback", Return = "", Notes = "Calls the Callback function for each command that has been bound using BindConsoleCommand()" }, + ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, + ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:
    function(Command, Permission, HelpString)
    . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, + ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature:
    function (Command, HelpString)
    . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, Get = { Params = "", Return = "cPluginManager", Notes = "Returns the single instance of the plugin manager" }, - GetAllPlugins = { Params = "", Return = "PluginTable", Notes = "Returns a table of all plugins, [name => cPlugin] pairs" }, + GetAllPlugins = { Params = "", Return = "table", Notes = "Returns a table (dictionary) of all plugins, [name => {{cPlugin}}] pairing." }, GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" }, GetNumPlugins = { Params = "", Return = "number", Notes = "Returns the number of plugins, including the disabled ones" }, GetPlugin = { Params = "PluginName", Return = "{{cPlugin|cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" }, - IsCommandBound = { Params = "Command", Return = "boolean", Notes = "Returns true if in-game Command is already bound (by any plugin)" }, - IsConsoleCommandBound = { Params = "Command", Return = "boolean", Notes = "Returns true if console Command is already bound (by any plugin)" }, - LoadPlugin = { Params = "PluginFolder", Return = "", Notes = "Loads a plugin from the specified folder" }, + IsCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if in-game Command is already bound (by any plugin)" }, + IsConsoleCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if console Command is already bound (by any plugin)" }, + LoadPlugin = { Params = "PluginFolder", Return = "", Notes = "(DEPRECATED) Loads a plugin from the specified folder. NOTE: Loading plugins may be an unsafe operation and may result in a deadlock or a crash. This API is deprecated and might be removed." }, ReloadPlugins = { Params = "", Return = "", Notes = "Reloads all active plugins" }, }, Constants = { + HOOK_BLOCK_TO_PICKUPS = { Notes = "Called when a block has been dug and is being converted to pickups. The server has provided the default pickups and the plugins may modify them." }, + HOOK_CHAT = { Notes = "Called when a client sends a chat message that is not a command. The plugin may modify the chat message" }, + HOOK_CHUNK_AVAILABLE = { Notes = "Called when a chunk is loaded or generated and becomes available in the {{cWorld|world}}." }, + HOOK_CHUNK_GENERATED = { Notes = "Called after a chunk is generated. A plugin may do last modifications on the generated chunk before it is handed of to the {{cWorld|world}}." }, + HOOK_CHUNK_GENERATING = { Notes = "Called before a chunk is generated. A plugin may override some parts of the generation algorithm." }, + HOOK_CHUNK_UNLOADED = { Notes = "Called after a chunk has been unloaded from a {{cWorld|world}}." }, + HOOK_CHUNK_UNLOADING = { Notes = "Called before a chunk is unloaded from a {{cWorld|world}}. The chunk has already been saved." }, + HOOK_COLLECTING_PICKUP = { Notes = "Called when a player is about to collect a pickup." }, + HOOK_CRAFTING_NO_RECIPE = { Notes = "Called when a player has items in the crafting slots and the server cannot locate any recipe. Plugin may provide a recipe." }, + HOOK_DISCONNECT = { Notes = "Called after the player has disconnected." }, + HOOK_EXECUTE_COMMAND = { Notes = "Called when a client sends a chat message that is recognized as a command, before handing that command to the regular command handler. A plugin may stop the command from being handled. This hook is called even when the player doesn't have permissions for the command." }, + HOOK_EXPLODED = { Notes = "Called after an explosion has been processed in a {{cWorld|world}}." }, + HOOK_EXPLODING = { Notes = "Called before an explosion is processed in a {{cWorld|world}}. A plugin may alter the explosion parameters or cancel the explosion altogether." }, + HOOK_HANDSHAKE = { Notes = "Called when a Handshake packet is received from a client." }, + HOOK_HOPPER_PULLING_ITEM = { Notes = "Called when a hopper is pulling an item from the container above it." }, + HOOK_HOPPER_PUSHING_ITEM = { Notes = "Called when a hopper is pushing an item into the container it is aimed at." }, + HOOK_KILLING = { Notes = "Called when an entity has just been killed. A plugin may resurrect the entity by setting its health to above zero." }, + HOOK_LOGIN = { Notes = "Called when a Login packet is sent to the client, before the client is queued for authentication." }, + HOOK_MAX = { Notes = "The maximum TypeID of a hook. Used internally by MCS to check hook type for validity." }, + HOOK_NUM_HOOKS = { Notes = "Total number of hook types MCS supports. Used internally by MCS to check hook type for validity." }, + HOOK_PLAYER_ANIMATION = { Notes = "Called when a client send the Animation packet." }, + HOOK_PLAYER_BREAKING_BLOCK = { Notes = "Called when a player is about to break a block. A plugin may cancel the event." }, + HOOK_PLAYER_BROKEN_BLOCK = { Notes = "Called after a player has broken a block." }, + HOOK_PLAYER_EATING = { Notes = "Called when the player starts eating a held item. Plugins may abort the eating." }, + HOOK_PLAYER_JOINED = { Notes = "Called when the player entity has been created. It has not yet been fully initialized." }, + HOOK_PLAYER_LEFT_CLICK = { Notes = "Called when the client sends the LeftClick packet." }, + HOOK_PLAYER_MOVING = { Notes = "Called when the player has moved and the movement is now being applied." }, + HOOK_PLAYER_PLACED_BLOCK = { Notes = "Called when the player has just placed a block" }, + HOOK_PLAYER_PLACING_BLOCK = { Notes = "Called when the player is about to place a block. A plugin may cancel the event." }, + HOOK_PLAYER_RIGHT_CLICK = { Notes = "Called when the client sends the RightClick packet." }, + HOOK_PLAYER_RIGHT_CLICKING_ENTITY = { Notes = "Called when the client sends the UseEntity packet." }, + HOOK_PLAYER_SHOOTING = { Notes = "Called when the player releases the mouse button to fire their bow." }, + HOOK_PLAYER_SPAWNED = { Notes = "Called after the player entity has been created. The entity is fully initialized and is spawning in the {{cWorld|world}}." }, + HOOK_PLAYER_TOSSING_ITEM = { Notes = "Called when the player is tossing the held item (keypress Q)" }, + HOOK_PLAYER_USED_BLOCK = { Notes = "Called after the player has right-clicked a block" }, + HOOK_PLAYER_USED_ITEM = { Notes = "Called after the player has right-clicked with a usable item in their hand." }, + HOOK_PLAYER_USING_BLOCK = { Notes = "Called when the player is about to use (right-click) a block" }, + HOOK_PLAYER_USING_ITEM = { Notes = "Called when the player is about to right-click with a usable item in their hand." }, + HOOK_POST_CRAFTING = { Notes = "Called after a valid recipe has been chosen for the current contents of the crafting grid. Plugins may modify the recipe." }, + HOOK_PRE_CRAFTING = { Notes = "Called before a recipe is searched for the current contents of the crafting grid. Plugins may provide a recipe and cancel the built-in search." }, + HOOK_SPAWNED_ENTITY = { Notes = "Called after an entity is spawned in a {{cWorld|world}}. The entity is already part of the world." }, + HOOK_SPAWNED_MONSTER = { Notes = "Called after a mob is spawned in a {{cWorld|world}}. The mob is already part of the world." }, + HOOK_SPAWNING_ENTITY = { Notes = "Called just before an entity is spawned in a {{cWorld|world}}." }, + HOOK_SPAWNING_MONSTER = { Notes = "Called just before a mob is spawned in a {{cWorld|world}}." }, + HOOK_TAKE_DAMAGE = { Notes = "Called when an entity is taking any kind of damage. Plugins may modify the damage value, effects, source or cancel the damage." }, + HOOK_TICK = { Notes = "Called when the main server thread ticks - 20 times a second." }, + HOOK_UPDATED_SIGN = { Notes = "Called after a {{cSignEntity|sign}} text has been updated, either by a player or by any external means." }, + HOOK_UPDATING_SIGN = { Notes = "Called before a {{cSignEntity|sign}} text is updated, either by a player or by any external means." }, + HOOK_WEATHER_CHANGED = { Notes = "Called after the weather has changed." }, + HOOK_WEATHER_CHANGING = { Notes = "Called just before the weather changes" }, + HOOK_WORLD_TICK = { Notes = "Called in each world's tick thread when the game logic is about to tick (20 times a second)." }, }, }, -- cgit v1.2.3 From bc3447e4b2bf54306215524837de3ff028d1636b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 19 Sep 2013 18:53:07 +0200 Subject: APIDump: Automatic corrections. --- MCServer/Plugins/APIDump/APIDesc.lua | 161 +++++++++++++++++------------------ 1 file changed, 78 insertions(+), 83 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f5777b67e..82bbe9e0d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -487,9 +487,9 @@ g_APIDesc = ]], Functions = { - Sort = { Notes = "void" }, - IsInside = { Notes = "bool" }, - IsInside = { Notes = "bool" }, + Sort = { Return = "" }, + IsInside = { Return = "bool" }, + IsInside = { Return = "bool" }, }, Variables = { @@ -688,14 +688,14 @@ g_APIDesc = ]], Functions = { - SetName = { Notes = "void" }, - GetName = { Notes = "String" }, - SetColor = { Notes = "void" }, - GetColor = { Notes = "String" }, - AddCommand = { Notes = "void" }, - HasCommand = { Notes = "bool" }, - AddPermission = { Notes = "void" }, - InheritFrom = { Notes = "void" }, + SetName = { Return = "" }, + GetName = { Return = "string" }, + SetColor = { Return = "" }, + GetColor = { Return = "string" }, + AddCommand = { Return = "" }, + HasCommand = { Return = "bool" }, + AddPermission = { Return = "" }, + InheritFrom = { Return = "" }, }, Constants = { @@ -709,16 +709,16 @@ g_APIDesc = Functions = { constructor = { Return = "{{cIniFile|cIniFile}}" }, - CaseSensitive = { Notes = "void" }, - CaseInsensitive = { Notes = "void" }, - Path = { Notes = "void" }, - Path = { Notes = "String" }, - SetPath = { Notes = "void" }, - ReadFile = { Notes = "bool" }, - WriteFile = { Notes = "bool" }, - Erase = { Notes = "void" }, - Clear = { Notes = "void" }, - Reset = { Notes = "void" }, + CaseSensitive = { Return = "" }, + CaseInsensitive = { Return = "" }, + Path = { Return = "" }, + Path = { Return = "string" }, + SetPath = { Return = "" }, + ReadFile = { Return = "bool" }, + WriteFile = { Return = "bool" }, + Erase = { Return = "" }, + Clear = { Return = "" }, + Reset = { Return = "" }, FindKey = { Notes = "long i" }, FindValue = { Notes = "long i" }, NumKeys = { Notes = "unsigned i" }, @@ -743,29 +743,29 @@ g_APIDesc = GetValueSetI = { Notes = "i" }, GetValueSetB = { Notes = "bo" }, GetValueSetF = { Notes = "doub" }, - SetValue = { Notes = "bool" }, - SetValue = { Notes = "bool" }, - SetValueI = { Notes = "bool" }, - SetValueB = { Notes = "bool" }, - SetValueF = { Notes = "bool" }, - DeleteValueByID = { Notes = "bool" }, - DeleteValue = { Notes = "bool" }, - DeleteKey = { Notes = "bool" }, + SetValue = { Return = "bool" }, + SetValue = { Return = "bool" }, + SetValueI = { Return = "bool" }, + SetValueB = { Return = "bool" }, + SetValueF = { Return = "bool" }, + DeleteValueByID = { Return = "bool" }, + DeleteValue = { Return = "bool" }, + DeleteKey = { Return = "bool" }, NumHeaderComments = { Notes = "unsigned int" }, - HeaderComment = { Notes = "void" }, + HeaderComment = { Return = "" }, HeaderComment = { Notes = "Stri" }, - DeleteHeaderComment = { Notes = "bool" }, - DeleteHeaderComments = { Notes = "void" }, + DeleteHeaderComment = { Return = "bool" }, + DeleteHeaderComments = { Return = "" }, NumKeyComments = { Notes = "unsigned i" }, NumKeyComments = { Notes = "unsigned i" }, - KeyComment = { Notes = "bool" }, - KeyComment = { Notes = "bool" }, + KeyComment = { Return = "bool" }, + KeyComment = { Return = "bool" }, KeyComment = { Notes = "Stri" }, KeyComment = { Notes = "Stri" }, - DeleteKeyComment = { Notes = "bool" }, - DeleteKeyComment = { Notes = "bool" }, - DeleteKeyComments = { Notes = "bool" }, - DeleteKeyComments = { Notes = "bool" }, + DeleteKeyComment = { Return = "bool" }, + DeleteKeyComment = { Return = "bool" }, + DeleteKeyComments = { Return = "bool" }, + DeleteKeyComments = { Return = "bool" }, }, Constants = { @@ -1042,12 +1042,12 @@ a_Player:OpenWindow(Window); ]], Functions = { - TeleportToEntity = { Notes = "void" }, - TeleportTo = { Notes = "void" }, - Heal = { Notes = "void" }, - TakeDamage = { Notes = "void" }, - KilledBy = { Notes = "void" }, - GetHealth = { Notes = "int" }, + TeleportToEntity = { Return = "" }, + TeleportTo = { Return = "" }, + Heal = { Return = "" }, + TakeDamage = { Return = "" }, + KilledBy = { Return = "" }, + GetHealth = { Return = "number" }, }, Constants = { @@ -1063,7 +1063,7 @@ a_Player:OpenWindow(Window); { cPickup = { Notes = "[[cPickup}}" }, GetItem = { Notes = "{{cItem|cItem}}" }, - CollectedBy = { Notes = "bool" }, + CollectedBy = { Return = "bool" }, }, Constants = { @@ -1077,40 +1077,35 @@ a_Player:OpenWindow(Window); ]], Functions = { - GetEyeHeight = { Notes = "double" }, - GetEyePosition = { Notes = "{{Vector3d|Vector3d}}" }, - GetFlying = { Notes = "bool" }, - GetStance = { Notes = "double" }, - GetInventory = { Notes = "{{cInventory|cInventory}}" }, - TeleportTo = { Notes = "void" }, - GetGameMode = { Notes = "{{eGameMode|eGameMode}}" }, - GetIP = { Notes = "String" }, - GetLastBlockActionTime = { Notes = "float" }, - GetLastBlockActionCnt = { Notes = "int" }, - SetLastBlockActionCnt = { Notes = "void" }, - SetLastBlockActionTime = { Notes = "void" }, - SetGameMode = { Notes = "void" }, - MoveTo = { Notes = "void" }, - GetClientHandle = { Notes = "{{cClientHandle|cClientHandle}}" }, - SendMessage = { Notes = "void" }, - GetName = { Notes = "String" }, - SetName = { Notes = "void" }, - AddToGroup = { Notes = "void" }, - CanUseCommand = { Notes = "bool" }, - HasPermission = { Notes = "bool" }, - IsInGroup = { Notes = "bool" }, - GetColor = { Notes = "String" }, - TossItem = { Notes = "void" }, - Heal = { Notes = "void" }, - TakeDamage = { Notes = "void" }, - KilledBy = { Notes = "void" }, - Respawn = { Notes = "void" }, - SetVisible = { Notes = "void" }, - IsVisible = { Notes = "bool" }, - MoveToWorld = { Notes = "bool" }, - LoadPermissionsFromDisk = { Notes = "void" }, - GetGroups = { Notes = "list<{{cGroup|cGroup}}>" }, - GetResolvedPermissions = { Notes = "String" }, + GetEyeHeight = { Return = "number" }, + GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}" }, + GetFlying = { Return = "bool" }, + GetStance = { Return = "number" }, + GetInventory = { Return = "{{cInventory|Inventory}}" }, + GetGameMode = { Return = "{{eGameMode|GameMode}}", Notes = "Returns the player's gamemode. The player may have their gamemode unassigned, in which case they inherit the gamemode from the current {{cWorld|world}}.
    NOTE: Instead of comparing the value returned by this function to the gmXXX constants, use the IsGameModeXXX() functions. These functions handle the gamemode inheritance automatically."}, + GetIP = { Return = "string" }, + SetGameMode = { Return = "" }, + MoveTo = { Return = "" }, + GetClientHandle = { Return = "{{cClientHandle|ClientHandle}}" }, + SendMessage = { Return = "" }, + GetName = { Return = "String" }, + SetName = { Return = "" }, + AddToGroup = { Return = "" }, + CanUseCommand = { Return = "bool" }, + HasPermission = { Return = "bool" }, + IsInGroup = { Return = "bool" }, + GetColor = { Return = "string" }, + TossItem = { Return = "" }, + Heal = { Return = "" }, + TakeDamage = { Return = "" }, + KilledBy = { Return = "" }, + Respawn = { Return = "" }, + SetVisible = { Return = "" }, + IsVisible = { Return = "bool" }, + MoveToWorld = { Return = "bool" }, + LoadPermissionsFromDisk = { Return = "" }, + GetGroups = { Return = "list<{{cGroup|cGroup}}>" }, + GetResolvedPermissions = { Return = "string" }, }, Constants = { @@ -1124,11 +1119,11 @@ a_Player:OpenWindow(Window); ]], Functions = { - GetName = { Notes = "String" }, - SetName = { Notes = "void" }, + GetName = { Return = "string" }, + SetName = { Return = "" }, GetVersion = { Notes = "int" }, - SetVersion = { Notes = "void" }, - GetFileName = { Notes = "String" }, + SetVersion = { Return = "" }, + GetFileName = { Return = "string" }, CreateWebPlugin = { Notes = "{{cWebPlugin|cWebPlugin}}" }, }, Constants = -- cgit v1.2.3 From 636a0331f9cf2d4825acc76e74aeabcbb341142f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 22 Sep 2013 15:46:08 +0200 Subject: APIDump: Documented the globals. --- MCServer/Plugins/APIDump/APIDesc.lua | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 82bbe9e0d..b8f15c638 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1662,6 +1662,43 @@ World:ForEachEntity( { }, }, + Globals = + { + Desc = [[These functions are available directly, without a class instance. Any plugin cal call them at any time.]], + Functions = + { + AddFaceDirection = {Params = "BlockX, BlockY, BlockZ, BlockFace, Inverse", Return = "BlockX, BlockY, BlockZ", Notes = "Returns the coords of a block adjacent to the specified block through the specified face"}, + BlockStringToType = {Params = "BlockTypeString", Return = "BLOCKTYPE", Notes = "Returns the block type parsed from the given string"}, + ClickActionToString = {Params = "ClickAction", Return = "string", Notes = "Returns a string description of the ClickAction enumerated value"}, + DamageTypeToString = {Params = "{{TakeDamageInfo|eDamageType}}", Return = "string", Notes = "Converts a damage type enumerated value to a string representation "}, + EscapeString = {Params = "string", Return = "string", Notes = "Returns a copy of the string with all quotes and backslashes escaped by a backslash"}, + GetChar = {Params = "String, Pos", Return = "string", Notes = "Returns one character from the string, specified by position "}, + GetTime = {Return = "number", Notes = "Returns the current OS time, as a unix time stamp (number of seconds since Jan 1, 1970)"}, + IsValidBlock = {Params = "BlockType", Return = "bool", Notes = "Returns true if BlockType is a known block type"}, + IsValidItem = {Params = "ItemType", Return = "bool", Notes = "Returns true if ItemType is a known item type"}, + ItemToFullString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item, in the format “ItemTypeText:ItemDamage * Count”"}, + ItemToString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item type"}, + ItemTypeToString = {Params = "ItemType", Return = "string", Notes = "Returns the string representation of ItemType "}, + LOG = {Params = "string", Notes = "Logs a text into the server console using “normal” severity (gray text) "}, + LOGERROR = {Params = "string", Notes = "Logs a text into the server console using “error” severity (black text on red background)"}, + LOGINFO = {Params = "string", Notes = "Logs a text into the server console using “info” severity (yellow text)"}, + LOGWARN = {Params = "string", Notes = "Logs a text into the server console using “warning” severity (red text); OBSOLETE"}, + LOGWARNING = {Params = "string", Notes = "Logs a text into the server console using “warning” severity (red text)"}, + NoCaseCompare = {Params = "string, string", Return = "number", Notes = "Case-insensitive string comparison; returns 0 if the strings are the same"}, + ReplaceString = {Params = "full-string, to-be-replaced-string, to-replace-string", Notes = "Replaces *each* occurence of to-be-replaced-string in full-string with to-replace-string"}, + StringSplit = {Params = "string, Seperator", Return = "list", Notes = "Seperates string into multiple by splitting every time Seperator is encountered."}, + StringToBiome = {Params = "string", Return = "EMCSBiome", Notes = "Converts a string representation to a biome enumerated value"}, + StringToDamageType = {Params = "string", Return = "{{TakeDamageInfo|eDamageType}}", Notes = "Converts a string representation to an {{TakeDamageInfo|eDamageType}} enumerated value "}, + StringToDimension = {Params = "string", Return = "eDimension", Notes = "Converts a string representation to an eDimension enumerated value"}, + StringToItem = {Params = "string, {{cItem|cItem}}", Return = "bool", Notes = "Parses the given string and sets the item; returns true if successful"}, + StringToMobType = {Params = "string", Return = "number", Notes = "Converts a string representation to a mob enumerated value"}, + StripColorCodes = {Params = "string", Return = "string", Notes = "Removes all control codes used by MC for colors and styles"}, + md5 = {Params = "string", Return = "string", Notes = "converts a string to an md5 hash"}, + }, + Constants = + { + }, + }, }, -- cgit v1.2.3 From 34f94cdc913afa8a72227c52bca3e5210b0d005d Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sun, 22 Sep 2013 15:54:33 +0200 Subject: APIDump: Forgot a function in globals. --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b8f15c638..86256e4b3 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1693,6 +1693,7 @@ World:ForEachEntity( StringToItem = {Params = "string, {{cItem|cItem}}", Return = "bool", Notes = "Parses the given string and sets the item; returns true if successful"}, StringToMobType = {Params = "string", Return = "number", Notes = "Converts a string representation to a mob enumerated value"}, StripColorCodes = {Params = "string", Return = "string", Notes = "Removes all control codes used by MC for colors and styles"}, + TrimString = {Params = "string", Return = "string", Notes = "Trime whitespace at both ends of the string"}, md5 = {Params = "string", Return = "string", Notes = "converts a string to an md5 hash"}, }, Constants = -- cgit v1.2.3 From 401e31fdc00aa74af2a721e81831e019992c957f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 24 Sep 2013 22:41:29 +0200 Subject: APIDump: Documented the cBoundingBox class. --- MCServer/Plugins/APIDump/APIDesc.lua | 37 ++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 86256e4b3..b750bf74c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -311,8 +311,41 @@ g_APIDesc = cBoundingBox = { - Desc = "", - Functions = {}, + Desc = [[ + Represents two sets of coordinates, minimum and maximum for each direction; thus defining an + axis-aligned cuboid with floating-point boundaries. It supports operations changing the size and + position of the box, as well as querying whether a point or another BoundingBox is inside the box.

    +

    + All the points within the coordinate limits (inclusive the edges) are considered "inside" the box. + However, for intersection purposes, if the intersection is "sharp" in any coord (min1 == max2, i. e. + zero volume), the boxes are considered non-intersecting.

    + ]], + Functions = + { + constructor = + { + { Params = "MinX, MaxX, MinY, MaxY, MinZ, MaxZ", Return = "cBoundingBox", Notes = "Creates a new bounding box with the specified edges" }, + { Params = "{{Vector3d|Min}}, {{Vector3d|Max}}", Return = "cBoundingBox", Notes = "Creates a new bounding box with the coords specified as two vectors" }, + { Params = "{{Vector3d|Pos}}, Radius, Height", Return = "cBoundingBox", Notes = "Creates a new bounding box from the position given and radius (X/Z) and height. Radius is added from X/Z to calculate the maximum coords and subtracted from X/Z to get the minimum; minimum Y is set to Pos.y and maxumim Y to Pos.y plus Height. This corresponds with how {{cEntity|entities}} are represented in Minecraft." }, + { Params = "OtherBoundingBox", Return = "cBoundingBox", Notes = "Creates a new copy of the given bounding box. Same result can be achieved by using a simple assignment." }, + }, + CalcLineIntersection = { Params = "{{Vector3d|LineStart}}, {{Vector3d|LinePt2}}", Return = "DoesIntersect, LineCoeff, Face", Notes = "Calculates the intersection of a ray (half-line), given by two of its points, with the bounding box. Returns false if the line doesn't intersect the bounding box, or true, together with coefficient of the intersection (how much of the difference between the two ray points is needed to reach the intersection), and the face of the box which is intersected.
    TODO: Lua binding for this function is wrong atm." }, + DoesIntersect = { Params = "OtherBoundingBox", Return = "bool", Notes = "Returns true if the two bounding boxes have an intersection of nonzero volume." }, + Expand = { Params = "ExpandX, ExpandY, ExpandZ", Return = "", Notes = "Expands this bounding box by the specified amount in each direction (so the box becomes larger by 2 * Expand in each axis)." }, + IsInside = + { + { Params = "{{Vector3d|Point}}", Return = "bool", Notes = "Returns true if the specified point is inside (including on the edge) of the box." }, + { Params = "PointX, PointY, PointZ", Return = "bool", Notes = "Returns true if the specified point is inside (including on the edge) of the box." }, + { Params = "OtherBoundingBox", Return = "bool", Notes = "Returns true if OtherBoundingBox is inside of this box." }, + { Params = "{{Vector3d|OtherBoxMin}}, {{Vector3d|OtherBoxMax}}", Return = "bool", Notes = "Returns true if the other bounding box, specified by its 2 corners, is inside of this box." }, + }, + Move = + { + { Params = "OffsetX, OffsetY, OffsetZ", Return = "", Notes = "Moves the bounding box by the specified offset in each axis" }, + { Params = "{{Vector3d|Offset}}", Return = "", Notes = "Moves the bounding box by the specified offset in each axis" }, + }, + Union = { Params = "OtherBoundingBox", Return = "cBoundingBox", Notes = "Returns the smallest bounding box that contains both OtherBoundingBox and this bounding box. Note that unlike the strict geometrical meaning of \"union\", this operation actually returns a cBoundingBox." }, + }, Constants = {}, }, -- cgit v1.2.3 From 8ca8c84ee52b4edf914a2e2563204b7a86723263 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 25 Sep 2013 08:43:01 +0200 Subject: APIDump: Updated cClientHandle documentation --- MCServer/Plugins/APIDump/APIDesc.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b750bf74c..973e189d5 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -429,25 +429,27 @@ g_APIDesc = cClientHandle = { Desc = [[ - A cClientHandle represents technical aspect of a connected player - their game client connection. + A cClientHandle represents the technical aspect of a connected player - their game client + connection. Internally, it handles all the incoming and outgoing packets, the chunks that are to be + sent to the client, ping times etc. ]], Functions = { GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, - GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client" }, + GetPlayer = { Params = "", Return = "{{cPlayer|cPlayer}}", Notes = "Returns the player object connected to this client. Note that this may be nil, for example if the player object is not yet spawned." }, GetUniqueID = { Params = "", Return = "number", Notes = "Returns the UniqueID of the client used to identify the client in the server" }, GetUsername = { Params = "", Return = "string", Notes = "Returns the username that the client has provided" }, GetViewDistance = { Params = "", Return = "number", Notes = "Returns the viewdistance (number of chunks loaded for the player in each direction)" }, Kick = { Params = "Reason", Return = "", Notes = "Kicks the user with the specified reason" }, SetUsername = { Params = "Name", Return = "", Notes = "Sets the username" }, SetViewDistance = { Params = "ViewDistance", Return = "", Notes = "Sets the viewdistance (number of chunks loaded for the player in each direction)" }, - SendBlockChange = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sends a block to the client. This can be used to create fake blocks." }, + SendBlockChange = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sends a BlockChange packet to the client. This can be used to create fake blocks only for that player." }, }, Constants = { - MAX = { Notes = "10" }, - MIN = { Notes = "4" }, + MAX_VIEW_DISTANCE = { Notes = "The maximum value of the view distance" }, + MIN_VIEW_DISTANCE = { Notes = "The minimum value of the view distance" }, }, }, -- cgit v1.2.3 From 6d1580bd3949c8dab90d27544147950396f0187b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 25 Sep 2013 09:03:53 +0200 Subject: APIDump: Updated cChunkDesc docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 973e189d5..1d259b984 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -398,17 +398,40 @@ g_APIDesc = Functions = { FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" }, + FillRelCuboid = + { + { Params = "{{cCuboid|RelCuboid}}, BlockType, BlockMeta", Return = "", Notes = "Fills the cuboid, specified in relative coords, by the specified block type and block meta. The cuboid may reach outside of the chunk, only the part intersecting with this chunk is filled." }, + { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta", Return = "", Notes = "Fills the cuboid, specified in relative coords, by the specified block type and block meta. The cuboid may reach outside of the chunk, only the part intersecting with this chunk is filled." }, + }, + FloorRelCuboid = + { + { Params = "{{cCuboid|RelCuboid}}, BlockType, BlockMeta", Return = "", Notes = "Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, + { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta", Return = "", Notes = "Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, + }, GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" }, GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, + GetChunkX = { Params = "", Return = "number", Notes = "Returns the X coord of the chunk contained." }, + GetChunkZ = { Params = "", Return = "number", Notes = "Returns the Z coord of the chunk contained." }, GetHeight = { Params = "RelX, RelZ", Return = "number", Notes = "Returns the height at the specified relative coords" }, + GetMaxHeight = { Params = "", Return = "number", Notes = "Returns the maximum height contained in the heightmap." }, IsUsingDefaultBiomes = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default biome generator" }, IsUsingDefaultComposition = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default composition generator" }, IsUsingDefaultFinish = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default finishers" }, IsUsingDefaultHeight = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default height generator" }, IsUsingDefaultStructures = { Params = "", Return = "bool", Notes = "Returns true if the chunk is set to use default structures" }, - ReadBlockArea = { Params = "BlockArea, MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ", Return = "", Notes = "Reads data from the chunk into the block area object" }, + RandomFillRelCuboid = + { + { Params = "{{cCuboid|RelCuboid}}, BlockType, BlockMeta, RandomSeed, ChanceOutOf10k", Return = "", Notes = "Fills the specified relative cuboid with block type and meta in random locations. RandomSeed is used for the random number genertion (same seed produces same results); ChanceOutOf10k specifies the density (how many out of every 10000 blocks should be filled). Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, + { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta, RandomSeed, ChanceOutOf10k", Return = "", Notes = "Fills the specified relative cuboid with block type and meta in random locations. RandomSeed is used for the random number genertion (same seed produces same results); ChanceOutOf10k specifies the density (how many out of every 10000 blocks should be filled). Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, + }, + ReadBlockArea = { Params = "{{cBlockArea|BlockArea}}, MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ", Return = "", Notes = "Reads data from the chunk into the block area object. Block types and metas are processed." }, + ReplaceRelCuboid = + { + { Params = "{{cCuboid|RelCuboid}}, SrcType, SrcMeta, DstType, DstMeta", Return = "", Notes = "Replaces all SrcType+SrcMeta blocks in the cuboid (specified in relative coords) with DstType+DstMeta blocks. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, + { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, SrcType, SrcMeta, DstType, DstMeta", Return = "", Notes = "Replaces all SrcType+SrcMeta blocks in the cuboid (specified in relative coords) with DstType+DstMeta blocks. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, + }, SetBiome = { Params = "RelX, RelZ, EMCSBiome", Return = "", Notes = "Sets the biome at the specified relative coords" }, SetBlockMeta = { Params = "RelX, RelY, RelZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified relative coords" }, SetBlockType = { Params = "RelX, RelY, RelZ, BlockType", Return = "", Notes = "Sets the block type at the specified relative coords" }, @@ -419,7 +442,7 @@ g_APIDesc = SetUseDefaultFinish = { Params = "bool", Return = "", Notes = "Sets the chunk to use default finishers or not" }, SetUseDefaultHeight = { Params = "bool", Return = "", Notes = "Sets the chunk to use default height generator or not" }, SetUseDefaultStructures = { Params = "bool", Return = "", Notes = "Sets the chunk to use default structures or not" }, - WriteBlockArea = { Params = "BlockArea, MinRelX, MinRelY, MinRelZ", Return = "", Notes = "Writes data from the block area into the chunk" }, + WriteBlockArea = { Params = "{{cBlockArea|BlockArea}}, MinRelX, MinRelY, MinRelZ", Return = "", Notes = "Writes data from the block area into the chunk" }, }, Constants = { -- cgit v1.2.3 From fe9be5b8bec4b68cb13e6b5370b00fdc26d06278 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 25 Sep 2013 09:15:48 +0200 Subject: APIDump: Updated cBlockArea docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1d259b984..efe0fc43f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -157,10 +157,13 @@ g_APIDesc = SetBlockMeta = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified absolute coords" }, SetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified absolute coords" }, SetBlockType = { Params = "BlockX, BlockY, BlockZ, BlockType", Return = "", Notes = "Sets the block type at the specified absolute coords" }, + SetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block type and meta at the specified absolute coords" }, + SetOrigin = { Params = "OriginX, OriginY, OriginZ", Return = "", Notes = "Resets the origin for the absolute coords. Only affects how absolute coords are translated into relative coords." }, SetRelBlockLight = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockLight", Return = "", Notes = "Sets the blocklight at the specified relative coords" }, SetRelBlockMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockMeta", Return = "", Notes = "Sets the block meta at the specified relative coords" }, SetRelBlockSkyLight = { Params = "RelBlockX, RelBlockY, RelBlockZ, SkyLight", Return = "", Notes = "Sets the skylight at the specified relative coords" }, SetRelBlockType = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockType", Return = "", Notes = "Sets the block type at the specified relative coords" }, + SetRelBlockTypeMeta = { Params = "RelBlockX, RelBlockY, RelBlockZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block type and meta at the specified relative coords" }, Write = { Params = "World, MinX, MinY, MinZ, DataTypes", Return = "bool", Notes = "Writes the area into World at the specified coords, returns true if successful" }, }, Constants = -- cgit v1.2.3 From 1c0f47704f81f06923fac2ad995e74ae972da6b3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 26 Sep 2013 21:28:23 +0200 Subject: APIDump: completed cChestEntity docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index efe0fc43f..69e1e213d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -376,17 +376,46 @@ g_APIDesc = Desc = [[ A chest entity is a {{cBlockEntityWithItems|cBlockEntityWithItems}} descendant that represents a chest in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate - in any way. + in any way.

    +

    + The chest entity can be created by the plugins only in the {{OnChunkGenerating}} and + {{OnChunkGenerated}} hooks, as part of the new chunk being generated. Plugins may generate chests + with contents in this way.

    +

    + To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with + either DoWithChestAt() or ForEachChestInChunk() function. See the code example below ]], Inherits = "cBlockEntityWithItems", Functions = { + constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cChestEntity", Notes = "Creates a new cChestEntity object. To be used only in the chunk generating hooks {{OnChunkGenerating}} and {{OnChunkGenerated}}." }, }, Constants = { + ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, + ContentsWidth = { Notes = "Width of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, }, + AdditionalInfo = + { + { + Header = "Code example", + Contents = [[ + The following example code sets the top-left item of each chest in the same chunk as Player to + 64 * diamond: +

    +-- Player is a {{cPlayer}} object instance
    +local World = Player:GetWorld();
    +World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
    +	function (ChestEntity)
    +		ChestEntity:SetSlot(0, 0, cItem(E_ITEM_DIAMOND, 64));
    +	end
    +);
    +
    + ]], + }, + }, -- AdditionalInfo }, cChunkDesc = -- cgit v1.2.3 From b4c7b1879385932706734e30926b362b1aea1c09 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 26 Sep 2013 21:37:15 +0200 Subject: APIDump: Completed cCraftingGrid's documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 69e1e213d..333d1abe3 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -511,16 +511,21 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cCraftingGrid = { Desc = [[ - cCraftingGrid represents the player's crafting grid. It is used only in + cCraftingGrid represents the player's crafting grid. It is used in {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect the items the player placed - on their crafting grid. + on their crafting grid.

    +

    + Also, an object of this type is used in {{cCraftingRecipe}}'s ConsumeIngredients() function for + specifying the exact number of ingredients to consume in that recipe; plugins may use this to + apply the crafting recipe.

    ]], Functions = { + constructor = { Params = "Width, Height", Return = "cCraftingGrid", Notes = "Creates a new CraftingGrid object. This new crafting grid is not related to any player, but may be needed for {{cCraftingRecipe}}'s ConsumeIngredients function." }, Clear = { Params = "", Return = "", Notes = "Clears the entire grid" }, - ConsumeGrid = { Params = "{{cCraftingGrid|CraftingGrid}}", Return = "", Notes = "Consumes items specified in CraftingGrid from the current contents" }, + ConsumeGrid = { Params = "{{cCraftingGrid|CraftingGrid}}", Return = "", Notes = "Consumes items specified in CraftingGrid from the current contents. Used internally by {{cCraftingRecipe}}'s ConsumeIngredients() function, but available to plugins, too." }, Dump = { Params = "", Return = "", Notes = "DEBUG build: Dumps the contents of the grid to the log. RELEASE build: no action" }, GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the grid" }, GetItem = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified coords" }, -- cgit v1.2.3 From aeb44b5e66e0e88ca1a69a16282423eae444b47b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 26 Sep 2013 21:58:18 +0200 Subject: APIDump: Completed cCuboid docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 333d1abe3..c628efbc7 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -576,15 +576,37 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cCuboid = { Desc = [[ - cCuboid offers some native support for integral-boundary cuboids. A cuboid simply consists of two - {{vector3i}}-s. It offers some extra functions for sorting and checking if a point is inside the - cuboid. + cCuboid offers some native support for integral-boundary cuboids. A cuboid internally consists of + two {{Vector3i}}s. By default the cuboid doesn't make any assumptions about the defining points, + but for most of the operations in the cCuboid class, the p1 member variable is expected to be the + minima and the p2 variable the maxima. The Sort() function guarantees this condition.

    +

    + The Cuboid considers both its edges inclusive.

    ]], Functions = { - Sort = { Return = "" }, - IsInside = { Return = "bool" }, - IsInside = { Return = "bool" }, + constructor = + { + { Params = "OtheCuboid", Return = "cCuboid", Notes = "Creates a new Cuboid object as a copy of OtherCuboid" }, + { Params = "{{Vector3i|Point1}}, {{Vector3i|Point2}}", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." }, + { Params = "X, Y, Z", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified point as both its corners (the cuboid has a size of 1 in each direction)." }, + { Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "cCuboid", Notes = "Creates a new Cuboid object with the specified points as its corners." }, + }, + Assign = { Params = "X1, Y1, Z1, X2, Y2, Z2", Return = "", Notes = "Assigns all the coords stored in the cuboid. Sort-state is ignored." }, + DifX = { Params = "", Return = "number", Notes = "Returns the difference between the two X coords (X-size minus 1). Assumes sorted." }, + DifY = { Params = "", Return = "number", Notes = "Returns the difference between the two Y coords (Y-size minus 1). Assumes sorted." }, + DifZ = { Params = "", Return = "number", Notes = "Returns the difference between the two Z coords (Z-size minus 1). Assumes sorted." }, + DoesIntersect = { Params = "OtherCuboid", Return = "bool", Notes = "Returns true if this cuboid has at least one voxel in common with OtherCuboid. Note that edges are considered inclusive. Assumes both sorted." }, + IsCompletelyInside = { Params = "OuterCuboid", Return = "bool", Notes = "Returns true if this cuboid is completely inside (in all directions) in OuterCuboid. Assumes both sorted." }, + IsInside = + { + { Params = "X, Y, Z", Return = "bool", Notes = "Returns true if the specified point (integral coords) is inside this cuboid. Assumes sorted." }, + { Params = "{{Vector3i|Point}}", Return = "bool", Notes = "Returns true if the specified point (integral coords) is inside this cuboid. Assumes sorted." }, + { Params = "{{Vector3d|Point}}", Return = "bool", Notes = "Returns true if the specified point (floating-point coords) is inside this cuboid. Assumes sorted." }, + }, + IsSorted = { Params = "", Return = "bool", Notes = "Returns true if this cuboid is sorted" }, + Move = { Params = "OffsetX, OffsetY, OffsetZ", Return = "", Notes = "Adds the specified offsets to each respective coord, effectively moving the Cuboid. Sort-state is ignored." }, + Sort = { Params = "", Return = "" , Notes = "Sorts the internal representation so that p1 contains the lesser coords and p2 contains the greater coords." }, }, Variables = { -- cgit v1.2.3 From 271bbdd7ac15c5fa8de90797016243747b000231 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 27 Sep 2013 15:10:55 +0200 Subject: APIDump: Documented cServer --- MCServer/Plugins/APIDump/APIDesc.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index c628efbc7..7f10b0072 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1402,10 +1402,15 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cServer = { - Desc = [[cServer is typically only used by plugins to broadcast a chat message to all players in the server. Natively however, cServer accepts connections from clients and adds those clients to the game. + Desc = [[cServer is typically only used by plugins to broadcast a chat message(Now replaced by the {{cRoot|cRoot}} BroadcastChat function) to all players in the server. Natively however, cServer accepts connections from clients and adds those clients to the game. ]], Functions = { + GetDescription = { Return = "string", Notes = "Returns the server description set in the settings.ini." }, + GetMaxPlayers = { Return = "number", Notes = "Returns the max amount of players who can join the server." }, + SetMaxPlayers = { Params = "number", Notes = "Sets the max amount of players who can join." }, + GetNumPlayers = { Return = "number", Notes = "Returns the amount of players online." }, + GetServerID = { Return = "string", Notes = "Returns the ID of the server?" }, }, Constants = { -- cgit v1.2.3 From 5e7e4b3a2837e5d1bd27e24f09dd598d9b9643d2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 27 Sep 2013 16:32:44 +0200 Subject: APIDump: Updated cEntity docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 148 +++++++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 33 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7f10b0072..0318c69ea 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -691,67 +691,149 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cEntity = { - Desc = [[A cEntity object represents an object in the world, it has a position and orientation. cEntity is an abstract class, and can not be instantiated directly, instead, all entities are implemented as subclasses. The cEntity class works as the common interface for the operations that all (most) entities support. -

    -

    All cEntity objects have an Entity Type so it can be determined what kind of entity it is efficiently. Entities also have a class inheritance awareness, they know their class name, their parent class' name and can decide if there is a class within their inheritance chain. Since these functions operate on strings, they are slightly slower than checking the entity type directly, on the other hand, they are more specific (compare etMob vs "cSpider" class name). -

    -

    Note that you should not store a cEntity object between two hooks' calls, because MCServer may remove that entity in between the calls. If you need to refer to an entity later, use its UniqueID and {{cWorld|cWorld}}'s entity manipulation functions to access the entity. + Desc = [[ + A cEntity object represents an object in the world, it has a position and orientation. cEntity is an + abstract class, and can not be instantiated directly, instead, all entities are implemented as + subclasses. The cEntity class works as the common interface for the operations that all (most) + entities support.

    +

    + All cEntity objects have an Entity Type so it can be determined what kind of entity it is + efficiently. Entities also have a class inheritance awareness, they know their class name, + their parent class' name and can decide if there is a class within their inheritance chain. + Since these functions operate on strings, they are slightly slower than checking the entity type + directly, on the other hand, they are more specific directly. To check if the entity is a spider, + you need to call IsMob(), then cast the object to {{cMonster}} and finally compare + {{cMonster}}:GetMonsterType() to mtSpider. GetClass(), on the other hand, returns "cSpider" + directly.

    +

    + Note that you should not store a cEntity object between two hooks' calls, because MCServer may + despawn / remove that entity in between the calls. If you need to refer to an entity later, use its + UniqueID and {{cWorld|cWorld}}'s entity manipulation functions DoWithEntityByID(), ForEachEntity() + or ForEachEntityInChunk() to access the entity again.

    ]], Functions = { + AddPosition = + { + { Params = "OffsetX, OffsetY, OffsetZ", Return = "", Notes = "Moves the entity by the specified amount in each axis direction" }, + { Params = "{{Vector3d|Offset}}", Return = "", Notes = "Moves the entity by the specified amount in each direction" }, + }, + AddPosX = { Params = "OffsetX", Return = "", Notes = "Moves the entity by the specified amount in the X axis direction" }, + AddPosY = { Params = "OffsetY", Return = "", Notes = "Moves the entity by the specified amount in the Y axis direction" }, + AddPosZ = { Params = "OffsetZ", Return = "", Notes = "Moves the entity by the specified amount in the Z axis direction" }, + AddSpeed = + { + { Params = "AddX, AddY, AddZ", Return = "", Notes = "Adds the specified amount of speed in each axis direction." }, + { Params = "{{Vector3d|Add}}", Return = "", Notes = "Adds the specified amount of speed in each axis direction." }, + }, + AddSpeedX = { Params = "AddX", Return = "", Notes = "Adds the specified amount of speed in the X axis direction." }, + AddSpeedY = { Params = "AddY", Return = "", Notes = "Adds the specified amount of speed in the Y axis direction." }, + AddSpeedZ = { Params = "AddZ", Return = "", Notes = "Adds the specified amount of speed in the Z axis direction." }, Destroy = { Params = "", Return = "", Notes = "Schedules the entity to be destroyed" }, + GetArmorCoverAgainst = { Params = "AttackerEntity, DamageType, RawDamage", Return = "number", Notes = "Returns the number of hitpoints out of RawDamage that the currently equipped armor would cover. See {{TakeDamageInfo}} for more information on attack damage." }, GetChunkX = { Params = "", Return = "number", Notes = "Returns the X-coord of the chunk in which the entity is placed" }, - GetChunkY = { Params = "", Return = "number", Notes = "Returns the Y-coord of the chunk in which the entity is placed" }, GetChunkZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the chunk in which the entity is placed" }, - GetClass = { Params = "", Return = "string", Notes = "Returns the classname of the entity, such as \"spider\" or \"pickup\"" }, + GetClass = { Params = "", Return = "string", Notes = "Returns the classname of the entity, such as \"cSpider\" or \"cPickup\"" }, GetClassStatic = { Params = "", Return = "string", Notes = "Returns the entity classname that this class implements. Each descendant overrides this function. Is static" }, - GetEntityType = { Params = "", Return = "cEntity.eEntityType", Notes = "Returns the type of the entity, one of the etXXX constants" }, + GetEntityType = { Params = "", Return = "eEntityType", Notes = "Returns the type of the entity, one of the etXXX constants. Note that to check specific entity type, you should use one of the IsXXX functions instead of comparing the value returned by this call." }, + GetEquippedBoots = { Params = "", Return = "{{cItem}}", Notes = "Returns the boots that the entity has equipped. Returns an empty cItem if no boots equipped or not applicable." }, + GetEquippedChestplate = { Params = "", Return = "{{cItem}}", Notes = "Returns the chestplate that the entity has equipped. Returns an empty cItem if no chestplate equipped or not applicable." }, + GetEquippedHelmet = { Params = "", Return = "{{cItem}}", Notes = "Returns the helmet that the entity has equipped. Returns an empty cItem if no helmet equipped or not applicable." }, + GetEquippedLeggings = { Params = "", Return = "{{cItem}}", Notes = "Returns the leggings that the entity has equipped. Returns an empty cItem if no leggings equipped or not applicable." }, + GetEquippedWeapon = { Params = "", Return = "{{cItem}}", Notes = "Returns the weapon that the entity has equipped. Returns an empty cItem if no weapon equipped or not applicable." }, + GetGravity = { Params = "", Return = "number", Notes = "Returns the number that is used as the gravity for physics simulation. 1G (9.78) by default." }, + GetHeadYaw = { Params = "", Return = "number", Notes = "Returns the pitch of the entity's head (FIXME: Rename to GetHeadPitch() )." }, + GetHealth = { Params = "", Return = "number", Notes = "Returns the current health of the entity." }, + GetHeight = { Params = "", Return = "number", Notes = "Returns the height (Y size) of the entity" }, + GetKnockbackAmountAgainst = { Params = "ReceiverEntity", Return = "number", Notes = "Returns the amount of knockback that the currently equipped items would cause when attacking the ReceiverEntity." }, GetLookVector = { Params = "", Return = "Vector3f", Notes = "Returns the vector that defines the direction in which the entity is looking" }, + GetMass = { Params = "", Return = "number", Notes = "Returns the mass of the entity. Currently unused." }, + GetMaxHealth = { Params = "", Return = "number", Notes = "Returns the maximum number of hitpoints this entity is allowed to have." }, GetParentClass = { Params = "", Return = "string", Notes = "Returns the name of the direct parent class for this entity" }, GetPitch = { Params = "", Return = "number", Notes = "Returns the pitch (nose-down rotation) of the entity" }, + GetPosition = { Params = "", Return = "Vector3d", Notes = "Returns the entity's pivot position as a 3D vector" }, GetPosX = { Params = "", Return = "number", Notes = "Returns the X-coord of the entity's pivot" }, GetPosY = { Params = "", Return = "number", Notes = "Returns the Y-coord of the entity's pivot" }, GetPosZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the entity's pivot" }, - GetPosition = { Params = "", Return = "Vector3d", Notes = "Returns the entity's pivot position as a 3D vector" }, - GetRoll = { Params = "", Return = "number", Notes = "Returns the roll (sideways rotation) of the entity" }, - GetRot = { Params = "", Return = "Vector3f", Notes = "Returns the entire rotation vector (Rotation, Pitch, Roll)" }, - GetRotation = { Params = "", Return = "number", Notes = "Returns the rotation (direction) of the entity" }, + GetRawDamageAgainst = { Params = "ReceiverEntity", Return = "number", Notes = "Returns the raw damage that this entity's equipment would cause when attacking the ReceiverEntity. This includes this entity's weapon {{cEnchantments|enchantments}}, but excludes the receiver's armor or potion effects. See {{TakeDamageInfo}} for more information on attack damage." }, + GetRoll = { Params = "", Return = "number", Notes = "Returns the roll (sideways rotation) of the entity. Currently unused." }, + GetRot = { Params = "", Return = "{{Vector3f}}", Notes = "Returns the entire rotation vector (Yaw, Pitch, Roll)" }, + GetRotation = { Params = "", Return = "number", Notes = "Returns the yaw (direction) of the entity. FIXME: Rename to GetYaw()." }, GetSpeed = { Params = "", Return = "Vector3d", Notes = "Returns the complete speed vector of the entity" }, GetSpeedX = { Params = "", Return = "number", Notes = "Returns the X-part of the speed vector" }, GetSpeedY = { Params = "", Return = "number", Notes = "Returns the Y-part of the speed vector" }, GetSpeedZ = { Params = "", Return = "number", Notes = "Returns the Z-part of the speed vector" }, - GetUniqueID = { Params = "", Return = "number", Notes = "Returns the ID that uniquely identifies the entity" }, + GetUniqueID = { Params = "", Return = "number", Notes = "Returns the ID that uniquely identifies the entity within the running server. Note that this ID is not persisted to the data files." }, + GetWidth = { Params = "", Return = "number", Notes = "Returns the width (X and Z size) of the entity." }, GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world where the entity resides" }, + Heal = { Params = "Hitpoints", Return = "", Notes = "Heals the specified number of hitpoints. Hitpoints is expected to be a positive number." }, IsA = { Params = "ClassName", Return = "bool", Notes = "Returns true if the entity class is a descendant of the specified class name, or the specified class itself" }, - IsCrouched = { Params = "", Return = "bool", Notes = "Returns true if the entity is crouched. False for entities that don't support crouching" }, - IsDestroyed = { Params = "", Return = "bool", Notes = "Returns true if the entity has been destroyed and is awaiting removal from the internal structures" }, - IsMinecart = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a minecart" }, - IsMob = { Params = "", Return = "bool", Notes = "Returns true if the entity represents any mob" }, + IsBoat = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cBoat|boat}}." }, + IsCrouched = { Params = "", Return = "bool", Notes = "Returns true if the entity is crouched. Always false for entities that don't support crouching." }, + IsDestroyed = { Params = "", Return = "bool", Notes = "Returns true if the entity has been destroyed and is awaiting removal from the internal structures." }, + IsMinecart = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cMinecart|minecart}}" }, + IsMob = { Params = "", Return = "bool", Notes = "Returns true if the entity represents any {{cMonster|mob}}." }, IsOnFire = { Params = "", Return = "bool", Notes = "Returns true if the entity is on fire" }, - IsPickup = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a pickup" }, - IsPlayer = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a player" }, - IsTNT = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a TNT entity" }, + IsPickup = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cPickup|pickup}}." }, + IsPlayer = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cPlayer|player}}" }, IsRclking = { Params = "", Return = "bool", Notes = "Currently unimplemented" }, - IsSprinting = { Params = "", Return = "bool", Notes = "Returns true if the entity is sprinting. ENtities that cannot sprint return always false" }, + IsRiding = { Params = "", Return = "bool", Notes = "Returns true if the entity is attached to (riding) another entity." }, + IsSprinting = { Params = "", Return = "bool", Notes = "Returns true if the entity is sprinting. Entities that cannot sprint return always false" }, + IsTNT = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cTNTEntity|TNT entity}}" }, + KilledBy = { Notes = "FIXME: Remove this from API" }, + SetGravity = { Params = "Gravity", Return = "", Notes = "Sets the number that is used as the gravity for physics simulation. 1G (9.78) by default." }, + SetHeadYaw = { Params = "HeadPitch", Return = "", Notes = "Sets the head pitch (FIXME: Rename to SetHeadPitch() )." }, + SetHealth = { Params = "Hitpoints", Return = "", Notes = "Sets the entity's health to the specified amount of hitpoints. Doesn't broadcast any hurt animation. Doesn't kill the entity if health drops below zero. Use the TakeDamage() function instead for taking damage." }, + SetHeight = { Params = "", Return = "", Notes = "FIXME: Remove this from API" }, + SetMass = { Params = "Mass", Return = "", Notes = "Sets the mass of the entity. Currently unused." }, + SetMaxHealth = { Params = "MaxHitpoints", Return = "", Notes = "Sets the maximum hitpoints of the entity. If current health is above MaxHitpoints, it is capped to MaxHitpoints." }, SetPitch = { Params = "number", Return = "", Notes = "Sets the pitch (nose-down rotation) of the entity" }, + SetPitchFromSpeed = { Params = "", Return = "", Notes = "Sets the entity pitch to match its speed (entity looking forwards as it moves)" }, + SetPosition = + { + { Params = "PosX, PosY, PosZ", Return = "", Notes = "Sets all three coords of the entity's pivot" }, + { Params = "{{Vector3d|Vector3d}}", Return = "", Notes = "Sets all three coords of the entity's pivot" }, + }, SetPosX = { Params = "number", Return = "", Notes = "Sets the X-coord of the entity's pivot" }, SetPosY = { Params = "number", Return = "", Notes = "Sets the Y-coord of the entity's pivot" }, SetPosZ = { Params = "number", Return = "", Notes = "Sets the Z-coord of the entity's pivot" }, - SetPosition = { Params = "X, Y, Z", Return = "", Notes = "Sets all three coords of the entity's pivot" }, - SetPosition = { Params = "{{Vector3d|Vector3d}}", Return = "", Notes = ":::" }, - SetRoll = { Params = "number", Return = "", Notes = "Sets the roll (sideways rotation) of the entity" }, - SetRot = { Params = "{{Vector3f|Vector3f}}", Return = "", Notes = "Sets the entire rotation vector (Rotation, Pitch, Roll)" }, - SetRotation = { Params = "number", Return = "", Notes = "Sets the rotation (direction) of the entity" }, + SetRoll = { Params = "number", Return = "", Notes = "Sets the roll (sideways rotation) of the entity. Currently unused." }, + SetRot = { Params = "{{Vector3f|Rotation}}", Return = "", Notes = "Sets the entire rotation vector (Yaw, Pitch, Roll)" }, + SetRotation = { Params = "number", Return = "", Notes = "Sets the yaw (direction) of the entity. FIXME: Rename to SetYaw()." }, + SetRotationFromSpeed = { Params = "", Return = "", Notes = "Sets the entity's yaw to match its current speed (entity looking forwards as it moves). (FIXME: Rename to SetYawFromSpeed)" }, + SetSpeed = + { + { Params = "SpeedX, SpeedY, SpeedZ", Return = "", Notes = "Sets the current speed of the entity" }, + { Params = "{{Vector3d|Speed}}", Return = "", Notes = "Sets the current speed of the entity" }, + }, + SetSpeedX = { Params = "SpeedX", Return = "", Notes = "Sets the X component of the entity speed" }, + SetSpeedY = { Params = "SpeedY", Return = "", Notes = "Sets the Y component of the entity speed" }, + SetSpeedZ = { Params = "SpeedZ", Return = "", Notes = "Sets the Z component of the entity speed" }, + SetWidth = { Params = "", Return = "", Notes = "FIXME: Remove this from API" }, + StartBurning = { Params = "NumTicks", Return = "", Notes = "Sets the entity on fire for the specified number of ticks. If entity is on fire already, makes it burn for either NumTicks or the number of ticks left from the previous fire, whichever is larger." }, + SteerVehicle = { Params = "ForwardAmount, SidewaysAmount", Return = "", Notes = "Applies the specified steering to the vehicle this entity is attached to. Ignored if not attached to any entity." }, + StopBurning = { Params = "", Return = "", Notes = "Extinguishes the entity fire, cancels all fire timers." }, + TakeDamage = + { + { Params = "AttackerEntity", Return = "", Notes = "Causes this entity to take damage that AttackerEntity would inflict. Includes their weapon and this entity's armor." }, + { Params = "DamageType, AttackerEntity, RawDamage, KnockbackAmount", Return = "", Notes = "Causes this entity to take damage of the specified type, from the specified attacker (may be nil). The final damage is calculated from RawDamage using the currently equipped armor." }, + { Params = "DamageType, ArrackerEntity, RawDamage, FinalDamage, KnockbackAmount", Return = "", Notes = "Causes this entity to take damage of the specified type, from the specified attacker (may be nil). The values are wrapped into a {{TakeDamageInfo}} structure and applied directly." }, + }, + TeleportToCoords = { Params = "PosX, PosY, PosZ", Return = "", Notes = "Teleports the entity to the specified coords." }, + TeleportToEntity = { Params = "DestEntity", Return = "", Notes = "Teleports this entity to the specified destination entity." }, }, Constants = { - etEntity = { Notes = "N" }, - etPlayer = { Notes = "{{cPlayer|cPlayer" }, - etPickup = { Notes = "{{cPickup|cPickup" }, - etMob = { Notes = "{{cMonster|cMonster}} and descendan" }, - etFallingBlock = { Notes = "{{cFallingBlock|cFallingBlock" }, - etMinecart = { Notes = "{{cMinecart|cMinecart" }, - etTNT = { Notes = "{{cTNTEntity|cTNTEntity" }, + etBoat = { Notes = "The entity is a {{cBoat}}" }, + etEntity = { Notes = "No further specialization available" }, + etFallingBlock = { Notes = "The entity is a {{cFallingBlock}}" }, + etMob = { Notes = "The entity is a {{cMonster}} descendant" }, + etMonster = { Notes = "The entity is a {{cMonster}} descendant" }, + etMinecart = { Notes = "The entity is a {{cMinecart}} descendant" }, + etPlayer = { Notes = "The entity is a {{cPlayer}}" }, + etPickup = { Notes = "The entity is a {{cPickup}}" }, + etProjectile = { Notes = "The entity is a {{cProjectile}} descendant" }, + etTNT = { Notes = "The entity is a {{cTNTEntity}}" }, }, }, -- cgit v1.2.3 From 1f9397302c6e4381b86a15c3d28e41c9b199473e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Sep 2013 00:10:42 +0200 Subject: APIDump: Added the possibility to ignore classes. Ignoring Lua builtins. --- MCServer/Plugins/APIDump/APIDesc.lua | 14 +++++++++++++- MCServer/Plugins/APIDump/main.lua | 27 +++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0318c69ea..f260731f5 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -710,7 +710,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), despawn / remove that entity in between the calls. If you need to refer to an entity later, use its UniqueID and {{cWorld|cWorld}}'s entity manipulation functions DoWithEntityByID(), ForEachEntity() or ForEachEntityInChunk() to access the entity again.

    -]], + ]], Functions = { AddPosition = @@ -1906,6 +1906,18 @@ World:ForEachEntity( }, }, + + IgnoreClasses = + { + "coroutine", + "debug", + "io", + "math", + "package", + "os", + "string", + "table", + }, IgnoreFunctions = { diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 7c200712d..a7b4f7511 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -291,6 +291,19 @@ end function ReadDescriptions(a_API) + -- Returns true if the class of the specified name is to be ignored + local function IsClassIgnored(a_ClsName) + if (g_APIDesc.IgnoreClasses == nil) then + return false; + end + for i, name in ipairs(g_APIDesc.IgnoreClasses) do + if (a_ClsName:match(name)) then + return true; + end + end + return false; + end + -- Returns true if the function (specified by its fully qualified name) is to be ignored local function IsFunctionIgnored(a_FnName) if (g_APIDesc.IgnoreFunctions == nil) then @@ -317,6 +330,20 @@ function ReadDescriptions(a_API) return false; end + -- Remove ignored classes from a_API: + local APICopy = {}; + for i, cls in ipairs(a_API) do + if not(IsClassIgnored(cls.Name)) then + table.insert(APICopy, cls); + else + LOG("Ignoring class " .. cls.Name); + end + end + for i = 1, #a_API do + a_API[i] = APICopy[i]; + end; + + -- Process the documentation for each class: for i, cls in ipairs(a_API) do -- Rename special functions: for j, fn in ipairs(cls.Functions) do -- cgit v1.2.3 From 6fa0361a64ed150ee148f18e10c08635ea16059a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Sep 2013 08:55:31 +0200 Subject: APIDump: Linkified cDropSpenser constants. --- MCServer/Plugins/APIDump/APIDesc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f260731f5..e026e49d0 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -659,8 +659,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), }, Constants = { - ContentsWidth = { Notes = "Width (X) of the cItemGrid representing the contents" }, - ContentsHeight = { Notes = "Height (Y) of the cItemGrid representing the contents" }, + ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, + ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, }, Inherits = "cBlockEntity"; -- cgit v1.2.3 From 425073c4aa111a46ceb9ee2101f98b649c5ca8e8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Sep 2013 08:59:46 +0200 Subject: APIDump: Added more inheritance and linkification. --- MCServer/Plugins/APIDump/APIDesc.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e026e49d0..65d551d7e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -879,6 +879,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), Desc = "", Functions = {}, Constants = {}, + Inherits = "cProjectileEntity", } , cGroup = @@ -1063,10 +1064,10 @@ These ItemGrids are available in the API and can be manipulated by the plugins, Desc = [[This class represents a 2D array of items. It is used as the underlying storage and API for all cases that use a grid of items:
  • Chest contents
  • (TODO) Chest minecart contents
  • -
  • Dispenser contents
  • -
  • Dropper contents
  • -
  • (TODO) Furnace contents (?)
  • -
  • (TODO) Hopper contents
  • +
  • {{cDispenserEntity|Dispenser|| contents
  • +
  • {{cDropperEntity|Dropper}} contents
  • +
  • {{cFurnaceEntity|Furnace}} contents (?)
  • +
  • {{cHopperEntity|Hopper}} contents
  • (TODO) Hopper minecart contents
  • Player Inventory areas
  • (TODO) Trapped chest contents
  • @@ -1225,6 +1226,7 @@ a_Player:OpenWindow(Window); ]], }, }, -- AdditionalInfo + Inherits = "cWindow", }, -- cLuaWindow cMonster = -- cgit v1.2.3 From 9e19d598d0d8767c8de83699ba47dea42237ccd2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 29 Sep 2013 09:09:13 +0200 Subject: APIDump: Fixed overloaded functions' docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 63 +++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 18 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 65d551d7e..187fdeb9b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1078,33 +1078,54 @@ These ItemGrids are available in the API and can be manipulated by the plugins, { AddItem = { Params = "{{cItem|cItem}}, [AllowNewStacks]", Return = "number", Notes = "Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Returns the number of items added" }, AddItems = { Params = "{{cItems|cItems}}, [AllowNewStacks]", Return = "number", Notes = "Same as AddItem, but for several items at once" }, - ChangeSlotCount = { Params = "SlotNum, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum" }, - ChangeSlotCount = { Params = "X, Y, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid slot coords" }, + ChangeSlotCount = + { + { Params = "SlotNum, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid SlotNum" }, + { Params = "X, Y, AddToCount", Return = "number", Notes = "Adds AddToCount to the count of items in the specified slot. If the slot was empty, ignores the call. Returns the new count in the slot, or -1 if invalid slot coords" }, + }, Clear = { Params = "", Return = "", Notes = "Empties all slots" }, CopyToItems = { Params = "{{cItems|cItems}}", Return = "", Notes = "Copies all non-empty slots into the cItems object provided; original cItems contents are preserved" }, - DamageItem = { Params = "SlotNum, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, - DamageItem = { Params = "X, Y, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, - EmptySlot = { Params = "SlotNum", Return = "", Notes = "Destroys the item in the specified slot" }, - EmptySlot = { Params = "X, Y", Return = "", Notes = "Destroys the item in the specified slot" }, + DamageItem = + { + { Params = "SlotNum, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, + { Params = "X, Y, [DamageAmount]", Return = "bool", Notes = "Adds the specified damage (1 by default) to the specified item, returns true if the item reached its max damage and should be destroyed" }, + }, + EmptySlot = + { + { Params = "SlotNum", Return = "", Notes = "Destroys the item in the specified slot" }, + { Params = "X, Y", Return = "", Notes = "Destroys the item in the specified slot" }, + }, GetFirstEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the first empty slot, -1 if all slots are full" }, GetHeight = { Params = "", Return = "number", Notes = "Returns the Y dimension of the grid" }, GetLastEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the last empty slot, -1 if all slots are full" }, GetNextEmptySlot = { Params = "StartFrom", Return = "number", Notes = "Returns the SlotNumber of the first empty slot following StartFrom, -1 if all the following slots are full" }, GetNumSlots = { Params = "", Return = "number", Notes = "Returns the total number of slots in the grid (Width * Height)" }, - GetSlot = { Params = "SlotNumber", Return = "{{cItem|cItem}}", Notes = "Returns the item in the specified slot. Note that the item is read-only" }, - GetSlot = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the item in the specified slot. Note that the item is read-only" }, + GetSlot = + { + { Params = "SlotNumber", Return = "{{cItem|cItem}}", Notes = "Returns the item in the specified slot. Note that the item is read-only" }, + { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the item in the specified slot. Note that the item is read-only" }, + }, GetSlotCoords = { Params = "SlotNum", Return = "number, number", Notes = "Returns the X and Y coords for the specified SlotNumber. Returns \"-1, -1\" on invalid SlotNumber" }, GetSlotNum = { Params = "X, Y", Return = "number", Notes = "Returns the SlotNumber for the specified slot coords. Returns -1 on invalid coords" }, GetWidth = { Params = "", Return = "number", Notes = "Returns the X dimension of the grid" }, HasItems = { Params = "{{cItem|cItem}}", Return = "bool", Notes = "Returns true if there are at least as many items of the specified type as in the parameter" }, HowManyCanFit = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that can fit in the storage, including empty slots" }, HowManyItems = { Params = "{{cItem|cItem}}", Return = "number", Notes = "Returns the number of the specified items that are currently stored" }, - IsSlotEmpty = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, - IsSlotEmpty = { Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, - RemoveOneItem = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, - RemoveOneItem = { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, - SetSlot = { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, - SetSlot = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, + IsSlotEmpty = + { + { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, + { Params = "X, Y", Return = "bool", Notes = "Returns true if the specified slot is empty, or an invalid slot is specified" }, + }, + RemoveOneItem = + { + { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, + { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Removes one item from the stack in the specified slot and returns it as a single cItem. Empty slots are skipped and an empty item is returned" }, + }, + SetSlot = + { + { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, + { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, + }, }, Constants = { @@ -1121,13 +1142,19 @@ These ItemGrids are available in the API and can be manipulated by the plugins, Functions = { constructor = { Params = "", Return = "cItems", Notes = "Creates a new cItems object" }, - Add = { Params = "Index, {{cItem|cItem}}", Return = "", Notes = "Adds a new item to the end of the collection" }, - Add = { Params = "Index, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Adds a new item to the end of the collection" }, + Add = + { + { Params = "{{cItem|cItem}}", Return = "", Notes = "Adds a new item to the end of the collection" }, + { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Adds a new item to the end of the collection" }, + }, Clear = { Params = "", Return = "", Notes = "Removes all items from the collection" }, Delete = { Params = "Index", Return = "", Notes = "Deletes item at the specified index" }, Get = { Params = "Index", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified index" }, - Set = { Params = "Index, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified index to the specified item" }, - Set = { Params = "Index, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified index to the specified item" }, + Set = + { + { Params = "Index, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified index to the specified item" }, + { Params = "Index, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified index to the specified item" }, + }, Size = { Params = "", Return = "number", Notes = "Returns the number of items in the collection" }, }, Constants = -- cgit v1.2.3 From 4cbe24d2e89e5f75737be4cd9def525e6a20fb4b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 30 Sep 2013 20:45:13 +0200 Subject: APIDump: Added equality operator renaming. --- MCServer/Plugins/APIDump/main.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index a7b4f7511..300a4d9ce 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -362,6 +362,9 @@ function ReadDescriptions(a_API) elseif (fn.Name == ".sub") then fn.DocID = "operator_sub"; fn.Name = "operator -"; + elseif (fn.Name == ".eq") then + fn.DocID = "operator_sub"; + fn.Name = "operator =="; end end -- cgit v1.2.3 From 02c41b6f1dd8b0a197997c0e73f81d00493ac863 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 2 Oct 2013 08:49:15 +0200 Subject: APIDump: Fixed operator == rename having bad DocID. --- MCServer/Plugins/APIDump/APIDesc.lua | 8 ++++++-- MCServer/Plugins/APIDump/main.lua | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 187fdeb9b..643214de3 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -674,8 +674,12 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), ]], Functions = { - constructor = { Params = "", Return = "cEnchantments", Notes = "Creates a new empty cEnchantments object" }, - constructor = { Params = "StringSpec", Return = "cEnchantments", Notes = "Creates a new cEnchantments object filled with enchantments based on the string description" }, + constructor = + { + { Params = "", Return = "cEnchantments", Notes = "Creates a new empty cEnchantments object" }, + { Params = "StringSpec", Return = "cEnchantments", Notes = "Creates a new cEnchantments object filled with enchantments based on the string description" }, + }, + operator_eq = { Params = "OtherEnchantments", Return = "bool", Notes = "Returns true if this enchantments object has the same enchantments as OtherEnchantments." }, AddFromString = { Params = "StringSpec", Return = "", Notes = "Adds the enchantments in the string description into the object. If a specified enchantment already existed, it is overwritten." }, Clear = { Params = "", Return = "", Notes = "Removes all enchantments" }, GetLevel = { Params = "EnchantmentNumID", Return = "number", Notes = "Returns the level of the specified enchantment stored in this object; 0 if not stored" }, diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 300a4d9ce..6dc2f8a3e 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -363,7 +363,7 @@ function ReadDescriptions(a_API) fn.DocID = "operator_sub"; fn.Name = "operator -"; elseif (fn.Name == ".eq") then - fn.DocID = "operator_sub"; + fn.DocID = "operator_eq"; fn.Name = "operator =="; end end -- cgit v1.2.3 From 5ab6003e0fe0f3d9f781dfd7b1e79de7eb407d11 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 2 Oct 2013 08:50:43 +0200 Subject: APIDump: Removed ignored classes logging. --- MCServer/Plugins/APIDump/main.lua | 2 -- 1 file changed, 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 6dc2f8a3e..aaeebecbb 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -335,8 +335,6 @@ function ReadDescriptions(a_API) for i, cls in ipairs(a_API) do if not(IsClassIgnored(cls.Name)) then table.insert(APICopy, cls); - else - LOG("Ignoring class " .. cls.Name); end end for i = 1, #a_API do -- cgit v1.2.3 From a171757f1afee864b7d27357b4babb0c28c50d9a Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Oct 2013 22:01:01 +0100 Subject: MagicCarpet Fixes [SEE DESC] + Version 2! * Fixed loading plugin + Now uses Core messaging functions --- MCServer/Plugins/MagicCarpet/plugin.lua | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/MagicCarpet/plugin.lua b/MCServer/Plugins/MagicCarpet/plugin.lua index 27dcdf45d..bcf87d202 100644 --- a/MCServer/Plugins/MagicCarpet/plugin.lua +++ b/MCServer/Plugins/MagicCarpet/plugin.lua @@ -1,18 +1,18 @@ -local PLUGIN = {} local Carpets = {} function Initialize( Plugin ) PLUGIN = Plugin Plugin:SetName( "MagicCarpet" ) - Plugin:SetVersion( 1 ) + Plugin:SetVersion( 2 ) cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_MOVING, OnPlayerMoving) cPluginManager.AddHook(cPluginManager.HOOK_DISCONNECT, OnDisconnect) + local PluginManager = cPluginManager:Get() PluginManager:BindCommand("/mc", "magiccarpet", HandleCarpetCommand, " - Spawns a magical carpet"); - LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) + LOG( "Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() ) return true end @@ -33,14 +33,17 @@ end function HandleCarpetCommand( Split, Player ) Carpet = Carpets[ Player ] + PluginManager = cPluginManager:Get() + local Core = PluginManager:GetPlugin("Core") + if( Carpet == nil ) then Carpets[ Player ] = cCarpet:new() - Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "You're on a magic carpet!" ) - Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. "Look straight down to descend. Jump to ascend!" ) + Core:Call("SendMessageSuccess", Player, "You're on a magic carpet!") + Core:Call("SendMessage", Player, "Look straight down to descend. Jump to ascend.") else Carpet:remove() Carpets[ Player ] = nil - Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. "The carpet vanished!" ) + Core:Call("SendMessage", Player, "The carpet vanished!") end return true -- cgit v1.2.3 From 55e6963107866b1c76689ae39cd965d6446984eb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Wed, 2 Oct 2013 22:05:26 +0100 Subject: Fixed discrepancy --- MCServer/Plugins/MagicCarpet/plugin.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/MagicCarpet/plugin.lua b/MCServer/Plugins/MagicCarpet/plugin.lua index bcf87d202..219956984 100644 --- a/MCServer/Plugins/MagicCarpet/plugin.lua +++ b/MCServer/Plugins/MagicCarpet/plugin.lua @@ -43,7 +43,7 @@ function HandleCarpetCommand( Split, Player ) else Carpet:remove() Carpets[ Player ] = nil - Core:Call("SendMessage", Player, "The carpet vanished!") + Core:Call("SendMessageSuccess", Player, "The carpet vanished!") end return true -- cgit v1.2.3 From a1898521b0debe2c33ea63494208d84317a3cf0c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Oct 2013 08:49:55 +0200 Subject: APIDump: Added the cWorld:IsWeatherXXX() functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 643214de3..6d0b72c14 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1741,7 +1741,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa GetStorageSaveQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks queued up for saving" }, GetTicksUntilWeatherChange = { Params = "", Return = "number", Notes = "Returns the number of ticks that will pass before the weather is changed" }, GetTimeOfDay = { Params = "", Return = "number", Notes = "Returns the number of ticks that have passed from the sunrise, 0 .. 24000." }, - GetWeather = { Params = "", Return = "eWeather", Notes = "Returns the current weather in the world (wSunny, wRain, wStorm)." }, + GetWeather = { Params = "", Return = "eWeather", Notes = "Returns the current weather in the world (wSunny, wRain, wStorm). To check for weather, use IsWeatherXXX() functions instead." }, GetWorldAge = { Params = "", Return = "number", Notes = "Returns the total age of the world, in ticks. The age always grows, cannot be set by plugins and is unrelated to TimeOfDay." }, GrowCactus = { Params = "BlockX, BlockY, BlockZ, NumBlocksToGrow", Return = "", Notes = "Grows a cactus block at the specified coords, by up to the specified number of blocks. Adheres to the world's maximum cactus growth (GetMaxCactusHeight())." }, GrowMelonPumpkin = { Params = "BlockX, BlockY, BlockZ, StemType", Return = "", Notes = "Grows a melon or pumpkin, based on the stem type specified (assumed to be in the coords provided). Checks for normal melon / pumpkin growth conditions - stem not having another produce next to it and suitable ground below." }, @@ -1756,6 +1756,10 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmCreative." }, IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the current gamemode is gmSurvival." }, IsPVPEnabled = { Params = "", Return = "bool", Notes = "Returns whether PVP is enabled in the world settings." }, + IsWeatherRain = { Params = "", Return = "bool", Notes = "Returns true if the current weather is rain." }, + IsWeatherStorm = { Params = "", Return = "bool", Notes = "Returns true if the current weather is a storm." }, + IsWeatherSunny = { Params = "", Return = "bool", Notes = "Returns true if the current weather is sunny." }, + IsWeatherWet = { Params = "", Return = "bool", Notes = "Returns true if the current weather has any precipitation (rain or storm)." }, QueueBlockForTick = { Params = "BlockX, BlockY, BlockZ, TicksToWait", Return = "", Notes = "Queues the specified block to be ticked after the specified number of gameticks." }, QueueSaveAllChunks = { Params = "", Return = "", Notes = "Queues all chunks to be saved in the world storage thread" }, QueueSetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta, TickDelay", Return = "", Notes = "Queues the block to be set to the specified blocktype and meta after the specified amount of game ticks. Uses SetBlock() for the actual setting, so simulators are woken up and block entities are handled correctly." }, -- cgit v1.2.3 From fdc67142fd589a93840308a3eb1845a203d2cbec Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Fri, 4 Oct 2013 20:58:25 +0200 Subject: APIDump: Documented cPlugin --- MCServer/Plugins/APIDump/APIDesc.lua | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6d0b72c14..5779e18bc 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1347,14 +1347,18 @@ a_Player:OpenWindow(Window); cPlugin = { - Desc = [[cPlugin describes a Lua plugin. This page is dedicated to new-style plugins and contain their functions. + Desc = [[cPlugin describes a Lua plugin. This page is dedicated to new-style plugins and contain their functions. Each plugin has its own Plugin object. ]], Functions = { - GetName = { Return = "string" }, - SetName = { Return = "" }, - GetVersion = { Notes = "int" }, - SetVersion = { Return = "" }, + Call = { Params = "Function name, [All the parameters divided with commas]", Notes = "This function allows you to call a function from another plugin. It can only use pass: integers, booleans, strings and usertypes (cPlayer, cEntity, cCuboid, etc.)." }, + GetDirectory = { Return = "string", Notes = "Returns the name of the folder where the plugin's files are. (APIDump)" }, + GetLocalDirectory = { Notes = "OBSOLETE use GetLocalFolder instead." }, + GetLocalFolder = { Return = "string", Notes = "Returns the path where the plugin's files are. (Plugins/APIDump)" }, + GetName = { Return = "string", Notes = "Returns the name of the plugin." }, + SetName = { Params = "string", Notes = "Sets the name of the Plugin." }, + GetVersion = { Return = "number", Notes = "Returns the version of the plugin." }, + SetVersion = { Params = "number", Notes = "Sets the version of the plugin." }, GetFileName = { Return = "string" }, CreateWebPlugin = { Notes = "{{cWebPlugin|cWebPlugin}}" }, }, -- cgit v1.2.3 From a7401fa8329be3c9b33935ebffd1088f9e6088e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 4 Oct 2013 21:53:14 +0200 Subject: APIDump: Added cLineBlockTracer documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 90 ++++++++++++++++++++++++++++++++++-- 1 file changed, 86 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 5779e18bc..c849e0e3d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1168,10 +1168,92 @@ These ItemGrids are available in the API and can be manipulated by the plugins, cLineBlockTracer = { - Desc = "", - Functions = {}, - Constants = {}, - }, + Desc = [[Objects of this class provide an easy-to-use interface to tracing lines through individual +blocks in the world. It will call the provided callbacks according to what events it encounters along the +way.

    +

    +For the Lua API, there's only one function exported that takes all the parameters necessary to do the +tracing. The Callbacks parameter is a table containing all the functions that will be called upon the +various events. See below for further information. + ]], + Functions = + { + Trace = { Params = "{{cWorld}}, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ", Return = "bool", Notes = "(STATIC) Performs the trace on the specified line. Returns true if the entire trace was processed (no callback returned true)" }, + }, + + AdditionalInfo = + { + { + Header = "Callbacks", + Contents = [[ +The Callbacks in the Trace() function is a table that contains named functions. MCServer will call +individual functions from that table for the events that occur on the line - hitting a block, going out of +valid world data etc. The following table lists all the available callbacks. If the callback function is +not defined, MCServer skips it. Each function can return a bool value, if it returns true, the tracing is +aborted and Trace() returns false.

    +

    + + + + + + + + + + + + + +
    NameParametersNotes
    OnNextBlockBlockX, BlockY, BlockZ, BlockType, BlockMeta, EntryFaceCalled when the ray hits a new valid block. The block type and meta is given. EntryFace is one of the + BLOCK_FACE_ constants indicating which "side" of the block got hit by the ray.
    OnNextBlockNoDataBlockX, BlockY, BlockZ, EntryFaceCalled when the ray hits a new block, but the block is in an unloaded chunk - no valid data is + available. Only the coords and the entry face are given.
    OnOutOfWorldX, Y, ZCalled when the ray goes outside of the world (Y-wise); the coords specify the exact exit point. Note + that for other paths than lines (considered for future implementations) the path may leave the world and + go back in again later, in such a case this callback is followed by OnIntoWorld() and further + OnNextBlock() calls.
    OnIntoWorldX, Y, ZCalled when the ray enters the world (Y-wise); the coords specify the exact entry point.
    OnNoMoreHits Called when the path is sure not to hit any more blocks. This is the final callback, no more + callbacks are called after this function. Unlike the other callbacks, this function doesn't have a return + value.
    OnNoChunk Called when the ray enters a chunk that is not loaded. This usually means that the tracing is aborted. + Unlike the other callbacks, this function doesn't have a return value.
    + ]], + }, + { + Header = "Example", + Contents = [[ +

    The following example is taken from the Debuggers plugin. It is a command handler function for the +"/spidey" command that creates a line of cobweb blocks from the player's eyes up to 50 blocks away in +the direction they're looking, but only through the air. +

    +function HandleSpideyCmd(a_Split, a_Player)
    +	local World = a_Player:GetWorld();
    +
    +	local Callbacks = {
    +		OnNextBlock = function(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta)
    +			if (a_BlockType ~= E_BLOCK_AIR) then
    +				-- abort the trace
    +				return true;
    +			end
    +			World:SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_COBWEB, 0);
    +		end
    +	};
    +	
    +	local EyePos = a_Player:GetEyePosition();
    +	local LookVector = a_Player:GetLookVector();
    +	LookVector:Normalize();  -- Make the vector 1 m long
    +	
    +	-- Start cca 2 blocks away from the eyes
    +	local Start = EyePos + LookVector + LookVector;
    +	local End = EyePos + LookVector * 50;
    +	
    +	cLineBlockTracer.Trace(World, Callbacks, Start.x, Start.y, Start.z, End.x, End.y, End.z);
    +	
    +	return true;
    +end
    +
    +

    + ]], + }, + }, -- AdditionalInfo + }, -- cLineBlockTracer cLuaWindow = { -- cgit v1.2.3 From 914a318b8eab1d5cf913d3707a7af244b58a9bfb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 4 Oct 2013 22:22:01 +0100 Subject: Made MagicCarpet more magical! --- MCServer/Plugins/MagicCarpet/coremessaging.lua | 28 ++++++++++++++++++++++++++ MCServer/Plugins/MagicCarpet/plugin.lua | 10 ++++----- 2 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 MCServer/Plugins/MagicCarpet/coremessaging.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/MagicCarpet/coremessaging.lua b/MCServer/Plugins/MagicCarpet/coremessaging.lua new file mode 100644 index 000000000..1677e8940 --- /dev/null +++ b/MCServer/Plugins/MagicCarpet/coremessaging.lua @@ -0,0 +1,28 @@ +IniFile = cIniFile( "settings.ini" ) +IniFile:ReadFile() +UsePrefixes = IniFile:GetValueSet( "Messaging", "Prefixes", "true" ) +IniFile:WriteFile() + +function SendMessage(a_Player, a_Message) + if (UsePrefixes) then + a_Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. a_Message) + else + a_Player:SendMessage(cChatColor.Yellow .. a_Message) + end +end + +function SendMessageSuccess(a_Player, a_Message) + if (UsePrefixes) then + a_Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. a_Message) + else + a_Player:SendMessage(cChatColor.Green .. a_Message) + end +end + +function SendMessageFailure(a_Player, a_Message) + if (UsePrefixes) then + a_Player:SendMessage(cChatColor.Red .. "[INFO] " .. cChatColor.White .. a_Message) + else + a_Player:SendMessage(cChatColor.Red .. a_Message) + end +end \ No newline at end of file diff --git a/MCServer/Plugins/MagicCarpet/plugin.lua b/MCServer/Plugins/MagicCarpet/plugin.lua index 219956984..4a2097351 100644 --- a/MCServer/Plugins/MagicCarpet/plugin.lua +++ b/MCServer/Plugins/MagicCarpet/plugin.lua @@ -33,17 +33,15 @@ end function HandleCarpetCommand( Split, Player ) Carpet = Carpets[ Player ] - PluginManager = cPluginManager:Get() - local Core = PluginManager:GetPlugin("Core") - + if( Carpet == nil ) then Carpets[ Player ] = cCarpet:new() - Core:Call("SendMessageSuccess", Player, "You're on a magic carpet!") - Core:Call("SendMessage", Player, "Look straight down to descend. Jump to ascend.") + SendMessageSuccess(Player, "You're on a magic carpet!") + SendMessage(Player, "Look straight down to descend. Jump to ascend.") else Carpet:remove() Carpets[ Player ] = nil - Core:Call("SendMessageSuccess", Player, "The carpet vanished!") + SendMessageSuccess(Player, "The carpet vanished!") end return true -- cgit v1.2.3 From d41f3a1b0ce4eb2f7fceef8ad91468da443aab05 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 5 Oct 2013 12:01:51 +0200 Subject: APIDump: Brought cItem docs up-to-date. --- MCServer/Plugins/APIDump/APIDesc.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index c849e0e3d..6578e6d8b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1034,27 +1034,29 @@ These ItemGrids are available in the API and can be manipulated by the plugins, { Desc = [[ cItem is what defines an item or stack of items in the game, it contains the item ID, damage, - quantity and enchantments. Each slot in a {{cInventory|cInventory}} class or a - {{cItemGrid|cItemGrid}} class is a cItem and each cPickup contains a cItem. The enchantments - are contained in a {{cEnchantments|cEnchantments}} class + quantity and enchantments. Each slot in a {{cInventory}} class or a {{cItemGrid}} class is a cItem + and each {{cPickup}} contains a cItem. The enchantments are contained in a separate + {{cEnchantments}} class and are accessible through the m_Enchantments variable. ]], Functions = { constructor = { - { Params = "", Return = "cItem", Notes = "Creates a new empty cItem obje" }, + { Params = "", Return = "cItem", Notes = "Creates a new empty cItem object" }, { Params = "ItemType, Count, Damage, EnchantmentString", Return = "cItem", Notes = "Creates a new cItem object of the specified type, count (1 by default), damage (0 by default) and enchantments (non-enchanted by default)" }, { Params = "cItem", Return = "cItem", Notes = "Creates an exact copy of the cItem object in the parameter" }, } , + AddCount = { Params = "AmountToAdd", Return = "cItem", Notes = "Adds the specified amount to the item count. Returns self (useful for chaining)." }, Clear = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, CopyOne = { Params = "", Return = "cItem", Notes = "Creates a copy of this object, with its count set to 1" }, DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" }, Empty = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, GetMaxDamage = { Params = "", Return = "number", Notes = "Returns the maximum value for damage that this item can get before breaking; zero if damage is not accounted for for this item type" }, IsDamageable = { Params = "", Return = "bool", Notes = "Returns true if this item does account for its damage" }, - IsEnchantable = { Params = "ItemType", Return = "bool", Notes = "(static) Returns true if the specified ItemType is an enchantable item, as defined by the 1.2.5 network protocol (deprecated)" }, + IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if this object represents an empty item (zero count or invalid ID)" }, IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" }, + IsFullStack = { Params = "", Return = "bool", Notes = "Returns true if the item is stacked up to its maximum stacking" }, IsSameType = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is of the same ItemType as the one stored in the object" }, IsStackableWith = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is stackable with the one stored in the object" }, }, -- cgit v1.2.3 From c34a9422f7ac802e242a2f36178a77cb5a0f533c Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Mon, 7 Oct 2013 07:38:20 +0100 Subject: Updated plugins. --- MCServer/Plugins/Core | 2 +- MCServer/Plugins/ProtectionAreas | 2 +- MCServer/Plugins/TransAPI | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 3871f7afa..839fb9582 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 3871f7afa326d3147b0f74653f7b836243a5c269 +Subproject commit 839fb9582b74ef55e596b4e71ddb5663e3ed7c77 diff --git a/MCServer/Plugins/ProtectionAreas b/MCServer/Plugins/ProtectionAreas index 3019c7b39..bef8ff2a8 160000 --- a/MCServer/Plugins/ProtectionAreas +++ b/MCServer/Plugins/ProtectionAreas @@ -1 +1 @@ -Subproject commit 3019c7b396221b987cd3f89d422276f764834ffe +Subproject commit bef8ff2a883e98db94f842f9db3d256a039b1fcd diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI index 52e1de433..678696eee 160000 --- a/MCServer/Plugins/TransAPI +++ b/MCServer/Plugins/TransAPI @@ -1 +1 @@ -Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e +Subproject commit 678696eeedce502199869577b8e03ff728926462 -- cgit v1.2.3 From 110c633c5fc17aa4d3a3b92f84ee93f9017d179b Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Tue, 8 Oct 2013 20:53:37 +0100 Subject: Some additional changes * Revert to Core:Call() - Removed variable --- MCServer/Plugins/MagicCarpet/coremessaging.lua | 23 +++++++---------------- MCServer/Plugins/MagicCarpet/plugin.lua | 2 -- 2 files changed, 7 insertions(+), 18 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/MagicCarpet/coremessaging.lua b/MCServer/Plugins/MagicCarpet/coremessaging.lua index 1677e8940..acf21df5b 100644 --- a/MCServer/Plugins/MagicCarpet/coremessaging.lua +++ b/MCServer/Plugins/MagicCarpet/coremessaging.lua @@ -1,28 +1,19 @@ -IniFile = cIniFile( "settings.ini" ) -IniFile:ReadFile() -UsePrefixes = IniFile:GetValueSet( "Messaging", "Prefixes", "true" ) -IniFile:WriteFile() +Core = cPluginManager:Get():GetPlugin("Core") function SendMessage(a_Player, a_Message) - if (UsePrefixes) then - a_Player:SendMessage(cChatColor.Yellow .. "[INFO] " .. cChatColor.White .. a_Message) - else - a_Player:SendMessage(cChatColor.Yellow .. a_Message) + if (Core ~= nil) then + Core:Call("SendMessage", a_Player, a_Message) end end function SendMessageSuccess(a_Player, a_Message) - if (UsePrefixes) then - a_Player:SendMessage(cChatColor.Green .. "[INFO] " .. cChatColor.White .. a_Message) - else - a_Player:SendMessage(cChatColor.Green .. a_Message) + if (Core ~= nil) then + Core:Call("SendMessageSuccess", a_Player, a_Message) end end function SendMessageFailure(a_Player, a_Message) - if (UsePrefixes) then - a_Player:SendMessage(cChatColor.Red .. "[INFO] " .. cChatColor.White .. a_Message) - else - a_Player:SendMessage(cChatColor.Red .. a_Message) + if (Core ~= nil) then + Core:Call("SendMessageFailure", a_Player, a_Message) end end \ No newline at end of file diff --git a/MCServer/Plugins/MagicCarpet/plugin.lua b/MCServer/Plugins/MagicCarpet/plugin.lua index 4a2097351..27efdab32 100644 --- a/MCServer/Plugins/MagicCarpet/plugin.lua +++ b/MCServer/Plugins/MagicCarpet/plugin.lua @@ -1,8 +1,6 @@ local Carpets = {} function Initialize( Plugin ) - PLUGIN = Plugin - Plugin:SetName( "MagicCarpet" ) Plugin:SetVersion( 2 ) -- cgit v1.2.3 From c03e44031168935d081c8986b433bac97d9fb8b8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 9 Oct 2013 10:02:07 +0200 Subject: APIDump: Taking advantage of the new cFile API. --- MCServer/Plugins/APIDump/main.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index aaeebecbb..92b0d150c 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -36,7 +36,6 @@ end - function DumpAPITxt() LOG("Dumping all available functions to API.txt..."); function dump (prefix, a, Output) @@ -177,18 +176,17 @@ function DumpAPIHtml() -- Read in the descriptions: ReadDescriptions(API); + -- Create the output folder + if not(cFile:IsFolder("API")) then + cFile:CreateFolder("API"); + end + -- Create a "class index" file, write each class as a link to that file, -- then dump class contents into class-specific file local f = io.open("API/index.html", "w"); if (f == nil) then - -- Create the output folder - os.execute("mkdir API"); - local err; - f, err = io.open("API/index.html", "w"); - if (f == nil) then - LOGINFO("Cannot output HTML API: " .. err); - return; - end + LOGINFO("Cannot output HTML API: " .. err); + return; end f:write([[MCServer API - class index -- cgit v1.2.3 From 27ce6dd97e3979a36318cea28e64c6a9029dbd99 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 9 Oct 2013 10:24:24 +0200 Subject: APIDump: Added support for extra pages. Referenced by file links and titles and copied directly from the plugin folder to the dest folder. --- MCServer/Plugins/APIDump/APIDesc.lua | 6 ++++ MCServer/Plugins/APIDump/WebWorldThreads.html | 8 ++++++ MCServer/Plugins/APIDump/main.lua | 41 +++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 MCServer/Plugins/APIDump/WebWorldThreads.html (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6578e6d8b..7bef7bcfd 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2063,6 +2063,12 @@ World:ForEachEntity( "ReadDescriptions", "WriteHtmlClass", }, + + ExtraPages = + { + -- No sorting is provided for these, they will be output in the same order as defined here + { FileName = "WebWorldThreads.html", Title = "Webserver vs World threads" }, + } } ; diff --git a/MCServer/Plugins/APIDump/WebWorldThreads.html b/MCServer/Plugins/APIDump/WebWorldThreads.html new file mode 100644 index 000000000..1a593ad8d --- /dev/null +++ b/MCServer/Plugins/APIDump/WebWorldThreads.html @@ -0,0 +1,8 @@ + + +Webserver vs World threads + + +This is a temporary test + + \ No newline at end of file diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 92b0d150c..5dd6c6f9e 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -9,6 +9,7 @@ -- Global variables: g_Plugin = nil; +g_PluginFolder = ""; @@ -22,6 +23,8 @@ function Initialize(Plugin) Plugin:SetVersion(1); LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) + + g_PluginFolder = Plugin:GetLocalFolder(); -- dump all available API functions and objects: -- DumpAPITxt(); @@ -189,9 +192,15 @@ function DumpAPIHtml() return; end - f:write([[MCServer API - class index + f:write([[MCServer API - index -

    MCServer API - class index

    +

    MCServer API - index

    +

    The API reference is divided into the following sections:

    +

    Class index

    The following classes are available in the MCServer Lua scripting language:

      ]]); @@ -199,7 +208,33 @@ function DumpAPIHtml() f:write("
    • " .. cls.Name .. "
    • \n"); WriteHtmlClass(cls, API); end - f:write("

    "); + f:write([[

    +

    Hooks

    +

    A plugin can register to be called whenever an “interesting event” occurs. It does so by calling + cPluginManager's AddHook() function and implementing a callback + function to handle the event.

    +

    A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it + from them. This is determined by the return value from the hook callback function. If the function returns + false or no value, the event is propagated further. If the function returns true, the processing is + stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior + for the event). See each hook's details to see the exact behavior.

    + + ]]); + -- TODO: Write out the hooks into a table + f:write([[
    Hook nameCalled when
    +

    Extra pages

    +

    The following pages provide various extra information

    +
      ]]); + for i, extra in ipairs(g_APIDesc.ExtraPages) do + if (cFile:Copy(g_PluginFolder .. "/" .. extra.FileName, "API/" .. extra.FileName)) then + f:write("
    • " .. extra.Title .. "
    • \n"); + else + f:write("
    • " .. extra.Title .. " (file is missing)
    • \n"); + end + end + f:write([[
    + + ]]); f:close(); -- Copy the CSS file to the output folder (overwrite any existing): -- cgit v1.2.3 From 9fc35514e64657f08929894c4ea4142daa81052d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 9 Oct 2013 11:31:38 +0200 Subject: APIDump: Documented the new cFile API functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7bef7bcfd..c41cac51b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -841,6 +841,30 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), }, }, + cFile = + { + Desc = [[ + Provides helper functions for manipulating and querying the filesystem. Most functions are called + directly on the cFile class itself: +
    +cFile:Delete("/usr/bin/virus.exe");
    +

    + ]], + + Functions = + { + Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, + CreateFolder = { Params = "FolderName", Return = "bool", Notes = "Creates a new folder. Returns true if successful." }, + Delete = { Params = "FileName", Return = "bool", Notes = "Deletes the specified file. Returns true if successful." }, + Exists = { Params = "FileName", Return = "bool", Notes = "Returns true if the specified file exists." }, + GetSize = { Params = "FileName", Return = "number", Notes = "Returns the size of the file, or -1 on failure." }, + IsFile = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing file." }, + IsFolder = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing folder." }, + Rename = { Params = "OrigPath, NewPath", Return = "bool", Notes = "Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists." }, + }, + + }, + cFireChargeEntity = { Desc = "", -- cgit v1.2.3 From 9dafba50157086ff952bff9cbba774334caf190a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 9 Oct 2013 15:10:25 +0200 Subject: APIDump: Implemented basic hook documentation. --- MCServer/Plugins/APIDump/APIDesc.lua | 34 ++++++++- MCServer/Plugins/APIDump/main.lua | 129 ++++++++++++++++++++++++++++++++--- 2 files changed, 152 insertions(+), 11 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index c41cac51b..33e1da976 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2055,6 +2055,33 @@ World:ForEachEntity( }, }, + + Hooks = + { + HOOK_CHAT = + { + CalledWhen = "Player sends a chat message", + DefaultFnName = "OnChat", -- also used as pagename + Desc = [[ + A plugin may implement an OnChat() function and register it as a Hook to process chat messages from + the players. The function is then called for every in-game message sent from any player. Note that + commands are handled separately using a command framework API. + ]], + Params = { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who sent the message" }, + { Name = "Message", Type = "string", Notes = "The message" }, + }, + Returns = [[ + The plugin may return 2 values. The first is a boolean specifying whether the hook handling is to be + stopped or not. If it is false, the message is broadcast to all players in the world. If it is true, + no message is broadcast and no further action is taken.

    +

    + The second value is specifies the message to broadcast. This way, plugins may modify the message. If + the second value is not provided, the original message is used. + ]], + }, -- HOOK_CHAT + }, -- Hooks[] + IgnoreClasses = { @@ -2080,12 +2107,15 @@ World:ForEachEntity( "%a+.delete", -- AnyClass.delete -- Functions global in the APIDump plugin: - "Initialize", - "DumpAPITxt", "CreateAPITables", "DumpAPIHtml", + "DumpAPITxt", + "Initialize", + "LinkifyString", "ReadDescriptions", + "ReadHooks", "WriteHtmlClass", + "WriteHtmlHook", }, ExtraPages = diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 5dd6c6f9e..6d4ac3d04 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -164,6 +164,8 @@ function DumpAPIHtml() LOG("Dumping all available functions and constants to API subfolder..."); local API, Globals = CreateAPITables(); + local Hooks = {}; + local UndocumentedHooks = {}; -- Sort the classes by name: table.sort(API, @@ -176,8 +178,21 @@ function DumpAPIHtml() Globals.Name = "Globals"; table.insert(API, Globals); + -- Extract hook constants: + for name, obj in pairs(cPluginManager) do + if (type(obj) == "number") and (name:match("HOOK_.*")) then + table.insert(Hooks, { Name = name }); + end + end + table.sort(Hooks, + function(Hook1, Hook2) + return (Hook1.Name < Hook2.Name); + end + ); + -- Read in the descriptions: ReadDescriptions(API); + ReadHooks(Hooks); -- Create the output folder if not(cFile:IsFolder("API")) then @@ -220,7 +235,16 @@ function DumpAPIHtml() for the event). See each hook's details to see the exact behavior.

    ]]); - -- TODO: Write out the hooks into a table + for i, hook in ipairs(Hooks) do + if (hook.DefaultFnName == nil) then + -- The hook is not documented yet + f:write("\n"); + table.insert(UndocumentedHooks, hook.Name); + else + f:write("\n"); + WriteHtmlHook(hook); + end + end f:write([[
    Hook nameCalled when
    " .. hook.Name .. "(No documentation yet)
    " .. hook.Name .. "" .. hook.CalledWhen .. "

    Extra pages

    The following pages provide various extra information

    @@ -286,6 +310,24 @@ function DumpAPIHtml() f:write("\t\t},\n\n"); end end -- for i, cls - API[] + f:write("\t},\n"); + + if (#UndocumentedHooks > 0) then + f:write("\n\tHooks =\n\t{\n"); + for i, hook in ipairs(UndocumentedHooks) do + if (i > 1) then + f:write("\n"); + end + f:write("\t\t" .. hook .. " =\n\t\t{\n"); + f:write("\t\t\tCalledWhen = \"\",\n"); + f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); + f:write("\t\t\tDesc = [[]],\n"); + f:write("\t\t\tParams =\n\t\t\t{\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\tReturns = [[]],\n"); + f:write("\t\t}, -- " .. hook .. "\n"); + end + end f:close(); end @@ -531,19 +573,46 @@ end +function ReadHooks(a_Hooks) + --[[ + a_Hooks = { + { Name = "HOOK_1"}, + { Name = "HOOK_2"}, + ... + }; + We want to add hook descriptions to each hook in this array + --]] + for i, hook in ipairs(a_Hooks) do + local HookDesc = g_APIDesc.Hooks[hook.Name]; + if (HookDesc ~= nil) then + for key, val in pairs(HookDesc) do + hook[key] = val; + end + end + end -- for i, hook - a_Hooks[] +end + + + + + +-- Make a link out of anything with the special linkifying syntax {{link|title}} +function LinkifyString(a_String) + local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", "%2") -- {{link|title}} + txt = txt:gsub("{{([^|}]*)}}", "%1") -- {{LinkAndTitle}} + return txt; +end + + + + + function WriteHtmlClass(a_ClassAPI, a_AllAPI) local cf, err = io.open("API/" .. a_ClassAPI.Name .. ".html", "w"); if (cf == nil) then return; end - -- Make a link out of anything with the special linkifying syntax {{link|title}} - local function LinkifyString(a_String) - local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", "%2") -- {{link|title}} - txt = txt:gsub("{{([^|}]*)}}", "%1") -- {{LinkAndTitle}} - return txt; - end - -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid local function WriteFunctions(a_Functions, a_InheritedName) if (#a_Functions == 0) then @@ -584,7 +653,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) CurrInheritance = CurrInheritance.Inherits; end - cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[ + cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[ class

    Contents

    @@ -664,3 +733,45 @@ end +function WriteHtmlHook(a_Hook) + local fnam = "API/" .. a_Hook.DefaultFnName .. ".html"; + local f, error = io.open(fnam, "w"); + if (f == nil) then + LOG("Cannot write \"" .. fnam .. "\": \"" .. error .. "\"."); + return; + end + f:write([[MCServer API - ]] .. a_Hook.DefaultFnName .. [[ hook + + +

    ]] .. a_Hook.Name .. [[ hook

    +

    + ]]); + f:write(LinkifyString(a_Hook.Desc)); + f:write("

    Callback function

    function " .. a_Hook.DefaultFnName .. "(");
    +	if (a_Hook.Params == nil) then
    +		a_Hook.Params = {};
    +	end
    +	for i, param in ipairs(a_Hook.Params) do
    +		if (i > 1) then
    +			f:write(", ");
    +		end
    +		f:write(param.Name);
    +	end
    +	f:write(")

    Parameters:\n\n"); + for i, param in ipairs(a_Hook.Params) do + f:write("\n"); + end + f:write("
    NameTypeNotes
    " .. param.Name .. "" .. LinkifyString(param.Type) .. "" .. LinkifyString(param.Notes) .. "

    \n

    " .. (a_Hook.Returns or "") .. "

    \n"); + f:write([[

    Code examples

    +

    Registering the callback

    +
    +cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);
    +
    + ]]); + -- TODO: Other code examples + f:close(); +end + + + + -- cgit v1.2.3 From 9deb9cfa0e3c79ed1ff1fbc702d84a61cba0f6d8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 9 Oct 2013 15:56:24 +0200 Subject: APIDump: Fixed extra pages copying. --- MCServer/Plugins/APIDump/main.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 6d4ac3d04..bb8de1d1b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -250,7 +250,13 @@ function DumpAPIHtml()

    The following pages provide various extra information

      ]]); for i, extra in ipairs(g_APIDesc.ExtraPages) do - if (cFile:Copy(g_PluginFolder .. "/" .. extra.FileName, "API/" .. extra.FileName)) then + local SrcFileName = g_PluginFolder .. "/" .. extra.FileName; + if (cFile:Exists(SrcFileName)) then + local DstFileName = "API/" .. extra.FileName; + if (cFile:Exists(DstFileName)) then + cFile:Delete(DstFileName); + end + cFile:Copy(SrcFileName, DstFileName); f:write("
    • " .. extra.Title .. "
    • \n"); else f:write("
    • " .. extra.Title .. " (file is missing)
    • \n"); -- cgit v1.2.3 From 990fa9dfe1f60728979896262da1d4d45a3d05a3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 11:44:59 +0200 Subject: APIDump: Hook notes are linkified. --- MCServer/Plugins/APIDump/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index bb8de1d1b..9865f4cf1 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -241,7 +241,7 @@ function DumpAPIHtml() f:write("" .. hook.Name .. "(No documentation yet)\n"); table.insert(UndocumentedHooks, hook.Name); else - f:write("" .. hook.Name .. "" .. hook.CalledWhen .. "\n"); + f:write("" .. hook.Name .. "" .. LinkifyString(hook.CalledWhen) .. "\n"); WriteHtmlHook(hook); end end -- cgit v1.2.3 From 50e5afd67da8d0b004193f86fa8023c015d64ea7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 11:46:00 +0200 Subject: APIDump: Documented OnBlockToPickups. --- MCServer/Plugins/APIDump/APIDesc.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 33e1da976..513af7816 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2058,6 +2058,36 @@ World:ForEachEntity( Hooks = { + HOOK_BLOCK_TO_PICKUPS = + { + CalledWhen = "A block is about to be dug ({{cPlayer|player}}, {{cEntity|entity}} or natural reason), plugins may override what pickups that will produce.", + DefaultFnName = "OnBlockToPickups", -- also used as pagename + Desc = [[ + This callback gets called whenever a block is about to be dug. This includes {{cPlayer|players}} + digging blocks, entities causing blocks to disappear ({{cTNTEntity|TNT}}, Endermen) and natural + causes (water washing away a block). Plugins may override the amount and kinds of pickups this + action produces. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" }, + { Name = "Digger", Type = "{{cEntity}} descendant", Notes = "The entitycausing the digging. May be a {{cPlayer}}, {{cTNTEntity}} or even nil (natural causes)" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "Block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "Block meta of the block" }, + { Name = "Pickups", Type = "{{cItems}}", Notes = "Items that will be spawned as pickups" }, + }, + Returns = [[ + If the function returns false or no value, the next callback in the hook chain will be called. If + the function returns true, no other callbacks in the chain will be called.

      +

      + Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable + pickups, you need to Clear the object first, then return true. + ]], + }, -- HOOK_BLOCK_TO_PICKUPS + HOOK_CHAT = { CalledWhen = "Player sends a chat message", -- cgit v1.2.3 From dff343b792d2b6a65aab96ee324c0ac6b9013123 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 18:11:14 +0200 Subject: APIDump: Added the possibility of extra code examples for hooks. --- MCServer/Plugins/APIDump/main.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 9865f4cf1..1ba9397f5 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -753,7 +753,8 @@ function WriteHtmlHook(a_Hook)

      ]]); f:write(LinkifyString(a_Hook.Desc)); - f:write("

      Callback function

      function " .. a_Hook.DefaultFnName .. "(");
      +	f:write("

      Callback function

      The default name for the callback function is "); + f:write(a_Hook.DefaultFnName .. ". It has the following signature:

      function " .. a_Hook.DefaultFnName .. "(");
       	if (a_Hook.Params == nil) then
       		a_Hook.Params = {};
       	end
      @@ -774,7 +775,12 @@ function WriteHtmlHook(a_Hook)
       cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);
       
      ]]); - -- TODO: Other code examples + local Examples = a_Hook.CodeExamples or {}; + for i, example in ipairs(Examples) do + f:write("

      " .. example.Title .. "

      \n"); + f:write("

      " .. example.Desc .. "

      \n"); + f:write("
      " .. example.Code .. "
      \n"); + end f:close(); end -- cgit v1.2.3 From 9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 18:29:06 +0200 Subject: APIDump: Added an OnBlockToPickups() code example. --- MCServer/Plugins/APIDump/APIDesc.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 513af7816..78ae4be1e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2086,6 +2086,32 @@ World:ForEachEntity( Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable pickups, you need to Clear the object first, then return true. ]], + CodeExamples = + { + { + Title = "Modify pickups", + Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).", + Code = [[ +function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups) + if (a_Digger ~= nil) then + -- Not a natural cause + return false; + end + if (a_BlockType ~= E_BLOCK_TALL_GRASS) then + -- Not a tall grass being washed away + return false; + end + + -- Remove all pickups suggested by MCServer: + a_Pickups:Clear(); + + -- Drop a diamond: + a_Pickups:Add(cItem(E_ITEM_DIAMOND)); + return true; +end; + ]], + }, + } , -- CodeExamples }, -- HOOK_BLOCK_TO_PICKUPS HOOK_CHAT = -- cgit v1.2.3 From 82834ee1ed17ba542049d583ad3ebde2ace22025 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 18:31:55 +0200 Subject: APIDump: Added pretty-printing to code examples. --- MCServer/Plugins/APIDump/APIDesc.lua | 54 ++++++++++++++++++------------------ MCServer/Plugins/APIDump/main.lua | 11 ++++++-- 2 files changed, 35 insertions(+), 30 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 78ae4be1e..dc04d3e81 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -404,7 +404,7 @@ g_APIDesc = Contents = [[ The following example code sets the top-left item of each chest in the same chunk as Player to 64 * diamond: -
      +
       -- Player is a {{cPlayer}} object instance
       local World = Player:GetWorld();
       World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
      @@ -846,7 +846,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
       			Desc = [[
       				Provides helper functions for manipulating and querying the filesystem. Most functions are called
       				directly on the cFile class itself:
      -
      +
       cFile:Delete("/usr/bin/virus.exe");
       

      ]], @@ -1248,7 +1248,7 @@ aborted and Trace() returns false.

      The following example is taken from the Debuggers plugin. It is a command handler function for the "/spidey" command that creates a line of cobweb blocks from the player's eyes up to 50 blocks away in the direction they're looking, but only through the air. -

      +
       function HandleSpideyCmd(a_Split, a_Player)
       	local World = a_Player:GetWorld();
       
      @@ -1315,7 +1315,7 @@ end
       					Header = "OnClosing Callback",
       					Contents = [[
       						This callback, settable via the SetOnClosing() function, will be called when the player tries to close the window, or the window is closed for any other reason (such as a player disconnecting).

      -
      +
       function OnWindowClosing(a_Window, a_Player, a_CanRefuse)
       

      @@ -1326,7 +1326,7 @@ function OnWindowClosing(a_Window, a_Player, a_CanRefuse) Header = "OnSlotChanged Callback", Contents = [[ This callback, settable via the SetOnSlotChanged() function, will be called whenever the contents of any slot in the window's contents (i. e. NOT in the player inventory!) changes.

      -
      +
       function OnWindowSlotChanged(a_Window, a_SlotNum)
       

      The a_Window parameter is the cLuaWindow object representing the window, a_SlotNum is the slot number. There is no reference to a {{cPlayer}}, because the slot change needn't originate from the player action. To get or set the slot, you'll need to retrieve a cPlayer object, for example by calling {{cWorld|cWorld}}:DoWithPlayer(). @@ -1338,7 +1338,7 @@ function OnWindowSlotChanged(a_Window, a_SlotNum) Header = "Example", Contents = [[ This example is taken from the Debuggers plugin, used to test the API functionality. It opens a window and refuse to close it 3 times. It also logs slot changes to the server console. -

      +
       -- Callback that refuses to close the window twice, then allows:
       local Attempt = 1;
       local OnClosing = function(Window, Player, CanRefuse)
      @@ -1494,7 +1494,7 @@ a_Player:OpenWindow(Window);
       				

      Note that some functions are "static", that means that they are called using a dot operator instead of the colon operator. For example: -

      +
       cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
       

      ]], @@ -1520,8 +1520,8 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); ExecuteConsoleCommand = { Params = "CommandStr", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, - ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:
      function(Command, Permission, HelpString)
      . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, - ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature:
      function (Command, HelpString)
      . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, + ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:
      function(Command, Permission, HelpString)
      . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, + ForEachConsoleCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindConsoleCommand(). The CallbackFn has the following signature:
      function (Command, HelpString)
      . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, Get = { Params = "", Return = "cPluginManager", Notes = "Returns the single instance of the plugin manager" }, GetAllPlugins = { Params = "", Return = "table", Notes = "Returns a table (dictionary) of all plugins, [name => {{cPlugin}}] pairing." }, GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" }, @@ -1605,8 +1605,8 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Get = { Params = "", Return = "Root object", Notes = "This function returns the cRoot object." }, BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server." }, FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player." }, - ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature:
      function Callback({{cPlayer|cPlayer}})
      " }, - ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature:
      function Callback({{cWorld|cWorld}})
      " }, + ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature:
      function Callback({{cPlayer|cPlayer}})
      " }, + ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature:
      function Callback({{cWorld|cWorld}})
      " }, GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" }, GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." }, GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object." }, @@ -1800,24 +1800,24 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa CreateProjectile = { Params = "X, Y, Z, {{cProjectile|ProjectileKind}}, {{cEntity|Creator}}, [{{Vector3d|Speed}}]", Return = "", Notes = "Creates a new projectile of the specified kind at the specified coords. The projectile's creator is set to Creator (may be nil). Optional speed indicates the initial speed for the projectile." }, DigBlock = { Params = "X, Y, Z", Return = "", Notes = "Replaces the specified block with air, without dropping the usual pickups for the block. Wakes up the simulators for the block and its neighbors." }, DoExplosionAt = { Params = "Force, X, Y, Z, CanCauseFire, Source, SourceData", Return = "", Notes = "Creates an explosion of the specified relative force in the specified position. If CanCauseFire is set, the explosion will set blocks on fire, too. The Source parameter specifies the source of the explosion, one of the esXXX constants. The SourceData parameter is specific to each source type, usually it provides more info about the source." }, - DoWithChestAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a chest at the specified coords, calls the CallbackFunction with the {{cChestEntity}} parameter representing the chest. The CallbackFunction has the following signature:
      function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
      The function returns false if there is no chest, or if there is, it returns the bool value that the callback has returned." }, - DoWithDispenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dispenser at the specified coords, calls the CallbackFunction with the {{cDispenserEntity}} parameter representing the dispenser. The CallbackFunction has the following signature:
      function Callback({{cDispenserEntity|DispenserEntity}}, [CallbackData])
      The function returns false if there is no dispenser, or if there is, it returns the bool value that the callback has returned." }, - DoWithDropSpenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper or a dispenser at the specified coords, calls the CallbackFunction with the {{cDropSpenserEntity}} parameter representing the dropper or dispenser. The CallbackFunction has the following signature:
      function Callback({{cDropSpenserEntity|DropSpenserEntity}}, [CallbackData])
      Note that this can be used to access both dispensers and droppers in a similar way. The function returns false if there is neither dispenser nor dropper, or if there is, it returns the bool value that the callback has returned." }, - DoWithDropperAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper at the specified coords, calls the CallbackFunction with the {{cDropperEntity}} parameter representing the dropper. The CallbackFunction has the following signature:
      function Callback({{cDropperEntity|DropperEntity}}, [CallbackData])
      The function returns false if there is no dropper, or if there is, it returns the bool value that the callback has returned." }, - DoWithEntityByID = { Params = "EntityID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If an entity with the specified ID exists, calls the callback with the {{cEntity}} parameter representing the entity. The CallbackFunction has the following signature:
      function Callback({{cEntity|Entity}}, [CallbackData])
      The function returns false if the entity was not found, and it returns the same bool value that the callback has returned if the entity was found." }, - DoWithFurnaceAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a furnace at the specified coords, calls the CallbackFunction with the {{cFurnaceEntity}} parameter representing the furnace. The CallbackFunction has the following signature:
      function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
      The function returns false if there is no furnace, or if there is, it returns the bool value that the callback has returned." }, - DoWithPlayer = { Params = "PlayerName, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of the specified name (exact match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
      function Callback({{cPlayer|Player}}, [CallbackData])
      The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." }, + DoWithChestAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a chest at the specified coords, calls the CallbackFunction with the {{cChestEntity}} parameter representing the chest. The CallbackFunction has the following signature:
      function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
      The function returns false if there is no chest, or if there is, it returns the bool value that the callback has returned." }, + DoWithDispenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dispenser at the specified coords, calls the CallbackFunction with the {{cDispenserEntity}} parameter representing the dispenser. The CallbackFunction has the following signature:
      function Callback({{cDispenserEntity|DispenserEntity}}, [CallbackData])
      The function returns false if there is no dispenser, or if there is, it returns the bool value that the callback has returned." }, + DoWithDropSpenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper or a dispenser at the specified coords, calls the CallbackFunction with the {{cDropSpenserEntity}} parameter representing the dropper or dispenser. The CallbackFunction has the following signature:
      function Callback({{cDropSpenserEntity|DropSpenserEntity}}, [CallbackData])
      Note that this can be used to access both dispensers and droppers in a similar way. The function returns false if there is neither dispenser nor dropper, or if there is, it returns the bool value that the callback has returned." }, + DoWithDropperAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper at the specified coords, calls the CallbackFunction with the {{cDropperEntity}} parameter representing the dropper. The CallbackFunction has the following signature:
      function Callback({{cDropperEntity|DropperEntity}}, [CallbackData])
      The function returns false if there is no dropper, or if there is, it returns the bool value that the callback has returned." }, + DoWithEntityByID = { Params = "EntityID, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If an entity with the specified ID exists, calls the callback with the {{cEntity}} parameter representing the entity. The CallbackFunction has the following signature:
      function Callback({{cEntity|Entity}}, [CallbackData])
      The function returns false if the entity was not found, and it returns the same bool value that the callback has returned if the entity was found." }, + DoWithFurnaceAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a furnace at the specified coords, calls the CallbackFunction with the {{cFurnaceEntity}} parameter representing the furnace. The CallbackFunction has the following signature:
      function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
      The function returns false if there is no furnace, or if there is, it returns the bool value that the callback has returned." }, + DoWithPlayer = { Params = "PlayerName, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of the specified name (exact match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
      function Callback({{cPlayer|Player}}, [CallbackData])
      The function returns false if the player was not found, or whatever bool value the callback returned if the player was found." }, FastSetBlock = { { Params = "X, Y, Z, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, { Params = "{{Vector3i|BlockCoords}}, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, }, - FindAndDoWithPlayer = { Params = "PlayerNameHint, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of a name similar to the specified name (weighted-match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
      function Callback({{cPlayer|Player}}, [CallbackData])
      The function returns false if the player was not found, or whatever bool value the callback returned if the player was found. Note that the name matching is very loose, so it is a good idea to check the player name in the callback function." }, - ForEachChestInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
      function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
      The callback should return false or no value to continue with the next chest, or true to abort the enumeration." }, - ForEachEntity = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
      function Callback({{cEntity|Entity}}, [CallbackData])
      The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, - ForEachEntityInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the specified chunk. Returns true if all the entities have been processed (including when there are zero entities), or false if the chunk is not loaded or the callback function has aborted the enumeration by returning true. The callback function has the following signature:
      function Callback({{cEntity|Entity}}, [CallbackData])
      The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, - ForEachFurnaceInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each furnace in the chunk. Returns true if all furnaces in the chunk have been processed (including when there are zero furnaces), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
      function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
      The callback should return false or no value to continue with the next furnace, or true to abort the enumeration." }, - ForEachPlayer = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each player in the loaded world. Returns true if all the players have been processed (including when there are zero players), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
      function Callback({{cPlayer|Player}}, [CallbackData])
      The callback should return false or no value to continue with the next player, or true to abort the enumeration." }, + FindAndDoWithPlayer = { Params = "PlayerNameHint, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of a name similar to the specified name (weighted-match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
      function Callback({{cPlayer|Player}}, [CallbackData])
      The function returns false if the player was not found, or whatever bool value the callback returned if the player was found. Note that the name matching is very loose, so it is a good idea to check the player name in the callback function." }, + ForEachChestInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
      function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
      The callback should return false or no value to continue with the next chest, or true to abort the enumeration." }, + ForEachEntity = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
      function Callback({{cEntity|Entity}}, [CallbackData])
      The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, + ForEachEntityInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the specified chunk. Returns true if all the entities have been processed (including when there are zero entities), or false if the chunk is not loaded or the callback function has aborted the enumeration by returning true. The callback function has the following signature:
      function Callback({{cEntity|Entity}}, [CallbackData])
      The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, + ForEachFurnaceInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each furnace in the chunk. Returns true if all furnaces in the chunk have been processed (including when there are zero furnaces), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
      function Callback({{cFurnaceEntity|FurnaceEntity}}, [CallbackData])
      The callback should return false or no value to continue with the next furnace, or true to abort the enumeration." }, + ForEachPlayer = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each player in the loaded world. Returns true if all the players have been processed (including when there are zero players), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
      function Callback({{cPlayer|Player}}, [CallbackData])
      The callback should return false or no value to continue with the next player, or true to abort the enumeration." }, GenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk in the chunk generator. Ignored if the chunk is already generated (use RegenerateChunk() to force chunk re-generation)." }, GetBiomeAt = { Params = "BlockX, BlockZ", Return = "eBiome", Notes = "Returns the biome at the specified coords. Reads the biome from the chunk, if it is loaded, otherwise it uses the chunk generator to provide the biome value." }, GetBlock = @@ -1924,7 +1924,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa The following code examples show how to use the callbacks

      This code teleports player Player to another player named ToName in the same world: -

      +
       -- Player is a cPlayer object
       -- ToName is a string
       -- World is a cWorld object
      @@ -1937,7 +1937,7 @@ World:ForEachPlayer(
       

      This code fills each furnace in the chunk with 64 coals: -

      +
       -- Player is a cPlayer object
       -- World is a cWorld object
       World:ForEachFurnaceInChunk(Player:GetChunkX(), Player:GetChunkZ(),
      @@ -1948,7 +1948,7 @@ World:ForEachFurnaceInChunk(Player:GetChunkX(), Player:GetChunkZ(),
       

      This code teleports all spiders up by 100 blocks: -

      +
       -- World is a cWorld object
       World:ForEachEntity(
       	function (a_Entity)
      diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua
      index 1ba9397f5..3827668e3 100644
      --- a/MCServer/Plugins/APIDump/main.lua
      +++ b/MCServer/Plugins/APIDump/main.lua
      @@ -661,6 +661,8 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
       	
       	cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[ class
       	
      +	
      +	
       	
       	

      Contents

        @@ -748,13 +750,16 @@ function WriteHtmlHook(a_Hook) end f:write([[MCServer API - ]] .. a_Hook.DefaultFnName .. [[ hook + +

        ]] .. a_Hook.Name .. [[ hook

        ]]); f:write(LinkifyString(a_Hook.Desc)); f:write("

        Callback function

        The default name for the callback function is "); - f:write(a_Hook.DefaultFnName .. ". It has the following signature:

        function " .. a_Hook.DefaultFnName .. "(");
        +	f:write(a_Hook.DefaultFnName .. ". It has the following signature:");
        +	f:write("
        function " .. a_Hook.DefaultFnName .. "(");
         	if (a_Hook.Params == nil) then
         		a_Hook.Params = {};
         	end
        @@ -771,7 +776,7 @@ function WriteHtmlHook(a_Hook)
         	f:write("

        \n

        " .. (a_Hook.Returns or "") .. "

        \n"); f:write([[

        Code examples

        Registering the callback

        -
        +
         cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);
         
        ]]); @@ -779,7 +784,7 @@ cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.Defa for i, example in ipairs(Examples) do f:write("

        " .. example.Title .. "

        \n"); f:write("

        " .. example.Desc .. "

        \n"); - f:write("
        " .. example.Code .. "
        \n"); + f:write("
        " .. example.Code .. "
        \n"); end f:close(); end -- cgit v1.2.3 From 058faa74d2ff0a1332bf153c75922289b625a2de Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 12 Oct 2013 23:13:09 +0200 Subject: APIDump: Documented the webserver vs world threads. This fixes #12. --- MCServer/Plugins/APIDump/WebWorldThreads.html | 60 ++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/WebWorldThreads.html b/MCServer/Plugins/APIDump/WebWorldThreads.html index 1a593ad8d..a77209b0b 100644 --- a/MCServer/Plugins/APIDump/WebWorldThreads.html +++ b/MCServer/Plugins/APIDump/WebWorldThreads.html @@ -1,8 +1,64 @@ -Webserver vs World threads +MCServer - Webserver vs World threads + + -This is a temporary test + +

        Webserver vs World threads

        +

        +This article will explain the threading issues that arise between the webserver and world threads are of concern to plugin authors.

        +

        +Generally, plugins that provide webadmin pages should be quite careful about their interactions. Most operations on MCServer objects requires synchronization, that MCServer provides automatically and transparently to plugins - when a block is written, the chunkmap is locked, or when an entity is being manipulated, the entity list is locked. Each plugin also has a mutex lock, so that only one thread at a time may be executing plugin code.

        +

        +This locking can be a source of deadlocks for plugins that are not written carefully.

        + +

        Example scenario

        +

        Consider the following example. A plugin provides a webadmin page that allows the admin to kick players off the server. When the admin presses the "Kick" button, the plugin calls cWorld:DoWithPlayer() with a callback to kick the player. Everything seems to be working fine now.

        +

        +A new feature is developed in the plugin, now the plugin adds a new in-game command so that the admins can kick players while they're playing the game. The plugin registers a command callback with cPluginManager.AddCommand(). Now there are problems bound to happen.

        +

        +Suppose that two admins are in, one is using the webadmin and the other is in-game. Both try to kick a player at the same time. The webadmin locks the plugin, so that it can execute the plugin code, but right at this moment the OS switches threads. The world thread locks the world so that it can access the list of in-game commands, receives the in-game command, it tries to lock the plugin. The plugin is already locked, so the world thread is put on hold. After a while, the webadmin thread is woken up again and continues processing. It tries to lock the world so that it can traverse the playerlist, but the lock is already held by the world thread. Now both threads are holding one lock each and trying to grab the other lock, and are therefore deadlocked.

        + +

        How to avoid the deadlock

        +

        +There are two main ways to avoid such a deadlock. The first approach is using tasks: Everytime you need to execute a task inside a world, instead of executing it, queue it, using cWorld:QueueTask(). This handy utility can will call the given function inside the world's TickThread, thus eliminating the deadlock, because now there's only one thread. However, this approach will not let you get data back. You cannot query the player list, or the entities, or anything - because when the task runs, the webadmin page has already been served to the browser.

        +

        +To accommodate this, you'll need to use the second approach - preparing and caching data in the tick thread, possibly using callbacks. This means that the plugin will have global variables that will store the data, and update those variables when the data changes; then the webserver thread will only read those variables, instead of calling the world functions. For example, if a webpage was to display the list of currently connected players, the plugin should maintain a global variable, g_WorldPlayers, which would be a table of worlds, each item being a list of currently connected players. The webadmin handler would read this variable and create the page from it; the plugin would use HOOK_PLAYER_JOINED and HOOK_DISCONNECT to update the variable.

        + +

        What to avoid

        +

        +Now that we know what the danger is and how to avoid it, how do we know if our code is susceptible?

        +

        +The general rule of thumb is to avoid calling any functions that read or write lists of things in the webserver thread. This means most ForEach() and DoWith() functions. Only cRoot:ForEachWorld() is safe - because the list of worlds is not expected to change, so it is not guarded by a mutex. Getting and setting world's blocks is, naturally, unsafe, as is calling other plugins, or creating entities.

        + +

        Example

        +The Core has the facility to kick players using the web interface. It used the following code for the kicking (inside the webadmin handler): +
        +local KickPlayerName = Request.Params["players-kick"]
        +local FoundPlayerCallback = function(Player)
        +  if (Player:GetName() == KickPlayerName) then
        +    Player:GetClientHandle():Kick("You were kicked from the game!")
        +  end
        +end
        +cRoot:Get():FindAndDoWithPlayer(KickPlayerName, FoundPlayerCallback)
        +
        +The cRoot:FindAndDoWithPlayer() is unsafe and could have caused a deadlock. The new solution is queue a task; but since we don't know in which world the player is, we need to queue the task to all worlds: +
        +cRoot:Get():ForEachWorld(    -- For each world...
        +  function(World)
        +    World:QueueTask(         -- ... queue a task...
        +      function(a_World)
        +        a_World:DoWithPlayer(KickPlayerName,  -- ... to walk the playerlist...
        +          function (a_Player)
        +            a_Player:GetClientHandle():Kick("You were kicked from the game!")  -- ... and kick the player
        +          end
        +        )
        +      end
        +    )
        +  end
        +)
        +
        \ No newline at end of file -- cgit v1.2.3 From 9faf4ef17891e99193b603960f0b680f57793f24 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Sun, 13 Oct 2013 17:36:57 +0100 Subject: Merge submodule changes --- MCServer/Plugins/Core | 2 +- MCServer/Plugins/ProtectionAreas | 2 +- MCServer/Plugins/TransAPI | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 839fb9582..e3a45f343 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 839fb9582b74ef55e596b4e71ddb5663e3ed7c77 +Subproject commit e3a45f34303331be77aceacf2ba53e503ad7284f diff --git a/MCServer/Plugins/ProtectionAreas b/MCServer/Plugins/ProtectionAreas index bef8ff2a8..3019c7b39 160000 --- a/MCServer/Plugins/ProtectionAreas +++ b/MCServer/Plugins/ProtectionAreas @@ -1 +1 @@ -Subproject commit bef8ff2a883e98db94f842f9db3d256a039b1fcd +Subproject commit 3019c7b396221b987cd3f89d422276f764834ffe diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI index 678696eee..52e1de433 160000 --- a/MCServer/Plugins/TransAPI +++ b/MCServer/Plugins/TransAPI @@ -1 +1 @@ -Subproject commit 678696eeedce502199869577b8e03ff728926462 +Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e -- cgit v1.2.3 From 9d7e638aa2f0aa2528c3bf230b791159a62354e6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 09:00:28 +0200 Subject: APIDump: Documented HOOK_CHUNK_AVAILABLE. --- MCServer/Plugins/APIDump/APIDesc.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index dc04d3e81..de25dd761 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2136,6 +2136,27 @@ end; the second value is not provided, the original message is used. ]], }, -- HOOK_CHAT + + HOOK_CHUNK_AVAILABLE = + { + CalledWhen = "A chunk has just been added to world, either generated or loaded. ", + DefaultFnName = "OnChunkAvailable", -- also used as pagename + Desc = [[ + This hook is called after a chunk is either generated or loaded from the disk. The chunk is + already available for manipulation using the {{cWorld}} API. This is a notification-only callback, + there is no behavior that plugins could override. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk belongs" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_CHUNK_AVAILABLE }, -- Hooks[] -- cgit v1.2.3 From 26fbefdcbf55d881cc28d43da24192f5d4fb8e9f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 09:03:54 +0200 Subject: APIDump: The undocumented hooks template now has 8 params. This allows for easier copypasting, hooks with less than 9 params don't need an extra copy-paste for a new param entry. --- MCServer/Plugins/APIDump/main.lua | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 3827668e3..b4208d208 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -330,6 +330,13 @@ function DumpAPIHtml() f:write("\t\t\tDesc = [[]],\n"); f:write("\t\t\tParams =\n\t\t\t{\n"); f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); f:write("\t\t\tReturns = [[]],\n"); f:write("\t\t}, -- " .. hook .. "\n"); end -- cgit v1.2.3 From 23b4aa48201783dc26816d9df58c3cf66ce2737b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 09:10:33 +0200 Subject: APIDump: Documented HOOK_CHUNK_GENERATED. --- MCServer/Plugins/APIDump/APIDesc.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index de25dd761..03d90a8fb 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2157,6 +2157,32 @@ end; returns true, no other callback is called for this event. ]], }, -- HOOK_CHUNK_AVAILABLE + + HOOK_CHUNK_GENERATED = + { + CalledWhen = "After a chunk was generated. Notification only.", + DefaultFnName = "OnChunkGenerated", -- also used as pagename + Desc = [[ + This hook is called when world generator finished its work on a chunk. The chunk data has already + been generated and is about to be stored in the {{cWorld|world}}. A plugin may provide some + last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the + world, so regular {{cWorld}} block API will not work! Instead, use the {{cChunkDesc}} object + received as the parameter. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data. Plugins may still modify the chunk data contained." }, + }, + Returns = [[ + If the plugin returns false or no value, MCServer will call other plugins' callbacks for this event. + If a plugin returns true, no other callback is called for this event.

        +

        + In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world. + ]], + }, -- HOOK_CHUNK_GENERATED }, -- Hooks[] -- cgit v1.2.3 From 8f5ed6511a958a1ed66cbbdfd5939f224475bb05 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 09:30:13 +0200 Subject: APIDump: Added example to HOOK_CHUNK_GENERATED. --- MCServer/Plugins/APIDump/APIDesc.lua | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 03d90a8fb..586c3ae03 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2182,6 +2182,43 @@ end;

        In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world. ]], + CodeExamples = + { + { + Title = "Generate emerald ore", + Desc = "This example callback function generates one block of emerald ore in each chunk, under the condition that the randomly chosen location is in an ExtremeHills biome.", + Code = [[ +function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) + -- Generate a psaudorandom value that is always the same for the same X/Z pair, but is otherwise random enough: + -- This is actually similar to how MCServer does its noise functions + local PseudoRandom = (a_ChunkX * 57 + a_ChunkZ) * 57 + 19785486 + PseudoRandom = PseudoRandom * 8192 + PseudoRandom; + PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff; + PseudoRandom = PseudoRandom / 7; + + -- Based on the PseudoRandom value, choose a location for the ore: + local OreX = PseudoRandom % 16; + local OreY = 2 + ((PseudoRandom / 16) % 20); + local OreZ = (PseudoRandom / 320) % 16; + + -- Check if the location is in ExtremeHills: + if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then + return false; + end + + -- Only replace allowed blocks with the ore: + local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ); + if ( + (CurrBlock == E_BLOCK_STONE) or + (CurrBlock == E_BLOCK_DIRT) or + (CurrBlock == E_BLOCK_GRAVEL) + ) then + a_ChunkDesc:SetBlockTypeMeta(OreX, OreY, OreZ, E_BLOCK_EMERALD_ORE, 0); + end +end; + ]], + }, + } , -- CodeExamples }, -- HOOK_CHUNK_GENERATED }, -- Hooks[] -- cgit v1.2.3 From 42b65c164d0979494dd7bfea214434f912c2f4e3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 09:32:55 +0200 Subject: APIDump: Fixed undocumented hook param generator. --- MCServer/Plugins/APIDump/main.lua | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index b4208d208..87583be0e 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -329,14 +329,15 @@ function DumpAPIHtml() f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); f:write("\t\t\tDesc = [[]],\n"); f:write("\t\t\tParams =\n\t\t\t{\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n\t\t\t},\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t},\n"); f:write("\t\t\tReturns = [[]],\n"); f:write("\t\t}, -- " .. hook .. "\n"); end -- cgit v1.2.3 From fb209757f0ad3c19f2925af00ac323236fd86741 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 09:41:06 +0200 Subject: APIDump: Documented HOOK_CHUNK_GENERATING. --- MCServer/Plugins/APIDump/APIDesc.lua | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 586c3ae03..578d6aeab 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2167,7 +2167,9 @@ end; been generated and is about to be stored in the {{cWorld|world}}. A plugin may provide some last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the world, so regular {{cWorld}} block API will not work! Instead, use the {{cChunkDesc}} object - received as the parameter. + received as the parameter.

        +

        + See also the {{OnChunkGenerating|HOOK_CHUNK_GENERATING}} hook. ]], Params = { @@ -2220,6 +2222,36 @@ end; }, } , -- CodeExamples }, -- HOOK_CHUNK_GENERATED + + HOOK_CHUNK_GENERATING = + { + CalledWhen = "A chunk is about to be generated. Plugin can override the built-in generator.", + DefaultFnName = "OnChunkGenerating", -- also used as pagename + Desc = [[ + This hook is called before the world generator starts generating a chunk. The plugin may provide + some or all parts of the generation, by-passing the built-in generator. The function is given access + to the {{cChunkDesc|ChunkDesc}} object representing the contents of the chunk. It may override parts + of the built-in generator by using the object's SetUseDefaultXXX(false) functions. After all + the callbacks for a chunk have been processed, the server will generate the chunk based on the + {{cChunkDesc|ChunkDesc}} description - those parts that are set for generating (by default + everything) are generated, the rest are read from the ChunkDesc object.

        +

        + See also the {{OnChunkGenerated|HOOK_CHUNK_GENERATED}} hook. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data." }, + }, + Returns = [[ + If this function returns true, the server will not call any other plugin with the same chunk. If + this function returns false, the server will call the rest of the plugins with the same chunk, + possibly overwriting the ChunkDesc's contents. + ]], + }, -- HOOK_CHUNK_GENERATING + }, -- Hooks[] -- cgit v1.2.3 From 37ea7ec0c1e9b278a53d0cc1485e216099ea1eee Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 15:46:01 +0200 Subject: APIDump: Documented HOOK_CHUNK_UNLOADED. --- MCServer/Plugins/APIDump/APIDesc.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 578d6aeab..6be0b6887 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2252,6 +2252,28 @@ end; ]], }, -- HOOK_CHUNK_GENERATING + HOOK_CHUNK_UNLOADED = + { + CalledWhen = "A chunk has been unloaded from the memory.", + DefaultFnName = "OnChunkUnloaded", -- also used as pagename + Desc = [[ + This hook is called when a chunk is unloaded from the memory. Though technically still in memory, + the plugin should behave as if the chunk was already not present. In particular, {{cWorld}} block + API should not be used in the area of the specified chunk. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no behavior that plugins could + override. + ]], + }, -- HOOK_CHUNK_UNLOADED + }, -- Hooks[] -- cgit v1.2.3 From 0b71b3bd141816869eb19b3a9841a8d16f5e4be9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 15:50:11 +0200 Subject: APIDump: Documented HOOK_CHUNK_UNLOADING. --- MCServer/Plugins/APIDump/APIDesc.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6be0b6887..013b3c69e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2274,6 +2274,29 @@ end; ]], }, -- HOOK_CHUNK_UNLOADED + HOOK_CHUNK_UNLOADING = + { + CalledWhen = " A chunk is about to be unloaded from the memory. Plugins may refuse the unload.", + DefaultFnName = "OnChunkUnloading", -- also used as pagename + Desc = [[ + MCServer calls this function when a chunk is about to be unloaded from the memory. A plugin may + force MCServer to keep the chunk in memory by returning true.

        +

        + FIXME: The return value should be used only for event propagation stopping, not for the actual + decision whether to unload. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called and finally MCServer + unloads the chunk. If the function returns true, no other callback is called for this event and the + chunk is left in the memory. + ]], + }, -- HOOK_CHUNK_UNLOADING }, -- Hooks[] -- cgit v1.2.3 From c8702e15bbced0a655d08761ea9173950445238c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 15:53:41 +0200 Subject: APIDump: Documented HOOK_COLLECTING_PICKUP. --- MCServer/Plugins/APIDump/APIDesc.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 013b3c69e..6044b0a0a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2297,6 +2297,33 @@ end; chunk is left in the memory. ]], }, -- HOOK_CHUNK_UNLOADING + + HOOK_COLLECTING_PICKUP = + { + CalledWhen = "Player is about to collect a pickup. Plugin can refuse / override behavior. ", + DefaultFnName = "OnCollectingPickup", -- also used as pagename + Desc = [[ + This hook is called when a player is about to collect a pickup. Plugins may refuse the action.

        +

        + Pickup collection happens within the world tick, so if the collecting is refused, it will be tried + again in the next world tick, as long as the player is within reach of the pickup.

        +

        + FIXME: There is no OnCollectedPickup() callback.

        +

        + FIXME: This callback is called even if the pickup doesn't fit into the player's inventory.

        + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who's collecting the pickup" }, + { Name = "Pickup", Type = "{{cPickup}}", Notes = "The pickup being collected" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally the + pickup is collected. If the function returns true, no other plugins are called for this event and + the pickup is not collected. + ]], + }, -- HOOK_COLLECTING_PICKUP + }, -- Hooks[] -- cgit v1.2.3 From f546a0e180cf153ed53ea0fc083f7954901e15e6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:02:32 +0200 Subject: APIDump: Documented HOOK_CRAFTING_NO_RECIPE. --- MCServer/Plugins/APIDump/APIDesc.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6044b0a0a..adc3a9835 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2324,6 +2324,32 @@ end; ]], }, -- HOOK_COLLECTING_PICKUP + HOOK_CRAFTING_NO_RECIPE = + { + CalledWhen = " No built-in crafting recipe is found. Plugin may provide a recipe.", + DefaultFnName = "OnCraftingNoRecipe", -- also used as pagename + Desc = [[ + This callback is called when a player places items in their {{cCraftingGrid|crafting grid}} and + MCServer cannot find a built-in {{cCraftingRecipe|recipe}} for the combination. Plugins may provide + a recipe for the ingredients given. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose crafting is reported in this hook" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "Contents of the player's crafting grid" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that will be used (can be filled by plugins)" }, + }, + Returns = [[ + If the function returns false or no value, no recipe will be used. If the function returns true, no + other plugin will have their callback called for this event and MCServer will use the crafting + recipe in Recipe.

        +

        + FIXME: To allow plugins give suggestions and overwrite other plugins' suggestions, we should change + the behavior with returning false, so that the recipe will still be used, but fill the recipe with + empty values by default. + ]], + }, -- HOOK_CRAFTING_NO_RECIPE + }, -- Hooks[] -- cgit v1.2.3 From ca285563d95d34ab8c9c57b9de948216c073d6c2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:04:43 +0200 Subject: APIDump: Fixed info missing from cCraftingRecipe. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index adc3a9835..35d50a861 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -546,7 +546,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), Desc = [[ This class is used to represent a crafting recipe, either a built-in one, or one created dynamically in a plugin. It is used only as a parameter for {{OnCraftingNoRecipe|OnCraftingNoRecipe}}, {{OnPostCrafting|OnPostCrafting}} and {{OnPreCrafting|OnPreCrafting}} hooks. Plugins may use it to inspect or modify a crafting recipe that a player views in their crafting window, either at a crafting table or the survival inventory screen.

        -

        Internally, the class contains a {{cItem|cItem}} for the result. +

        Internally, the class contains a {{cCraftingGrid}} for the ingredients and a {{cItem}} for the result. ]], Functions = { -- cgit v1.2.3 From 56bc94139d1982ec2a3f779bd8d66eab64ddca1c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:12:32 +0200 Subject: APIDump: Documented HOOK_DISCONNECT. --- MCServer/Plugins/APIDump/APIDesc.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 35d50a861..7530c3857 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2350,6 +2350,32 @@ end; ]], }, -- HOOK_CRAFTING_NO_RECIPE + HOOK_DISCONNECT = + { + CalledWhen = "A player has explicitly disconnected.", + DefaultFnName = "OnDisconnect", -- also used as pagename + Desc = [[ + This hook is called when a client sends the disconnect packet and is about to be disconnected from + the server.

        +

        + Note that this callback is not called if the client drops the connection or is kicked by the + server.

        +

        + FIXME: There is no callback for "client destroying" that would be called in all circumstances.

        + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has disconnected" }, + { Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks for this event + and finally broadcasts a disconnect message to the player's world. If the function returns true, no + other plugins are called for this event and the disconnect message is not broadcast. In either case, + the player is disconnected. + ]], + }, -- HOOK_DISCONNECT + }, -- Hooks[] -- cgit v1.2.3 From 66d8c1b3067efc2893b9db3cc434cadc769382cc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:13:39 +0200 Subject: APIDump: Updated the template for undocumented hooks. --- MCServer/Plugins/APIDump/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 87583be0e..8c07144f2 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -327,7 +327,7 @@ function DumpAPIHtml() f:write("\t\t" .. hook .. " =\n\t\t{\n"); f:write("\t\t\tCalledWhen = \"\",\n"); f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); - f:write("\t\t\tDesc = [[]],\n"); + f:write("\t\t\tDesc = [[\n\t\t\t\t\n\t\t\t]],\n"); f:write("\t\t\tParams =\n\t\t\t{\n"); f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); @@ -338,7 +338,7 @@ function DumpAPIHtml() f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); f:write("\t\t\t},\n"); - f:write("\t\t\tReturns = [[]],\n"); + f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); f:write("\t\t}, -- " .. hook .. "\n"); end end -- cgit v1.2.3 From 112e96ae9b17156cb18192421728a538ed0c51e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:20:32 +0200 Subject: APIDump: Documented HOOK_EXECUTE_COMMAND. --- MCServer/Plugins/APIDump/APIDesc.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7530c3857..e49c09ec8 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2376,6 +2376,31 @@ end; ]], }, -- HOOK_DISCONNECT + HOOK_EXECUTE_COMMAND = + { + CalledWhen = "A player executes an in-game command, or the admin issues a console command. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called.", + DefaultFnName = "OnExecuteCommand", -- also used as pagename + Desc = [[ + A plugin may implement a callback for this hook to intercept both in-game commands executed by the + players and console commands executed by the server admin. The function is called for every in-game + command sent from any player and for those server console commands that are not built in in the + server.

        +

        + If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's + executing the command. If the command comes from the server console, the first parameter is nil. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" }, + { Name = "Command", Type = "table of strings", Notes = "The command and its parameters, broken into a table by spaces" }, + }, + Returns = [[ + If the plugin returns true, the command will be blocked and none of the remaining hook handlers will + be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally + the command will be executed. + ]], + }, -- HOOK_EXECUTE_COMMAND + }, -- Hooks[] -- cgit v1.2.3 From 211b03a87082c3a99c171326afd79163274d663c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:43:39 +0200 Subject: APIDump: Documented HOOK_EXPLODED. --- MCServer/Plugins/APIDump/APIDesc.lua | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e49c09ec8..0ef93b400 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2401,6 +2401,49 @@ end; ]], }, -- HOOK_EXECUTE_COMMAND + HOOK_EXPLODED = + { + CalledWhen = "An explosion has happened", + DefaultFnName = "OnExploded", -- also used as pagename + Desc = [[ + This hook is called after an explosion has been processed in a world.

        +

        + See also {{OnHookExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.

        +

        + The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, + etc. It also carries the identification of the actual source. The exact type of the identification + depends on the source kind: + + + + + + + + + + + + +
        SourceSourceData TypeNotes
        esPrimedTNT{{cTNTEntity}}An exploding primed TNT entity
        esCreeper{{cCreeper}}An exploding creeper or charged creeper
        esBed{{Vector3i}}A bed exploding in the Nether or in the End. The bed coords are given.
        esEnderCrystal{{Vector3i}}An ender crystal exploding upon hit. The block coords are given.
        esGhastFireball{{cGhastFireballEntity}}A ghast fireball hitting ground or an {{cEntity|entity}}.
        esWitherSkullBlackTBDA black wither skull hitting ground or an {{cEntity|entity}}.
        esWitherSkullBlueTBDA blue wither skull hitting ground or an {{cEntity|entity}}.
        esWitherBirthTBDA wither boss being created
        esOtherTBDAny other previously unspecified type.
        esPluginobjectAn explosion created by a plugin. The plugin may specify any kind of data.

        + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happened" }, + { Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" }, + { Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion has turned random air blocks to fire (such as a ghast fireball)" }, + { Name = "X", Type = "number", Notes = "X-coord of the explosion center" }, + { Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" }, + { Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" }, + { Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." }, + { Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no overridable behaviour. + ]], + }, -- HOOK_EXPLODED + }, -- Hooks[] -- cgit v1.2.3 From c360849fa0fe016adb8186f09a862090b3858b06 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:53:13 +0200 Subject: APIDump: Documented HOOK_EXPLODING. --- MCServer/Plugins/APIDump/APIDesc.lua | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0ef93b400..871b04543 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2444,6 +2444,50 @@ end; ]], }, -- HOOK_EXPLODED + HOOK_EXPLODING = + { + CalledWhen = "An explosion is about to be processed", + DefaultFnName = "OnExploding", -- also used as pagename + Desc = [[ + This hook is called before an explosion has been processed in a world.

        +

        + See also {{OnHookExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.

        +

        + The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, + etc. It also carries the identification of the actual source. The exact type of the identification + depends on the source kind: + + + + + + + + + + + + +
        SourceSourceData TypeNotes
        esPrimedTNT{{cTNTEntity}}An exploding primed TNT entity
        esCreeper{{cCreeper}}An exploding creeper or charged creeper
        esBed{{Vector3i}}A bed exploding in the Nether or in the End. The bed coords are given.
        esEnderCrystal{{Vector3i}}An ender crystal exploding upon hit. The block coords are given.
        esGhastFireball{{cGhastFireballEntity}}A ghast fireball hitting ground or an {{cEntity|entity}}.
        esWitherSkullBlackTBDA black wither skull hitting ground or an {{cEntity|entity}}.
        esWitherSkullBlueTBDA blue wither skull hitting ground or an {{cEntity|entity}}.
        esWitherBirthTBDA wither boss being created
        esOtherTBDAny other previously unspecified type.
        esPluginobjectAn explosion created by a plugin. The plugin may specify any kind of data.

        + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happens" }, + { Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" }, + { Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion will turn random air blocks to fire (such as a ghast fireball)" }, + { Name = "X", Type = "number", Notes = "X-coord of the explosion center" }, + { Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" }, + { Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" }, + { Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." }, + { Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called, and finally + MCServer will process the explosion - destroy blocks and push + hurt entities. If the function + returns true, no other callback is called for this event and the explosion will not occur. + ]], + }, -- HOOK_EXPLODING + }, -- Hooks[] -- cgit v1.2.3 From 5c24d5acd7adcfa5a0bd121275f54b7d67505afb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 16:59:45 +0200 Subject: APIDump: Documented HOOK_HANDSHAKE. --- MCServer/Plugins/APIDump/APIDesc.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 871b04543..12665888b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2488,6 +2488,29 @@ end; ]], }, -- HOOK_EXPLODING + HOOK_HANDSHAKE = + { + CalledWhen = "A client is connecting.", + DefaultFnName = "OnHandshake", -- also used as pagename + Desc = [[ + This hook is called when a client sends the Handshake packet. At this stage, only the client IP and + (unverified) username are known. Plugins may refuse access to the server based on this + information.

        +

        + Note that the username is not authenticated - the authentication takes place only after this hook is + processed. + ]], + Params = + { + { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection. Note that there's no {{cPlayer}} object for this client yet." }, + { Name = "UserName", Type = "string", Notes = "The username presented in the packet. Note that this username is unverified." }, + }, + Returns = [[ + If the function returns false, the user is let in to the server. If the function returns true, no + other plugin's callback is called, the user is kicked and the connection is closed. + ]], + }, -- HOOK_HANDSHAKE + }, -- Hooks[] -- cgit v1.2.3 From 9969c1906016d2cb1a7e856fca72d16ec54c3687 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 21:15:55 +0200 Subject: APIDump: Documented HOOK_HOPPER_PULLING_ITEM. --- MCServer/Plugins/APIDump/APIDesc.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 12665888b..6b0ce9abb 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2511,6 +2511,29 @@ end; ]], }, -- HOOK_HANDSHAKE + HOOK_HOPPER_PULLING_ITEM = + { + CalledWhen = "A hopper is pulling an item from another block entity.", + DefaultFnName = "OnHopperPullingItem", -- also used as pagename + Desc = [[ + This callback is called whenever a hopper transfers an item from another block item into its own + internal storage. A plugin may decide to disallow the move by returning true. Note that in such a + case, the hook may be called again for the same hopper, with different slot numbers. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" }, + { Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pulling the item" }, + { Name = "DstSlot", Type = "number", Notes = "The destination slot in the hopper's {{cItemGrid|internal storage}}" }, + { Name = "SrcBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = "The block entity that is losing the item" }, + { Name = "SrcSlot", Type = "number", Notes = "Slot in SrcBlockEntity from which the item will be pulled" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event and the hopper will not pull the item. + ]], + }, -- HOOK_HOPPER_PULLING_ITEM + }, -- Hooks[] -- cgit v1.2.3 From 315af4450d8d7c4b746652eaa92347a3f5775da7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 21:45:08 +0200 Subject: APIDump: Documented HOOK_HOPPER_PUSHING_ITEM. --- MCServer/Plugins/APIDump/APIDesc.lua | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6b0ce9abb..69fcd6eb1 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2516,9 +2516,10 @@ end; CalledWhen = "A hopper is pulling an item from another block entity.", DefaultFnName = "OnHopperPullingItem", -- also used as pagename Desc = [[ - This callback is called whenever a hopper transfers an item from another block item into its own - internal storage. A plugin may decide to disallow the move by returning true. Note that in such a - case, the hook may be called again for the same hopper, with different slot numbers. + This callback is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from another + block entity into its own internal storage. A plugin may decide to disallow the move by returning + true. Note that in such a case, the hook may be called again for the same hopper, with different + slot numbers. ]], Params = { @@ -2534,6 +2535,30 @@ end; ]], }, -- HOOK_HOPPER_PULLING_ITEM + HOOK_HOPPER_PUSHING_ITEM = + { + CalledWhen = "A hopper is pushing an item into another block entity. ", + DefaultFnName = "OnHopperPushingItem", -- also used as pagename + Desc = [[ + This hook is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from its own + internal storage into another block entity. A plugin may decide to disallow the move by returning + true. Note that in such a case, the hook may be called again for the same hopper and block, with + different slot numbers. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" }, + { Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pushing the item" }, + { Name = "SrcSlot", Type = "number", Notes = "Slot in the hopper that will lose the item" }, + { Name = "DstBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = " The block entity that will receive the item" }, + { Name = "DstSlot", Type = "number", Notes = " Slot in DstBlockEntity's internal storage where the item will be stored" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event and the hopper will not push the item. + ]], + }, -- HOOK_HOPPER_PUSHING_ITEM + }, -- Hooks[] -- cgit v1.2.3 From a632f1d579298b2e0222b5f8ce6608c9b062dac4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 21:45:47 +0200 Subject: APIDump: Documented HOOK_KILLING. --- MCServer/Plugins/APIDump/APIDesc.lua | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 69fcd6eb1..4ea95b4da 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2559,6 +2559,33 @@ end; ]], }, -- HOOK_HOPPER_PUSHING_ITEM + HOOK_KILLING = + { + CalledWhen = "A player or a mob is dying.", + DefaultFnName = "OnKilling", -- also used as pagename + Desc = [[ + This hook is called whenever a {{cPawn|pawn}}'s (a player's or a mob's) health reaches zero. This + means that the pawn is about to be killed, unless a plugin "revives" them by setting their health + back to a positive value.

        +

        + FIXME: There is no HOOK_KILLED notification hook yet; this is deliberate because HOOK_KILLED has + been recently renamed to HOOK_KILLING, and plugins need to be updated. Once updated, the HOOK_KILLED + notification will be implemented. + ]], + Params = + { + { Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" }, + { Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins with this event. If the + function returns true, no other plugin is called for this event.

        +

        + In either case, the victim's health is then re-checked and if it is greater than zero, the victim is + "revived" with that health amount. If the health is less or equal to zero, the victim is killed. + ]], + }, -- HOOK_KILLING + }, -- Hooks[] -- cgit v1.2.3 From 862397856d4f42861b9b8bb4560e907310ce6fd8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 21:46:25 +0200 Subject: APIDump: Documented HOOK_LOGIN. --- MCServer/Plugins/APIDump/APIDesc.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4ea95b4da..3c9ee9421 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2586,6 +2586,31 @@ end; ]], }, -- HOOK_KILLING + HOOK_LOGIN = + { + CalledWhen = "Right after player authentication. If auth is disabled, right after the player sends their name.", + DefaultFnName = "OnLogin", -- also used as pagename + Desc = [[ + This hook is called whenever a client logs in. It is called right before the client's name is sent + to be authenticated. Plugins may refuse the client from accessing the server. Note that when this + callback is called, the {{cPlayer}} object for this client doesn't exist yet - the client has no + representation in any world. To process new players when their world is known, use a later callback, + such as {{OnPlayerJoined|HOOK_PLAYER_JOINED}} or {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}. + ]], + Params = + { + { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection" }, + { Name = "ProtocolVersion", Type = "number", Notes = "Versio of the protocol that the client is talking" }, + { Name = "UserName", Type = "string", Notes = "The name that the client has presented for authentication. This name will be given to the {{cPlayer}} object when it is created for this client." }, + }, + Returns = [[ + If the function returns true, no other plugins are called for this event and the client is kicked. + If the function returns false or no value, MCServer calls other plugins' callbacks and finally + sends an authentication request for the client's username to the auth server. If the auth server + is disabled in the server settings, the player object is immediately created. + ]], + }, -- HOOK_LOGIN + }, -- Hooks[] -- cgit v1.2.3 From e4bb796c6b03374ef5fcf02acee710900cacb5bb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 21:57:23 +0200 Subject: APIDump: Removed HOOK_MAX and HOOK_NUM_HOOKS from documentation. They're not really hooks, just constants for the maximum. --- MCServer/Plugins/APIDump/main.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 8c07144f2..6ae4a6b0f 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -180,7 +180,12 @@ function DumpAPIHtml() -- Extract hook constants: for name, obj in pairs(cPluginManager) do - if (type(obj) == "number") and (name:match("HOOK_.*")) then + if ( + (type(obj) == "number") and + name:match("HOOK_.*") and + (name ~= "HOOK_MAX") and + (name ~= "HOOK_NUM_HOOKS") + ) then table.insert(Hooks, { Name = name }); end end -- cgit v1.2.3 From d34fa4970ac56c3624654f148faafce096243fe7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 14 Oct 2013 22:01:10 +0200 Subject: APIDump: Documented HOOK_PLAYER_ANIMATION. --- MCServer/Plugins/APIDump/APIDesc.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3c9ee9421..e7ed25cdc 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2611,6 +2611,27 @@ end; ]], }, -- HOOK_LOGIN + HOOK_PLAYER_ANIMATION = + { + CalledWhen = "A client has sent an Animation packet (0x12)", + DefaultFnName = "OnPlayerAnimation", -- also used as pagename + Desc = [[ + This hook is called when the server receives an Animation packet (0x12) from the client.

        +

        + For the list of animations that are sent by the client, see the + Protocol wiki. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, + { Name = "Animation", Type = "number", Notes = "The kind of animation" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Afterwards, the + server broadcasts the animation packet to all nearby clients. If the function returns true, no other + callback is called for this event and the packet is not broadcasted. + ]], + }, -- HOOK_PLAYER_ANIMATION }, -- Hooks[] -- cgit v1.2.3 From 5e71b3011623a47167e555259259cde026817099 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 08:03:46 +0200 Subject: APIDump: Documented HOOK_PLAYER_BREAKING_BLOCK. --- MCServer/Plugins/APIDump/APIDesc.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e7ed25cdc..af4818755 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2632,6 +2632,36 @@ end; callback is called for this event and the packet is not broadcasted. ]], }, -- HOOK_PLAYER_ANIMATION + + HOOK_PLAYER_BREAKING_BLOCK = + { + CalledWhen = "Just before a player breaks a block. Plugin may override / refuse. ", + DefaultFnName = "OnPlayerBreakingBlock", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} breaks a block, before the block is actually broken in + the {{cWorld|World}}. Plugins may refuse the breaking. + + See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after + the block is broken. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is digging the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player is acting. One of the BLOCK_FACE_ constants" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block being broken" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block being broken " }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called, and then the block + is broken. If the function returns true, no other plugin's callback is called and the block breaking + is cancelled. The server re-sends the block back to the player to replace it (the player's client + already thinks the block was broken). + ]], + }, -- HOOK_PLAYER_BREAKING_BLOCK + }, -- Hooks[] -- cgit v1.2.3 From eb466334adaac7ee6ff6c1993e4969739ae28b6d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 08:11:01 +0200 Subject: APIDump: Documented HOOK_PLAYER_BROKEN_BLOCK. --- MCServer/Plugins/APIDump/APIDesc.lua | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index af4818755..efc0c6dc6 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2639,8 +2639,8 @@ end; DefaultFnName = "OnPlayerBreakingBlock", -- also used as pagename Desc = [[ This hook is called when a {{cPlayer|player}} breaks a block, before the block is actually broken in - the {{cWorld|World}}. Plugins may refuse the breaking. - + the {{cWorld|World}}. Plugins may refuse the breaking.

        +

        See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after the block is broken. ]], @@ -2662,6 +2662,35 @@ end; ]], }, -- HOOK_PLAYER_BREAKING_BLOCK + HOOK_PLAYER_BROKEN_BLOCK = + { + CalledWhen = "After a player has broken a block. Notification only.", + DefaultFnName = "OnPlayerBrokenBlock", -- also used as pagename + Desc = [[ + This function is called after a {{cPlayer|player}} breaks a block. The block is already removed + from the {{cWorld|world}} and {{cPickup|pickups}} have been spawned. To get the world in which the + block has been dug, use the {{cPlayer}}:GetWorld() function.

        +

        + See also the {{OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK}} hook for a similar hook called + before the block is broken. To intercept the creation of pickups, see the + {{OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS}} hook. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who broke the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_PLAYER_BROKEN_BLOCK + }, -- Hooks[] -- cgit v1.2.3 From b902c0b29e72098242bb81caabb99e333fb2da97 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 08:18:08 +0200 Subject: APIDump: Documented HOOK_PLAYER_EATING. --- MCServer/Plugins/APIDump/APIDesc.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index efc0c6dc6..84e7588db 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2691,6 +2691,26 @@ end; ]], }, -- HOOK_PLAYER_BROKEN_BLOCK + HOOK_PLAYER_EATING = + { + CalledWhen = "When the player starts eating", + DefaultFnName = "OnPlayerEating", -- also used as pagename + Desc = [[ + This hook gets called when the {{cPlayer|player}} starts eating, after the server checks that the + player can indeed eat (is not satiated and is holding food). Plugins may still refuse the eating by + returning true. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who started eating" }, + }, + Returns = [[ + If the function returns false or no value, the server calls the next plugin handler, and finally + lets the player eat. If the function returns true, the server doesn't call any more callbacks for + this event and aborts the eating. A "disallow" packet is sent to the client. + ]], + }, -- HOOK_PLAYER_EATING + }, -- Hooks[] -- cgit v1.2.3 From 90dc2c55d8273c4a9d4429f7f4473cbf3302f1a4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 08:24:44 +0200 Subject: APIDump: Documented HOOK_PLAYER_JOINED. --- MCServer/Plugins/APIDump/APIDesc.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 84e7588db..b464a10e6 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2711,6 +2711,28 @@ end; ]], }, -- HOOK_PLAYER_EATING + HOOK_PLAYER_JOINED = + { + CalledWhen = "After Login and before Spawned, before being added to world. ", + DefaultFnName = "OnPlayerJoined", -- also used as pagename + Desc = [[ + This hook is called whenever a {{cPlayer|player}} has completely logged in. If authentication is + enabled, this function is called after their name has been authenticated. It is called after + {{OnLogin|HOOK_LOGIN}} and before {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}, right after the player's + entity is created, but not added to the world yet. The player is not yet visible to other players. + This is a notification-only event, plugins wishing to refuse player's entry should kick the player + using the {{cPlayer}}:Kick() function. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has joined the game" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. Either way the player is let in. + ]], + }, -- HOOK_PLAYER_JOINED + }, -- Hooks[] -- cgit v1.2.3 From 19e176be20ce9fb9fede053f773c46da2e8f362f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 11:30:41 +0200 Subject: APIDump: Documented HOOK_PLAYER_LEFT_CLICK. --- MCServer/Plugins/APIDump/APIDesc.lua | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b464a10e6..02f6a8d3c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2733,6 +2733,46 @@ end; ]], }, -- HOOK_PLAYER_JOINED + HOOK_PLAYER_LEFT_CLICK = + { + CalledWhen = "A left-click packet is received from the client. Plugin may override / refuse.", + DefaultFnName = "OnPlayerLeftClick", -- also used as pagename + Desc = [[ + This hook is called when MCServer receives a left-click packet from the {{cClientHandle|client}}. It + is called before any processing whatsoever is performed on the packet, meaning that hacked / + malicious clients may be trigerring this event very often and with unchecked parameters. Therefore + plugin authors are advised to use extreme caution with this callback.

        +

        + Plugins may refuse the default processing for the packet, causing MCServer to behave as if the + packet has never arrived. This may, however, create inconsistencies in the client - the client may + think that they broke a block, while the server didn't process the breaking, etc. For this reason, + if a plugin refuses the processing, MCServer sends the block specified in the packet back to the + client (as if placed anew), if the status code specified a block-break action. For other actions, + plugins must rectify the situation on their own.

        +

        + The client sends the left-click packet for several other occasions, such as dropping the held item + (Q keypress) or shooting an arrow. This is reflected in the Status code. Consult the + protocol documentation for details on the actions. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "Action", Type = "number", Notes = "Action to be performed on the block (\"status\" in the protocol docs)" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends + the packet for further processing.

        +

        + If the function returns true, no other plugins are called, processing is halted. If the action was a + block dig, MCServer sends the block specified in the coords back to the client. The packet is + dropped. + ]], + }, -- HOOK_PLAYER_LEFT_CLICK + }, -- Hooks[] -- cgit v1.2.3 From deb2d89506b3c23a26b9e0de4143506894b8bfbb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 14:48:29 +0200 Subject: APIDump: Documented HOOK_PLAYER_MOVING and HOOK_PLAYER_PLACED_BLOCK. --- MCServer/Plugins/APIDump/APIDesc.lua | 53 ++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 02f6a8d3c..3982f8b4c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2773,6 +2773,59 @@ end; ]], }, -- HOOK_PLAYER_LEFT_CLICK + HOOK_PLAYER_MOVING = + { + CalledWhen = "Player tried to move in the tick being currently processed. Plugin may refuse movement.", + DefaultFnName = "OnPlayerMoving", -- also used as pagename + Desc = [[ + This function is called in each server tick for each {{cPlayer|player}} that has sent any of the + player-move packets. Plugins may refuse the movement. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has moved. The object already has the new position stored in it." }, + }, + Returns = [[ + If the function returns true, movement is prohibited. FIXME: The player's client is not informed.

        +

        + If the function returns false or no value, other plugins' callbacks are called and finally the new + position is permanently stored in the cPlayer object.

        + ]], + }, -- HOOK_PLAYER_MOVING + + HOOK_PLAYER_PLACED_BLOCK = + { + CalledWhen = "After a player has placed a block. Notification only.", + DefaultFnName = "OnPlayerPlacedBlock", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has placed a block in the {{cWorld|world}}. The block + is already added to the world and the corresponding item removed from player's + {{cInventory|inventory}}.

        +

        + Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.

        +

        + See also the {{OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK}} hook for a similar hook called + before the placement. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who placed the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, + }, + Returns = [[ + If this function returns false or no value, MCServer calls other plugins with the same event. If + this function returns true, no other plugin is called for this event. + ]], + }, -- HOOK_PLAYER_PLACED_BLOCK + }, -- Hooks[] -- cgit v1.2.3 From 9be35e122223b19eab76cac045144f1e572a1adb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 14:58:33 +0200 Subject: APIDump: Documented HOOK_PLAYER_PLACING_BLOCK. --- MCServer/Plugins/APIDump/APIDesc.lua | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3982f8b4c..b4b2e11a3 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2826,6 +2826,44 @@ end; ]], }, -- HOOK_PLAYER_PLACED_BLOCK + HOOK_PLAYER_PLACING_BLOCK = + { + CalledWhen = "Just before a player places a block. Plugin may override / refuse.", + DefaultFnName = "OnPlayerPlacingBlock", -- also used as pagename + Desc = [[ + This hook is called just before a {{cPlayer|player}} places a block in the {{cWorld|world}}. The + block is not yet placed, plugins may choose to override the default behavior or refuse the placement + at all.

        +

        + Note that the client already expects that the block has been placed. For that reason, if a plugin + refuses the placement, MCServer sends the old block at the provided coords to the client.

        +

        + Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.

        +

        + See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after + the placement. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is placing the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player is interacting. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, + }, + Returns = [[ + If this function returns false or no value, MCServer calls other plugins with the same event and + finally places the block and removes the corresponding item from player's inventory. If this + function returns true, no other plugin is called for this event, MCServer sends the old block at + the specified coords to the client and drops the packet. + ]], + }, -- HOOK_PLAYER_PLACING_BLOCK + }, -- Hooks[] -- cgit v1.2.3 From b079676290cdd6be5b6e3fd84f46b8d25f959b9e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 17:35:34 +0200 Subject: APIDump: Documented HOOK_POST_CRAFTING. --- MCServer/Plugins/APIDump/APIDesc.lua | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b4b2e11a3..9430f370d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2864,6 +2864,35 @@ end; ]], }, -- HOOK_PLAYER_PLACING_BLOCK + HOOK_POST_CRAFTING = + { + CalledWhen = "After the built-in recipes are checked and a recipe was found.", + DefaultFnName = "OnPostCrafting", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} changes contents of their + {{cCraftingGrid|crafting grid}}, after the recipe has been established by MCServer. Plugins may use + this to modify the resulting recipe or provide an alternate recipe.

        +

        + If a plugin implements custom recipes, it should do so using the {{OnPreCrafting|HOOK_PRE_CRAFTING}} + hook, because that will save the server from going through the built-in recipes. The + HOOK_POST_CRAFTING hook is intended as a notification, with a chance to tweak the result.

        +

        + Note that this hook is not called if a built-in recipe is not found; + {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}} is called instead in such a case. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer has decided to use (can be tweaked by plugins)" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. In either case, MCServer uses the value + of Recipe as the recipe to be presented to the player. + ]], + }, -- HOOK_POST_CRAFTING + }, -- Hooks[] -- cgit v1.2.3 From edd1a670edf97500aa9a8f68fd2ea0b68bcc8d55 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 17:43:41 +0200 Subject: APIDump: Documented HOOK_PRE_CRAFTING. --- MCServer/Plugins/APIDump/APIDesc.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 9430f370d..caa0f6bd8 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2893,6 +2893,36 @@ end; ]], }, -- HOOK_POST_CRAFTING + HOOK_PRE_CRAFTING = + { + CalledWhen = "Before the built-in recipes are checked.", + DefaultFnName = "OnPreCrafting", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} changes contents of their + {{cCraftingGrid|crafting grid}}, before the built-in recipes are searched for a match by MCServer. + Plugins may use this hook to provide a custom recipe.

        +

        + If you intend to tweak built-in recipes, use the {{OnPostCrafting|HOOK_POST_CRAFTING}} hook, because + that will be called once the built-in recipe is matched.

        +

        + Also note a third hook, {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}}, that is called when MCServer + cannot find any built-in recipe for the given ingredients. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer will use. Modify this object to change the recipe" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + searches the built-in recipes. The Recipe output parameter is ignored in this case.

        +

        + If the function returns true, no other callbacks are called for this event and MCServer uses the + recipe stored in the Recipe output parameter. + ]], + }, -- HOOK_PRE_CRAFTING + }, -- Hooks[] -- cgit v1.2.3 From 167d8d346ec0fd0b150116619fa3cde760e3e369 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 17:55:01 +0200 Subject: APIDump: Documented HOOK_SPAWNED_ENTITY. --- MCServer/Plugins/APIDump/APIDesc.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index caa0f6bd8..f2a0cbaa2 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2923,6 +2923,26 @@ end; ]], }, -- HOOK_PRE_CRAFTING + HOOK_SPAWNED_ENTITY = + { + CalledWhen = "After an entity is spawned in the world.", + DefaultFnName = "OnSpawnedEntity", -- also used as pagename + Desc = [[ + This callback is called after the server spawns an {{cEntity|entity}}. This is an information-only + callback, the entity is already spawned by the time it is called. If the entity spawned is a + {{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this hook. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity has spawned" }, + { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that has spawned" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_SPAWNED_ENTITY + }, -- Hooks[] -- cgit v1.2.3 From 44ec010e154853419d53ef88b82bf6dbf1fec747 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 17:58:39 +0200 Subject: APIDump: Documented HOOK_SPAWNED_MONSTER. --- MCServer/Plugins/APIDump/APIDesc.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f2a0cbaa2..3dcfb188d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2928,7 +2928,7 @@ end; CalledWhen = "After an entity is spawned in the world.", DefaultFnName = "OnSpawnedEntity", -- also used as pagename Desc = [[ - This callback is called after the server spawns an {{cEntity|entity}}. This is an information-only + This hook is called after the server spawns an {{cEntity|entity}}. This is an information-only callback, the entity is already spawned by the time it is called. If the entity spawned is a {{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this hook. ]], @@ -2943,6 +2943,26 @@ end; ]], }, -- HOOK_SPAWNED_ENTITY + HOOK_SPAWNED_MONSTER = + { + CalledWhen = "After a monster is spawned in the world", + DefaultFnName = "OnSpawnedMonster", -- also used as pagename + Desc = [[ + This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only + callback, the monster is already spawned by the time it is called. After this hook is called, the + {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the monster has spawned" }, + { Name = "Monster", Type = "{{cMonster}} descendant", Notes = "The monster that has spawned" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_SPAWNED_MONSTER + }, -- Hooks[] -- cgit v1.2.3 From ba6c2b9ef4173da0717f335754c1660ce32e4abf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 18:06:06 +0200 Subject: APIDump: Documented HOOK_SPAWNING_ENTITY. --- MCServer/Plugins/APIDump/APIDesc.lua | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3dcfb188d..42762a9ad 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2930,7 +2930,11 @@ end; Desc = [[ This hook is called after the server spawns an {{cEntity|entity}}. This is an information-only callback, the entity is already spawned by the time it is called. If the entity spawned is a - {{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this hook. + {{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this + hook.

        +

        + See also the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} hook for a similar hook called before the + entity is spawned. ]], Params = { @@ -2950,7 +2954,10 @@ end; Desc = [[ This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only callback, the monster is already spawned by the time it is called. After this hook is called, the - {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity. + {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity.

        +

        + See also the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook for a similar hook called before the + monster is spawned. ]], Params = { @@ -2963,6 +2970,31 @@ end; ]], }, -- HOOK_SPAWNED_MONSTER + HOOK_SPAWNING_ENTITY = + { + CalledWhen = "Before an entity is spawned in the world.", + DefaultFnName = "OnSpawningEntity", -- also used as pagename + Desc = [[ + This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the + entity before it is spawned, or disable the spawning altogether. If the entity spawning is a + monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook is called before this hook.

        +

        + See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the + entity is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, + { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that will spawn" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Finally, the server + spawns the entity with whatever parameters have been set on the {{cEntity}} object by the callbacks. + If the function returns true, no other callback is called for this event and the entity is not + spawned. + ]], + }, -- HOOK_SPAWNING_ENTITY + }, -- Hooks[] -- cgit v1.2.3 From 9c7ca813d283b42fae5ce6839aec5bff3181d0eb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 18:12:37 +0200 Subject: APIDump: Documented HOOK_SPAWNING_MONSTER. --- MCServer/Plugins/APIDump/APIDesc.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 42762a9ad..8b62df24d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2995,6 +2995,32 @@ end; ]], }, -- HOOK_SPAWNING_ENTITY + HOOK_SPAWNING_MONSTER = + { + CalledWhen = "Before a monster is spawned in the world.", + DefaultFnName = "OnSpawningMonster", -- also used as pagename + Desc = [[ + This hook is called before the server spawns a {{cMonster|monster}}. The plugins may modify the + monster's parameters in the {{cMonster}} class, or disallow the spawning altogether. This hook is + called before the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} is called for the monster entity.

        +

        + See also the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook for a similar hook called after the + monster is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, + { Name = "Monster", Type = "{{cMonster}} descentant", Notes = "The monster that will spawn" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Finally, the server + spawns the monster with whatever parameters the plugins set in the cMonster parameter.

        +

        + If the function returns true, no other callback is called for this event and the monster won't + spawn. + ]], + }, -- HOOK_SPAWNING_MONSTER + }, -- Hooks[] -- cgit v1.2.3 From c9a9a30fa54f2c41290ba4a99e3575ad3f5373f8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 15 Oct 2013 18:42:33 +0200 Subject: APIDump: Linkification supports #anchors. This implements #198. --- MCServer/Plugins/APIDump/main.lua | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 6ae4a6b0f..163c505b2 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -617,8 +617,39 @@ end -- Make a link out of anything with the special linkifying syntax {{link|title}} function LinkifyString(a_String) - local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", "%2") -- {{link|title}} - txt = txt:gsub("{{([^|}]*)}}", "%1") -- {{LinkAndTitle}} + local function CreateLink(Link, Title) + if (Link:sub(1, 7) == "http://") then + -- The link is a full absolute URL, do not modify, do not track: + return "" .. Title .. ""; + end + local idxHash = Link:find("#"); + if (idxHash ~= nil) then + -- The link contains an anchor: + if (idxHash == 1) then + -- Anchor in the current page, no need to track: + return "" .. Title .. ""; + end + -- Anchor in another page: + -- TODO: track this link + return "" .. Title .. ""; + end + -- Link without anchor: + -- TODO; track this link + return "" .. Title .. ""; + end + + local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", CreateLink) -- {{link|title}} + + txt = txt:gsub("{{([^|}]*)}}", -- {{LinkAndTitle}} + function(LinkAndTitle) + local idxHash = LinkAndTitle:find("#"); + if (idxHash ~= nil) then + -- The LinkAndTitle contains a hash, remove the hashed part from the title: + return CreateLink(LinkAndTitle, LinkAndTitle:sub(1, idxHash - 1)); + end + return CreateLink(LinkAndTitle, LinkAndTitle); + end + ); return txt; end -- cgit v1.2.3 From 17aff20666defab01006ea4ca56dc4f2f8cba9ac Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 15 Oct 2013 19:57:00 +0100 Subject: Added HOOK_PLAYER_RIGHT_CLICK --- MCServer/Plugins/APIDump/APIDesc.lua | 46 +++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8b62df24d..2bede6323 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -364,8 +364,8 @@ g_APIDesc = }, Constants = { - Color = { Notes = "The first character of the color-code-sequence, §" }, - Delimiter = { Notes = "The first character of the color-code-sequence, §" }, + Color = { Notes = "The first character of the color-code-sequence, §" }, + Delimiter = { Notes = "The first character of the color-code-sequence, §" }, Random = { Notes = "Random letters and symbols animate instead of the text" }, Plain = { Notes = "Resets all formatting to normal" }, }, @@ -2029,14 +2029,14 @@ World:ForEachEntity( GetTime = {Return = "number", Notes = "Returns the current OS time, as a unix time stamp (number of seconds since Jan 1, 1970)"}, IsValidBlock = {Params = "BlockType", Return = "bool", Notes = "Returns true if BlockType is a known block type"}, IsValidItem = {Params = "ItemType", Return = "bool", Notes = "Returns true if ItemType is a known item type"}, - ItemToFullString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item, in the format “ItemTypeText:ItemDamage * Count”"}, + ItemToFullString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item, in the format “ItemTypeText:ItemDamage * Countâ€"}, ItemToString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item type"}, ItemTypeToString = {Params = "ItemType", Return = "string", Notes = "Returns the string representation of ItemType "}, - LOG = {Params = "string", Notes = "Logs a text into the server console using “normal” severity (gray text) "}, - LOGERROR = {Params = "string", Notes = "Logs a text into the server console using “error” severity (black text on red background)"}, - LOGINFO = {Params = "string", Notes = "Logs a text into the server console using “info” severity (yellow text)"}, - LOGWARN = {Params = "string", Notes = "Logs a text into the server console using “warning” severity (red text); OBSOLETE"}, - LOGWARNING = {Params = "string", Notes = "Logs a text into the server console using “warning” severity (red text)"}, + LOG = {Params = "string", Notes = "Logs a text into the server console using “normal†severity (gray text) "}, + LOGERROR = {Params = "string", Notes = "Logs a text into the server console using “error†severity (black text on red background)"}, + LOGINFO = {Params = "string", Notes = "Logs a text into the server console using “info†severity (yellow text)"}, + LOGWARN = {Params = "string", Notes = "Logs a text into the server console using “warning†severity (red text); OBSOLETE"}, + LOGWARNING = {Params = "string", Notes = "Logs a text into the server console using “warning†severity (red text)"}, NoCaseCompare = {Params = "string, string", Return = "number", Notes = "Case-insensitive string comparison; returns 0 if the strings are the same"}, ReplaceString = {Params = "full-string, to-be-replaced-string, to-replace-string", Notes = "Replaces *each* occurence of to-be-replaced-string in full-string with to-replace-string"}, StringSplit = {Params = "string, Seperator", Return = "list", Notes = "Seperates string into multiple by splitting every time Seperator is encountered."}, @@ -2864,6 +2864,36 @@ end; ]], }, -- HOOK_PLAYER_PLACING_BLOCK + HOOK_PLAYER_RIGHT_CLICK = + { + CalledWhen = "A right-click packet is received from the client. Plugin may override / refuse.", + DefaultFnName = "OnPlayerRightClick", -- also used as pagename + Desc = [[ + This hook is called when MCServer receives a right-click packet from the {{cClientHandle|client}}. It + is called before any processing whatsoever is performed on the packet, meaning that hacked / + malicious clients may be trigerring this event very often and with unchecked parameters. Therefore + plugin authors are advised to use extreme caution with this callback.

        +

        + Plugins may refuse the default processing for the packet, causing MCServer to behave as if the + packet has never arrived. This may, however, create inconsistencies in the client - the client may + think that they placed a block, while the server didn't process the placing, etc. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends + the packet for further processing.

        +

        + If the function returns true, no other plugins are called, processing is halted. + ]], + }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_POST_CRAFTING = { CalledWhen = "After the built-in recipes are checked and a recipe was found.", -- cgit v1.2.3 From dbd925a7a4a2ce947bc3397e8633c56377657b88 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 16 Oct 2013 08:04:06 +0200 Subject: APIDump: Nicer HTML visage. * Fixed whacky HTML indentation + Added fancy CSS! + Now HTML5 compatible! --- MCServer/Plugins/APIDump/WebWorldThreads.html | 116 ++++++------ MCServer/Plugins/APIDump/main.css | 30 +++- MCServer/Plugins/APIDump/main.lua | 242 +++++++++++++++----------- 3 files changed, 230 insertions(+), 158 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/WebWorldThreads.html b/MCServer/Plugins/APIDump/WebWorldThreads.html index a77209b0b..7cc94e9fa 100644 --- a/MCServer/Plugins/APIDump/WebWorldThreads.html +++ b/MCServer/Plugins/APIDump/WebWorldThreads.html @@ -1,64 +1,64 @@ + - -MCServer - Webserver vs World threads - - - - + + MCServer - Webserver vs World threads + + + + +

        Webserver vs World threads

        +

        + This article will explain the threading issues that arise between the webserver and world threads are of concern to plugin authors.

        +

        + Generally, plugins that provide webadmin pages should be quite careful about their interactions. Most operations on MCServer objects requires synchronization, that MCServer provides automatically and transparently to plugins - when a block is written, the chunkmap is locked, or when an entity is being manipulated, the entity list is locked. Each plugin also has a mutex lock, so that only one thread at a time may be executing plugin code.

        +

        + This locking can be a source of deadlocks for plugins that are not written carefully.

        -

        Webserver vs World threads

        -

        -This article will explain the threading issues that arise between the webserver and world threads are of concern to plugin authors.

        -

        -Generally, plugins that provide webadmin pages should be quite careful about their interactions. Most operations on MCServer objects requires synchronization, that MCServer provides automatically and transparently to plugins - when a block is written, the chunkmap is locked, or when an entity is being manipulated, the entity list is locked. Each plugin also has a mutex lock, so that only one thread at a time may be executing plugin code.

        -

        -This locking can be a source of deadlocks for plugins that are not written carefully.

        +

        Example scenario

        +

        Consider the following example. A plugin provides a webadmin page that allows the admin to kick players off the server. When the admin presses the "Kick" button, the plugin calls cWorld:DoWithPlayer() with a callback to kick the player. Everything seems to be working fine now.

        +

        + A new feature is developed in the plugin, now the plugin adds a new in-game command so that the admins can kick players while they're playing the game. The plugin registers a command callback with cPluginManager.AddCommand(). Now there are problems bound to happen.

        +

        + Suppose that two admins are in, one is using the webadmin and the other is in-game. Both try to kick a player at the same time. The webadmin locks the plugin, so that it can execute the plugin code, but right at this moment the OS switches threads. The world thread locks the world so that it can access the list of in-game commands, receives the in-game command, it tries to lock the plugin. The plugin is already locked, so the world thread is put on hold. After a while, the webadmin thread is woken up again and continues processing. It tries to lock the world so that it can traverse the playerlist, but the lock is already held by the world thread. Now both threads are holding one lock each and trying to grab the other lock, and are therefore deadlocked.

        -

        Example scenario

        -

        Consider the following example. A plugin provides a webadmin page that allows the admin to kick players off the server. When the admin presses the "Kick" button, the plugin calls cWorld:DoWithPlayer() with a callback to kick the player. Everything seems to be working fine now.

        -

        -A new feature is developed in the plugin, now the plugin adds a new in-game command so that the admins can kick players while they're playing the game. The plugin registers a command callback with cPluginManager.AddCommand(). Now there are problems bound to happen.

        -

        -Suppose that two admins are in, one is using the webadmin and the other is in-game. Both try to kick a player at the same time. The webadmin locks the plugin, so that it can execute the plugin code, but right at this moment the OS switches threads. The world thread locks the world so that it can access the list of in-game commands, receives the in-game command, it tries to lock the plugin. The plugin is already locked, so the world thread is put on hold. After a while, the webadmin thread is woken up again and continues processing. It tries to lock the world so that it can traverse the playerlist, but the lock is already held by the world thread. Now both threads are holding one lock each and trying to grab the other lock, and are therefore deadlocked.

        +

        How to avoid the deadlock

        +

        + There are two main ways to avoid such a deadlock. The first approach is using tasks: Everytime you need to execute a task inside a world, instead of executing it, queue it, using cWorld:QueueTask(). This handy utility can will call the given function inside the world's TickThread, thus eliminating the deadlock, because now there's only one thread. However, this approach will not let you get data back. You cannot query the player list, or the entities, or anything - because when the task runs, the webadmin page has already been served to the browser.

        +

        + To accommodate this, you'll need to use the second approach - preparing and caching data in the tick thread, possibly using callbacks. This means that the plugin will have global variables that will store the data, and update those variables when the data changes; then the webserver thread will only read those variables, instead of calling the world functions. For example, if a webpage was to display the list of currently connected players, the plugin should maintain a global variable, g_WorldPlayers, which would be a table of worlds, each item being a list of currently connected players. The webadmin handler would read this variable and create the page from it; the plugin would use HOOK_PLAYER_JOINED and HOOK_DISCONNECT to update the variable.

        -

        How to avoid the deadlock

        -

        -There are two main ways to avoid such a deadlock. The first approach is using tasks: Everytime you need to execute a task inside a world, instead of executing it, queue it, using cWorld:QueueTask(). This handy utility can will call the given function inside the world's TickThread, thus eliminating the deadlock, because now there's only one thread. However, this approach will not let you get data back. You cannot query the player list, or the entities, or anything - because when the task runs, the webadmin page has already been served to the browser.

        -

        -To accommodate this, you'll need to use the second approach - preparing and caching data in the tick thread, possibly using callbacks. This means that the plugin will have global variables that will store the data, and update those variables when the data changes; then the webserver thread will only read those variables, instead of calling the world functions. For example, if a webpage was to display the list of currently connected players, the plugin should maintain a global variable, g_WorldPlayers, which would be a table of worlds, each item being a list of currently connected players. The webadmin handler would read this variable and create the page from it; the plugin would use HOOK_PLAYER_JOINED and HOOK_DISCONNECT to update the variable.

        +

        What to avoid

        +

        + Now that we know what the danger is and how to avoid it, how do we know if our code is susceptible?

        +

        + The general rule of thumb is to avoid calling any functions that read or write lists of things in the webserver thread. This means most ForEach() and DoWith() functions. Only cRoot:ForEachWorld() is safe - because the list of worlds is not expected to change, so it is not guarded by a mutex. Getting and setting world's blocks is, naturally, unsafe, as is calling other plugins, or creating entities.

        -

        What to avoid

        -

        -Now that we know what the danger is and how to avoid it, how do we know if our code is susceptible?

        -

        -The general rule of thumb is to avoid calling any functions that read or write lists of things in the webserver thread. This means most ForEach() and DoWith() functions. Only cRoot:ForEachWorld() is safe - because the list of worlds is not expected to change, so it is not guarded by a mutex. Getting and setting world's blocks is, naturally, unsafe, as is calling other plugins, or creating entities.

        - -

        Example

        -The Core has the facility to kick players using the web interface. It used the following code for the kicking (inside the webadmin handler): -
        -local KickPlayerName = Request.Params["players-kick"]
        -local FoundPlayerCallback = function(Player)
        -  if (Player:GetName() == KickPlayerName) then
        -    Player:GetClientHandle():Kick("You were kicked from the game!")
        -  end
        -end
        -cRoot:Get():FindAndDoWithPlayer(KickPlayerName, FoundPlayerCallback)
        -
        -The cRoot:FindAndDoWithPlayer() is unsafe and could have caused a deadlock. The new solution is queue a task; but since we don't know in which world the player is, we need to queue the task to all worlds: -
        -cRoot:Get():ForEachWorld(    -- For each world...
        -  function(World)
        -    World:QueueTask(         -- ... queue a task...
        -      function(a_World)
        -        a_World:DoWithPlayer(KickPlayerName,  -- ... to walk the playerlist...
        -          function (a_Player)
        -            a_Player:GetClientHandle():Kick("You were kicked from the game!")  -- ... and kick the player
        -          end
        -        )
        -      end
        -    )
        -  end
        -)
        -
        - +

        Example

        + The Core has the facility to kick players using the web interface. It used the following code for the kicking (inside the webadmin handler): +
        +		local KickPlayerName = Request.Params["players-kick"]
        +		local FoundPlayerCallback = function(Player)
        +		  if (Player:GetName() == KickPlayerName) then
        +			Player:GetClientHandle():Kick("You were kicked from the game!")
        +		  end
        +		end
        +		cRoot:Get():FindAndDoWithPlayer(KickPlayerName, FoundPlayerCallback)
        +		
        + The cRoot:FindAndDoWithPlayer() is unsafe and could have caused a deadlock. The new solution is queue a task; but since we don't know in which world the player is, we need to queue the task to all worlds: +
        +		cRoot:Get():ForEachWorld(    -- For each world...
        +		  function(World)
        +			World:QueueTask(         -- ... queue a task...
        +			  function(a_World)
        +				a_World:DoWithPlayer(KickPlayerName,  -- ... to walk the playerlist...
        +				  function (a_Player)
        +					a_Player:GetClientHandle():Kick("You were kicked from the game!")  -- ... and kick the player
        +				  end
        +				)
        +			  end
        +			)
        +		  end
        +		)
        +		
        + \ No newline at end of file diff --git a/MCServer/Plugins/APIDump/main.css b/MCServer/Plugins/APIDump/main.css index 777f6d71a..5cc603a3f 100644 --- a/MCServer/Plugins/APIDump/main.css +++ b/MCServer/Plugins/APIDump/main.css @@ -1,3 +1,8 @@ +html +{ + background-color: #C0C0C0; +} + table { background-color: #fff; @@ -25,4 +30,27 @@ pre { border: 1px solid #ccc; background-color: #eee; -} \ No newline at end of file +} + +body +{ + min-width: 800px; + width: 95%; + margin: 10px auto; + background-color: white; + border: 4px #FF8C00 solid; + border-radius: 20px; + font-family: Calibri, Trebuchet MS; +} + +header +{ + text-align: center; + font-family: Segoe UI Light, Helvetica; +} + +#content +{ + padding: 0px 25px 25px 25px; +} + diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 163c505b2..22801b1e5 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -22,7 +22,7 @@ function Initialize(Plugin) Plugin:SetName("APIDump"); Plugin:SetVersion(1); - LOG("Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) + LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) g_PluginFolder = Plugin:GetLocalFolder(); @@ -212,48 +212,69 @@ function DumpAPIHtml() return; end - f:write([[MCServer API - index - -

        MCServer API - index

        -

        The API reference is divided into the following sections:

        -

        Class index

        -

        The following classes are available in the MCServer Lua scripting language: -

          - ]]); + f:write([[ + + + MCServer API - Index + + + +
          +
          +

          MCServer API - Index

          +
          +
          +

          The API reference is divided into the following sections:

          + + + +
          +

          Class index

          +

          The following classes are available in the MCServer Lua scripting language:

          + +

          -

          Hooks

          -

          A plugin can register to be called whenever an “interesting event” occurs. It does so by calling - cPluginManager's AddHook() function and implementing a callback - function to handle the event.

          -

          A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it - from them. This is determined by the return value from the hook callback function. If the function returns - false or no value, the event is propagated further. If the function returns true, the processing is - stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior - for the event). See each hook's details to see the exact behavior.

          - - ]]); + f:write([[ + +
          +

          Hooks

          + +

          A plugin can register to be called whenever an "interesting event" occurs. It does so by calling cPluginManager's AddHook() function and implementing a callback function to handle the event.

          +

          A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it from them. This is determined by the return value from the hook callback function. If the function returns false or no value, the event is propagated further. If the function returns true, the processing is stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior for the event). See each hook's details to see the exact behavior.

          + +
          Hook nameCalled when
          + + + + +]]); for i, hook in ipairs(Hooks) do if (hook.DefaultFnName == nil) then -- The hook is not documented yet - f:write("\n"); + f:write(" \n \n \n \n"); table.insert(UndocumentedHooks, hook.Name); else - f:write("\n"); + f:write(" \n \n \n \n"); WriteHtmlHook(hook); end end - f:write([[
          Hook nameCalled when
          " .. hook.Name .. "(No documentation yet)
          " .. hook.Name .. "(No documentation yet)
          " .. hook.Name .. "" .. LinkifyString(hook.CalledWhen) .. "
          " .. hook.Name .. "" .. LinkifyString(hook.CalledWhen) .. "
          -

          Extra pages

          -

          The following pages provide various extra information

          -
            ]]); + f:write([[ + +
            +

            Extra pages

            + +

            The following pages provide various extra information

            + +
              +]]); for i, extra in ipairs(g_APIDesc.ExtraPages) do local SrcFileName = g_PluginFolder .. "/" .. extra.FileName; if (cFile:Exists(SrcFileName)) then @@ -262,14 +283,15 @@ function DumpAPIHtml() cFile:Delete(DstFileName); end cFile:Copy(SrcFileName, DstFileName); - f:write("
            • " .. extra.Title .. "
            • \n"); + f:write("
            • " .. extra.Title .. "
            • \n"); else - f:write("
            • " .. extra.Title .. " (file is missing)
            • \n"); + f:write("
            • " .. extra.Title .. " (file is missing)
            • \n"); end end - f:write([[
            - - ]]); + f:write([[
          +
          + +]]); f:close(); -- Copy the CSS file to the output folder (overwrite any existing): @@ -670,16 +692,16 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("

          Functions inherited from " .. a_InheritedName .. "

          "); + cf:write("

          Functions inherited from " .. a_InheritedName .. "

          \n"); end - cf:write("\n"); + cf:write("
          NameParametersReturn valueNotes
          \n \n \n \n \n \n \n"); for i, func in ipairs(a_Functions) do - cf:write(""); - cf:write(""); - cf:write(""); - cf:write("\n"); + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n"); + cf:write(" \n \n"); end - cf:write("
          NameParametersReturn valueNotes
          " .. func.Name .. "" .. LinkifyString(func.Params or "").. "" .. LinkifyString(func.Return or "").. "" .. LinkifyString(func.Notes or "") .. "
          " .. func.Name .. "" .. LinkifyString(func.Params or "").. "" .. LinkifyString(func.Return or "").. "" .. LinkifyString(func.Notes or "") .. "
          \n"); + cf:write(" \n\n"); end local function WriteDescendants(a_Descendants) @@ -703,67 +725,77 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) CurrInheritance = CurrInheritance.Inherits; end - cf:write([[MCServer API - ]] .. a_ClassAPI.Name .. [[ class - - - - -

          Contents

          -
            - ]]); + cf:write([[ + + + MCServer API - ]] .. a_ClassAPI.Name .. [[ + + + + + +
            +
            +

            ]] .. a_ClassAPI.Name .. [[

            +
            +
            +

            Contents

            + + "); + cf:write("
          \n\n"); -- Write the class description: - cf:write("

          " .. a_ClassAPI.Name .. " class

          \n"); + cf:write("

          Class " .. a_ClassAPI.Name .. "

          \n"); if (a_ClassAPI.Desc ~= nil) then - cf:write("

          "); + cf:write("

          "); cf:write(LinkifyString(a_ClassAPI.Desc)); - cf:write("

          \n"); + cf:write("

          \n\n"); end; -- Write the inheritance, if available: if (HasInheritance) then - cf:write("

          Inheritance

          \n"); + cf:write(" \n

          Inheritance

          \n"); if (#InheritanceChain > 0) then - cf:write("

          This class inherits from the following parent classes:

            \n"); + cf:write("

            This class inherits from the following parent classes:

            \n\n

            \n"); + cf:write("
          \n\n"); end if (#a_ClassAPI.Descendants > 0) then - cf:write("

          This class has the following descendants:\n"); + cf:write("

          This class has the following descendants:\n"); WriteDescendants(a_ClassAPI.Descendants); - cf:write("

          \n"); + cf:write("

          \n\n"); end end -- Write the constants: - cf:write("

          Constants

          \n"); - cf:write("\n"); + cf:write("

          Constants

          \n"); + cf:write("
          NameValueNotes
          \n \n \n \n \n \n"); for i, cons in ipairs(a_ClassAPI.Constants) do - cf:write(""); - cf:write(""); - cf:write("\n"); + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); end - cf:write("
          NameValueNotes
          " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "") .. "
          " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "") .. "
          \n"); + cf:write(" \n\n"); -- Write the functions, including the inherited ones: - cf:write("

          Functions

          \n"); + cf:write("

          Functions

          \n"); WriteFunctions(a_ClassAPI.Functions, nil); for i, cls in ipairs(InheritanceChain) do WriteFunctions(cls.Functions, cls.Name); @@ -772,12 +804,12 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the additional infos: if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("

          " .. additional.Header .. "

          \n"); + cf:write("

          " .. additional.Header .. "

          \n"); cf:write(LinkifyString(additional.Contents)); end end - cf:write(""); + cf:write(" \n \n"); cf:close(); end @@ -792,18 +824,26 @@ function WriteHtmlHook(a_Hook) LOG("Cannot write \"" .. fnam .. "\": \"" .. error .. "\"."); return; end - f:write([[MCServer API - ]] .. a_Hook.DefaultFnName .. [[ hook - - - - -

          ]] .. a_Hook.Name .. [[ hook

          -

          - ]]); + f:write([[ + + + MCServer API - Hook ]] .. a_Hook.DefaultFnName .. [[ + + + + + +

          +
          +

          ]] .. a_Hook.Name .. [[

          +
          +
          +

          +]]); f:write(LinkifyString(a_Hook.Desc)); - f:write("

          Callback function

          The default name for the callback function is "); - f:write(a_Hook.DefaultFnName .. ". It has the following signature:"); - f:write("

          function " .. a_Hook.DefaultFnName .. "(");
          +	f:write("			

          \n

          Callback function

          \n

          The default name for the callback function is "); + f:write(a_Hook.DefaultFnName .. ". It has the following signature:\n\n"); + f:write("

          function " .. a_Hook.DefaultFnName .. "(");
           	if (a_Hook.Params == nil) then
           		a_Hook.Params = {};
           	end
          @@ -813,23 +853,27 @@ function WriteHtmlHook(a_Hook)
           		end
           		f:write(param.Name);
           	end
          -	f:write(")

          Parameters:\n\n"); + f:write(")\n\n

          Parameters:

          \n\n
          NameTypeNotes
          \n \n \n \n \n \n"); for i, param in ipairs(a_Hook.Params) do - f:write("\n"); - end - f:write("
          NameTypeNotes
          " .. param.Name .. "" .. LinkifyString(param.Type) .. "" .. LinkifyString(param.Notes) .. "

          \n

          " .. (a_Hook.Returns or "") .. "

          \n"); - f:write([[

          Code examples

          -

          Registering the callback

          -
          -cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);
          -
          - ]]); + f:write(" \n " .. param.Name .. "\n " .. LinkifyString(param.Type) .. "\n " .. LinkifyString(param.Notes) .. "\n \n"); + end + f:write(" \n\n

          " .. (a_Hook.Returns or "") .. "

          \n\n"); + f:write([[

          Code examples

          +

          Registering the callback

          + +]]); + f:write("
          \n");
          +	f:write([[cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);]]);
          +	f:write("
          \n\n"); local Examples = a_Hook.CodeExamples or {}; for i, example in ipairs(Examples) do - f:write("

          " .. example.Title .. "

          \n"); - f:write("

          " .. example.Desc .. "

          \n"); - f:write("
          " .. example.Code .. "
          \n"); + f:write("

          " .. example.Title .. "

          \n"); + f:write("

          " .. example.Desc .. "

          \n\n"); + f:write("
          " .. example.Code .. "\n			
          \n\n"); end + f:write([[
          + +]]); f:close(); end -- cgit v1.2.3 From f8e3cbe44fd132d8eee7f6b8134ebc40260ccc9e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 16 Oct 2013 15:33:56 +0200 Subject: APIDump: Documented HOOK_WORLD_TICK. --- MCServer/Plugins/APIDump/APIDesc.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 2bede6323..f67b2f08a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3051,6 +3051,30 @@ end; ]], }, -- HOOK_SPAWNING_MONSTER + + + HOOK_WORLD_TICK = + { + CalledWhen = "Every world tick (about 20 times per second), separately for each world", + DefaultFnName = "OnWorldTick", -- also used as pagename + Desc = [[ + This hook is called for each {{cWorld|world}} every tick (50 msec, or 20 times a second). If the + world is overloaded, the interval is larger, which is indicated by the TimeDelta parameter.

          +

          + This hook is called in the world's tick thread context and thus has access to all world data + guaranteed without blocking. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World that is ticking" }, + { Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds since the previous game tick. Will not be less than 50 msec" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no overridable behavior. + ]], + }, -- HOOK_WORLD_TICK + }, -- Hooks[] -- cgit v1.2.3 From 0aa20762bc0c615751e604b0b700f51e67d38a5f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 16 Oct 2013 15:44:04 +0200 Subject: APIDump: Documented HOOK_WEATHER_CHANGING. --- MCServer/Plugins/APIDump/APIDesc.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f67b2f08a..42158f2e4 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3052,6 +3052,30 @@ end; }, -- HOOK_SPAWNING_MONSTER + HOOK_WEATHER_CHANGING = + { + CalledWhen = "The weather is about to change", + DefaultFnName = "OnWeatherChanging", -- also used as pagename + Desc = [[ + This hook is called when the current weather has expired and a new weather is selected. Plugins may + override the new weather setting.

          +

          + The new weather setting is sent to the clients only after this hook has been processed.

          +

          + See also the {{OnWeatherChanged|HOOK_WEATHER_CHANGED}} hook for a similar hook called after the + change. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather is changing" }, + { Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" }, + }, + Returns = [[ + If the function returns false or no value, the server calls other plugins' callbacks and finally + sets the weather. If the function returns true, the server takes the second returned value (wSunny + by default) and sets it as the new weather. No other plugins' callbacks are called in this case. + ]], + }, -- HOOK_WEATHER_CHANGING HOOK_WORLD_TICK = { -- cgit v1.2.3 From d688ac8e508f6797fbcf598a875a66c46f7cfc90 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 16 Oct 2013 15:47:27 +0200 Subject: APIDump: Documented HOOK_WEATHER_CHANGED. --- MCServer/Plugins/APIDump/APIDesc.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 42158f2e4..e7352beed 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3052,6 +3052,27 @@ end; }, -- HOOK_SPAWNING_MONSTER + HOOK_WEATHER_CHANGED = + { + CalledWhen = "The weather has changed", + DefaultFnName = "OnWeatherChanged", -- also used as pagename + Desc = [[ + This hook is called after the weather has changed in a {{cWorld|world}}. The new weather has already + been sent to the clients.

          +

          + See also the {{OnWeatherChanging|HOOK_WEATHER_CHANGING}} hook for a similar hook called before the + change. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather has changed" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no overridable behavior. + ]], + }, -- HOOK_WEATHER_CHANGED + HOOK_WEATHER_CHANGING = { CalledWhen = "The weather is about to change", -- cgit v1.2.3 From 1ef2e0e6a6cb63d9c58c56a59679c6a5ce7f76d4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 13:54:41 +0200 Subject: APIDump: More robust against missing APIDesc items. --- MCServer/Plugins/APIDump/main.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 22801b1e5..92425119e 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -867,9 +867,9 @@ function WriteHtmlHook(a_Hook) f:write("

        \n\n"); local Examples = a_Hook.CodeExamples or {}; for i, example in ipairs(Examples) do - f:write("

        " .. example.Title .. "

        \n"); - f:write("

        " .. example.Desc .. "

        \n\n"); - f:write("
        " .. example.Code .. "\n			
        \n\n"); + f:write("

        " .. (example.Title or "missing Title") .. "

        \n"); + f:write("

        " .. (example.Desc or "missing Desc") .. "

        \n\n"); + f:write("
        " .. (example.Code or "missing Code") .. "\n			
        \n\n"); end f:write([[ -- cgit v1.2.3 From 424807e33174e0bafe44ab009eccd22bff67f2d9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 13:54:53 +0200 Subject: APIDump: Documented HOOK_UPDATING_SIGN. --- MCServer/Plugins/APIDump/APIDesc.lua | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e7352beed..cb28b5486 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3051,6 +3051,56 @@ end; ]], }, -- HOOK_SPAWNING_MONSTER + HOOK_UPDATING_SIGN = + { + CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.", + DefaultFnName = "OnUpdatingSign", -- also used as pagename + Desc = [[ + This hook is called when a sign text is about to be updated, either as a result of player's + manipulation or any other event, such as a plugin setting the sign text. Plugins may modify the text + or refuse the update altogether.

        +

        + See also the {{OnUpdatedSign|HOOK_UPDATED_SIGN}} hook for a similar hook called after the update. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the sign" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" }, + { Name = "Line1", Type = "string", Notes = "1st line of the new text" }, + { Name = "Line2", Type = "string", Notes = "2nd line of the new text" }, + { Name = "Line3", Type = "string", Notes = "3rd line of the new text" }, + { Name = "Line4", Type = "string", Notes = "4th line of the new text" }, + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." } + }, + Returns = [[ + The function may return up to five values. If the function returns true as the first value, no other + callbacks are called for this event and the sign is not updated. If the function returns no value or + false as its first value, other plugins' callbacks are called.

        +

        + The other up to four values returned are used to update the sign text, line by line, respectively. + Note that other plugins may again update the texts (if the first value returned is false). + ]], + CodeExamples = + { + { + Title = "Add player signature", + Desc = "The following example appends a player signature to the last line, if the sign is updated by a player:", + Code = [[ +function OnUpdatingSign(World, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player) + if (Player == nil) then + -- Not changed by a player + return false; + end + + -- Sign with playername, allow other plugins to interfere: + return false, Line1, Line2, Line3, Line4 .. Player:GetName(); +end + ]], + } + } , + }, -- HOOK_UPDATING_SIGN HOOK_WEATHER_CHANGED = { -- cgit v1.2.3 From 36f6ffaadf552913df5201ca2273dfea4a18ab55 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 15:20:44 +0200 Subject: APIDump: Documented HOOK_TAKE_DAMAGE. --- MCServer/Plugins/APIDump/APIDesc.lua | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index cb28b5486..7698552e0 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3051,6 +3051,30 @@ end; ]], }, -- HOOK_SPAWNING_MONSTER + HOOK_TAKE_DAMAGE = + { + CalledWhen = "An {{cEntity|entity}} is taking any kind of damage", + DefaultFnName = "OnTakeDamage", -- also used as pagename + Desc = [[ + This hook is called when any {{cEntity}} descendant, such as a {{cPlayer|player}} or a + {{cMonster|mob}}, takes any kind of damage. The plugins may modify the amount of damage or effects + with this hook by editting the {{TakeDamageInfo}} object passed.

        +

        + This hook is called after the final damage is calculated, including all the possible weapon + {{cEnchantments|enchantments}}, armor protection and potion effects. + ]], + Params = + { + { Name = "Receiver", Type = "{{cEntity}} descendant", Notes = "The entity taking damage" }, + { Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects. Plugins may modify this object to alter the final damage applied." }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then the server + applies the final values from the TDI object to Receiver. If the function returns true, no other + callbacks are called, and no damage nor effects are applied. + ]], + }, -- HOOK_TAKE_DAMAGE + HOOK_UPDATING_SIGN = { CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.", -- cgit v1.2.3 From d3f5a979b4f1f058763c6c3bc75d8c709e916ee4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 16:07:18 +0200 Subject: APIDump: Documented HOOK_TICK. --- MCServer/Plugins/APIDump/APIDesc.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 7698552e0..b4816c85d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3075,6 +3075,28 @@ end; ]], }, -- HOOK_TAKE_DAMAGE + HOOK_TICK = + { + CalledWhen = "Every server tick (approximately 20 times per second)", + DefaultFnName = "OnTick", -- also used as pagename + Desc = [[ + This hook is called every game tick (50 msec, or 20 times a second). If the server is overloaded, + the interval is larger, which is indicated by the TimeDelta parameter.

        +

        + This hook is called in the context of the server-tick thread, that is, the thread that takes care of + {{cClientHandle|client connections}} before they're assigned to {{cPlayer|player entities}}, and + processing console commands. + ]], + Params = + { + { Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds elapsed since the last server tick. Will not be less than 50 msec." }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called. There is no overridable behavior. + ]], + }, -- HOOK_TICK + HOOK_UPDATING_SIGN = { CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.", -- cgit v1.2.3 From ed935d82bb390413f9465372ad4a0de781ad5c6c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 16:18:16 +0200 Subject: APIDump: Documented HOOK_UPDATED_SIGN. --- MCServer/Plugins/APIDump/APIDesc.lua | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b4816c85d..4500e6984 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3097,6 +3097,36 @@ end; ]], }, -- HOOK_TICK + HOOK_UPDATED_SIGN = + { + CalledWhen = "After the sign text is updated. Notification only.", + DefaultFnName = "OnUpdatedSign", -- also used as pagename + Desc = [[ + This hook is called after a sign has had its text updated. The text is already updated at this + point.

        +

        The update may have been caused either by a {{cPlayer|player}} directly updating the sign, or by + a plugin changing the sign text using the API.

        +

        + See also the {{OnUpdatingSign|HOOK_UPDATING_SIGN}} hook for a similar hook called before the update, + with a chance to modify the text. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the sign" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" }, + { Name = "Line1", Type = "string", Notes = "1st line of the new text" }, + { Name = "Line2", Type = "string", Notes = "2nd line of the new text" }, + { Name = "Line3", Type = "string", Notes = "3rd line of the new text" }, + { Name = "Line4", Type = "string", Notes = "4th line of the new text" }, + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." } + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called. There is no overridable behavior. + ]], + }, -- HOOK_UPDATED_SIGN HOOK_UPDATING_SIGN = { CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.", -- cgit v1.2.3 From 96072c9e0c4a2bc682a1c6d3a3952cac812887d4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 16:31:35 +0200 Subject: APIDump: Documented HOOK_PLAYER_USING_ITEM. --- MCServer/Plugins/APIDump/APIDesc.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4500e6984..1ed2f82e6 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,42 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_USING_ITEM = + { + CalledWhen = "Just before a player uses an item at hand (bucket...). Plugin may override / refuse.", + DefaultFnName = "OnPlayerUsingItem", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that + can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a + hoe. It is called before MCServer processes the usage (places fluid / turns dirt to farmland). + Plugins may refuse the interaction by returning true.

        +

        + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

        +

        + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get + the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the item" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + processes the interaction. If the function returns true, no other callbacks are called for this + event and the interaction is silently dropped. + ]], + }, -- HOOK_PLAYER_USING_ITEM + HOOK_POST_CRAFTING = { CalledWhen = "After the built-in recipes are checked and a recipe was found.", -- cgit v1.2.3 From 91f7662a51efe129e64d9952be22463760b25331 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 16:38:46 +0200 Subject: APIDump: Documented HOOK_PLAYER_USING_BLOCK. --- MCServer/Plugins/APIDump/APIDesc.lua | 47 ++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1ed2f82e6..5899ba3f5 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,9 +2894,48 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_USING_BLOCK = + { + CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.", + DefaultFnName = "OnPlayerUsingBlock", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} has right-clicked a block that can be used, such as a + {{cChestEntity|chest}} or a lever. It is called before MCServer processes the usage (sends the UI + handling packets / toggles redstone). Plugins may refuse the interaction by returning true.

        +

        + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

        +

        + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.

        +

        + See also the {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for a similar hook called after the use, the + {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for + similar hooks called when a player interacts with any block with a usable item in hand, such as a + bucket. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + processes the interaction. If the function returns true, no other callbacks are called for this + event and the interaction is silently dropped. + ]], + }, -- HOOK_PLAYER_USING_BLOCK + HOOK_PLAYER_USING_ITEM = { - CalledWhen = "Just before a player uses an item at hand (bucket...). Plugin may override / refuse.", + CalledWhen = "Just before a player uses an item in hand (bucket...). Plugin may override / refuse.", DefaultFnName = "OnPlayerUsingItem", -- also used as pagename Desc = [[ This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that @@ -2908,7 +2947,11 @@ end; not the air block between it and the player.

        To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get - the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function. + the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.

        +

        + See also the {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for a similar hook called after the use, the + {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for + similar hooks called when a player interacts with a block, such as a chest. ]], Params = { -- cgit v1.2.3 From dfd4c78c874fe3509a3a69356b32399c7439f689 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 17:10:46 +0200 Subject: APIDump: Documented HOOK_PLAYER_USED_ITEM. --- MCServer/Plugins/APIDump/APIDesc.lua | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 5899ba3f5..dba487f09 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,45 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_USED_ITEM = + { + CalledWhen = "A player has used an item in hand (bucket...)", + DefaultFnName = "OnPlayerUsedItem", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that + can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a + hoe. It is called after MCServer processes the usage (places fluid / turns dirt to farmland). + This is an information-only hook, there is no way to cancel the event anymore.

        +

        + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

        +

        + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get + the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.

        +

        + See also the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} for a similar hook called before the use, + the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} + for similar hooks called when a player interacts with a block, such as a chest. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the item" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. + ]], + }, -- HOOK_PLAYER_USED_ITEM + HOOK_PLAYER_USING_BLOCK = { CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.", -- cgit v1.2.3 From fd7c1754d017e419850761b0cdd05198cf07ad3a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 17 Oct 2013 17:14:57 +0200 Subject: APIDump: Documented HOOK_PLAYER_USED_BLOCK. --- MCServer/Plugins/APIDump/APIDesc.lua | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index dba487f09..1d1d0ead9 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,45 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_USED_BLOCK = + { + CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", + DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a + {{cChestEntity|chest}} or a lever. It is called after MCServer processes the usage (sends the UI + handling packets / toggles redstone). Note that for UI-related blocks, the player is most likely + still using the UI. This is a notification-only event.

        +

        + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

        +

        + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.

        +

        + See also the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} for a similar hook called before the + use, the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} + for similar hooks called when a player interacts with any block with a usable item in hand, such as + a bucket. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. + ]], + }, -- HOOK_PLAYER_USED_BLOCK + HOOK_PLAYER_USED_ITEM = { CalledWhen = "A player has used an item in hand (bucket...)", -- cgit v1.2.3 From 1f6498de22dd0404e5e74faf2e304969622a06de Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 09:40:18 +0200 Subject: APIDump: Documented HOOK_PLAYER_TOSSING_ITEM. --- MCServer/Plugins/APIDump/APIDesc.lua | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1d1d0ead9..f1f9be275 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,29 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_TOSSING_ITEM = + { + CalledWhen = "A player is tossing an item. Plugin may override / refuse.", + DefaultFnName = "OnPlayerTossingItem", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} has tossed an item (Q keypress). The + {{cPickup|pickup}} has not been spawned yet. Plugins may disallow the tossing, but in that case they + need to clean up - the player's client already thinks the item has been tossed so the + {{cInventory|inventory}} needs to be re-sent to the player.

        +

        + To get the item that is about to be tossed, call the {{cPlayer}}:GetEquippedItem() function. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player tossing an item" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and finally MCServer + creates the pickup for the item and tosses it, using {{cPlayer}}:TossItem. If the function returns + true, no other callbacks are called for this event and MCServer doesn't toss the item. + ]], + }, -- HOOK_PLAYER_TOSSING_ITEM + HOOK_PLAYER_USED_BLOCK = { CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", -- cgit v1.2.3 From 8020cbd3d7add94deacb17af47429f20f76f3a23 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 09:47:21 +0200 Subject: APIDump: Documented HOOK_PLAYER_SPAWNED. --- MCServer/Plugins/APIDump/APIDesc.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f1f9be275..d8aa77b19 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,31 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_SPAWNED = + { + CalledWhen = "After a player (re)spawns in the world to which they belong to.", + DefaultFnName = "OnPlayerSpawned", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has spawned in the world. It is called after + {{OnLogin|HOOK_LOGIN}} and {{OnPlayerJoined|HOOK_PLAYER_JOINED}}, after the player name has been + authenticated, the initial worldtime, inventory and health have been sent to the player and the + player spawn packet has been broadcast to all players near enough to the player spawn place. This is + a notification-only event, plugins wishing to refuse player's entry should kick the player using the + {{cPlayer}}:Kick() function.

        +

        + This hook is also called when the player respawns after death (and a respawn packet is received from + the client, meaning the player has already clicked the Respawn button). + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has (re)spawned" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. There is no overridable behavior. + ]], + }, -- HOOK_PLAYER_SPAWNED + HOOK_PLAYER_TOSSING_ITEM = { CalledWhen = "A player is tossing an item. Plugin may override / refuse.", -- cgit v1.2.3 From 5a31d191eb9f12f20899db3ff1361891f29e4e10 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 09:57:35 +0200 Subject: APIDump: Documented HOOK_PLAYER_SHOOTING. --- MCServer/Plugins/APIDump/APIDesc.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index d8aa77b19..4c22853f7 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,31 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_SHOOTING = + { + CalledWhen = "When the player releases the bow, shooting an arrow (other projectiles: unknown)", + DefaultFnName = "OnPlayerShooting", -- also used as pagename + Desc = [[ + This hook is called when the {{cPlayer|player}} shoots their bow. It is called for the actual + release of the {{cArrowEntity|arrow}}. FIXME: It is currently unknown whether other + {{cProjectileEntity|projectiles}} (snowballs, eggs) trigger this hook.

        +

        + To get the player's position and direction, use the {{cPlayer}}:GetEyePosition() and + cPlayer:GetLookVector() functions. Note that for shooting a bow, the position for the arrow creation + is not at the eye pos, some adjustments are required. FIXME: Export the {{cPlayer}} function for + this adjustment. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player shooting" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called, and finally + MCServer creates the projectile. If the functino returns true, no other callback is called and no + projectile is created. + ]], + }, -- HOOK_PLAYER_SHOOTING + HOOK_PLAYER_SPAWNED = { CalledWhen = "After a player (re)spawns in the world to which they belong to.", -- cgit v1.2.3 From 9776b89fb7d9eb99fdf6e3487927b92c8725a2f0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 10:04:44 +0200 Subject: APIDump: Documented HOOK_PLAYER_RIGHT_CLICKING_ENTITY. --- MCServer/Plugins/APIDump/APIDesc.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4c22853f7..2ea51dbf2 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2894,6 +2894,26 @@ end; ]], }, -- HOOK_PLAYER_RIGHT_CLICK + HOOK_PLAYER_RIGHT_CLICKING_ENTITY = + { + CalledWhen = "A player has right-clicked an entity. Plugins may override / refuse.", + DefaultFnName = "OnPlayerRightClickingEntity", -- also used as pagename + Desc = [[ + This hook is called when the {{cPlayer|player}} right-clicks an {{cEntity|entity}}. Plugins may + override the default behavior or even cancel the default processing. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has right-clicked the entity" }, + { Name = "Entity", Type = "{{cEntity}} descendant", Notes = "The entity that has been right-clicked" }, + }, + Returns = [[ + If the functino returns false or no value, MCServer calls other plugins' callbacks and finally does + the default processing for the right-click. If the function returns true, no other callbacks are + called and the default processing is skipped. + ]], + }, -- HOOK_PLAYER_RIGHT_CLICKING_ENTITY + HOOK_PLAYER_SHOOTING = { CalledWhen = "When the player releases the bow, shooting an arrow (other projectiles: unknown)", -- cgit v1.2.3 From 5992c41501a0f3732bef3ac768287104812c1111 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 11:56:58 +0200 Subject: APIDump: Improved page titles. --- MCServer/Plugins/APIDump/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 92425119e..1f814fc68 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -728,7 +728,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write([[ - MCServer API - ]] .. a_ClassAPI.Name .. [[ + MCServer API - ]] .. a_ClassAPI.Name .. [[ Class @@ -827,7 +827,7 @@ function WriteHtmlHook(a_Hook) f:write([[ - MCServer API - Hook ]] .. a_Hook.DefaultFnName .. [[ + MCServer API - ]] .. a_Hook.DefaultFnName .. [[ Hook -- cgit v1.2.3 From 22102b4a644fa9ca2abdac791a31ad70dd7641ec Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 12:30:06 +0200 Subject: APIDump: Makes a list of bad links. This fixes #219. --- MCServer/Plugins/APIDump/main.lua | 95 ++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 17 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 1f814fc68..0ca68e107 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -10,6 +10,7 @@ -- Global variables: g_Plugin = nil; g_PluginFolder = ""; +g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames. @@ -262,7 +263,7 @@ function DumpAPIHtml() f:write(" \n " .. hook.Name .. "\n (No documentation yet)\n \n"); table.insert(UndocumentedHooks, hook.Name); else - f:write(" \n " .. hook.Name .. "\n " .. LinkifyString(hook.CalledWhen) .. "\n \n"); + f:write(" \n " .. hook.Name .. "\n " .. LinkifyString(hook.CalledWhen, hook.Name) .. "\n \n"); WriteHtmlHook(hook); end end @@ -399,6 +400,9 @@ function DumpAPIHtml() f:close(); end + -- List the missing pages + ListMissingPages(); + LOG("API subfolder written"); end @@ -638,7 +642,18 @@ end -- Make a link out of anything with the special linkifying syntax {{link|title}} -function LinkifyString(a_String) +function LinkifyString(a_String, a_Referrer) + assert(a_Referrer ~= nil); + assert(a_Referrer ~= ""); + + --- Adds a page to the list of tracked pages (to be checked for existence at the end) + local function AddTrackedPage(a_PageName) + local Pg = (g_TrackedPages[a_PageName] or {}); + table.insert(Pg, a_Referrer); + g_TrackedPages[a_PageName] = Pg; + end + + --- Creates the HTML for the specified link and title local function CreateLink(Link, Title) if (Link:sub(1, 7) == "http://") then -- The link is a full absolute URL, do not modify, do not track: @@ -652,16 +667,17 @@ function LinkifyString(a_String) return "" .. Title .. ""; end -- Anchor in another page: - -- TODO: track this link - return "" .. Title .. ""; + local PageName = Link:sub(1, idxHash - 1); + AddTrackedPage(PageName); + return "" .. Title .. ""; end -- Link without anchor: - -- TODO; track this link + AddTrackedPage(Link); return "" .. Title .. ""; end + -- Linkify the strings using the CreateLink() function: local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", CreateLink) -- {{link|title}} - txt = txt:gsub("{{([^|}]*)}}", -- {{LinkAndTitle}} function(LinkAndTitle) local idxHash = LinkAndTitle:find("#"); @@ -697,9 +713,9 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" \n \n \n \n \n \n \n"); for i, func in ipairs(a_Functions) do cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n"); - cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n"); + cf:write(" \n \n"); end cf:write("
        NameParametersReturn valueNotes
        " .. func.Name .. "" .. LinkifyString(func.Params or "").. "" .. LinkifyString(func.Return or "").. "" .. LinkifyString(func.Notes or "") .. "
        " .. LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)).. "" .. LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)).. "" .. LinkifyString(func.Notes or "", (a_InheritedName or a_ClassAPI.Name)) .. "
        \n\n"); end @@ -716,6 +732,8 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end cf:write("

      \n"); end + + local ClassName = a_ClassAPI.Name; -- Build an array of inherited classes chain: local InheritanceChain = {}; @@ -760,10 +778,10 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write("
    \n\n"); -- Write the class description: - cf:write("

    Class " .. a_ClassAPI.Name .. "

    \n"); + cf:write("

    Class " .. ClassName .. "

    \n"); if (a_ClassAPI.Desc ~= nil) then cf:write("

    "); - cf:write(LinkifyString(a_ClassAPI.Desc)); + cf:write(LinkifyString(a_ClassAPI.Desc, ClassName)); cf:write("

    \n\n"); end; @@ -790,7 +808,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) for i, cons in ipairs(a_ClassAPI.Constants) do cf:write(" \n " .. cons.Name .. "\n"); cf:write(" " .. cons.Value .. "\n"); - cf:write(" " .. LinkifyString(cons.Notes or "") .. "\n \n"); + cf:write(" " .. LinkifyString(cons.Notes or "", ClassName) .. "\n \n"); end cf:write(" \n\n"); @@ -805,7 +823,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do cf:write("

    " .. additional.Header .. "

    \n"); - cf:write(LinkifyString(additional.Contents)); + cf:write(LinkifyString(additional.Contents, ClassName)); end end @@ -824,10 +842,12 @@ function WriteHtmlHook(a_Hook) LOG("Cannot write \"" .. fnam .. "\": \"" .. error .. "\"."); return; end + local HookName = a_Hook.DefaultFnName; + f:write([[ - MCServer API - ]] .. a_Hook.DefaultFnName .. [[ Hook + MCServer API - ]] .. HookName .. [[ Hook @@ -840,10 +860,10 @@ function WriteHtmlHook(a_Hook)

    ]]); - f:write(LinkifyString(a_Hook.Desc)); + f:write(LinkifyString(a_Hook.Desc, HookName)); f:write("

    \n

    Callback function

    \n

    The default name for the callback function is "); f:write(a_Hook.DefaultFnName .. ". It has the following signature:\n\n"); - f:write("

    function " .. a_Hook.DefaultFnName .. "(");
    +	f:write("			
    function " .. HookName .. "(");
     	if (a_Hook.Params == nil) then
     		a_Hook.Params = {};
     	end
    @@ -855,7 +875,7 @@ function WriteHtmlHook(a_Hook)
     	end
     	f:write(")
    \n\n

    Parameters:

    \n\n \n \n \n \n \n \n"); for i, param in ipairs(a_Hook.Params) do - f:write(" \n \n \n \n \n"); + f:write(" \n \n \n \n \n"); end f:write("
    NameTypeNotes
    " .. param.Name .. "" .. LinkifyString(param.Type) .. "" .. LinkifyString(param.Notes) .. "
    " .. param.Name .. "" .. LinkifyString(param.Type, HookName) .. "" .. LinkifyString(param.Notes, HookName) .. "
    \n\n

    " .. (a_Hook.Returns or "") .. "

    \n\n"); f:write([[

    Code examples

    @@ -880,3 +900,44 @@ end + +function ListMissingPages() + local MissingPages = {}; + for PageName, Referrers in pairs(g_TrackedPages) do + if not(cFile:Exists("API/" .. PageName .. ".html")) then + table.insert(MissingPages, {Name = PageName, Refs = Referrers} ); + end + end; + g_TrackedPages = {}; + + if (#MissingPages == 0) then + -- No missing pages, congratulations! + return; + end + + -- Sort the pages by name: + table.sort(MissingPages, + function (Page1, Page2) + return (Page1.Name < Page2.Name); + end + ); + + -- Output the pages: + local f, err = io.open("API/_missingPages.txt", "w"); + if (f == nil) then + LOGWARNING("Cannot open _missingPages.txt for writing: '" .. err .. "'. There are " .. #MissingPages .. " pages missing."); + return; + end + for idx, pg in ipairs(MissingPages) do + f:write(pg.Name .. ":\n"); + -- Sort and output the referrers: + table.sort(pg.Refs); + f:write("\t" .. table.concat(pg.Refs, "\n\t")); + f:write("\n\n"); + end + f:close(); +end + + + + -- cgit v1.2.3 From 1c0ab57d12710c87cd206561813ca503b4199b7c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 12:33:46 +0200 Subject: APIDump: Renamed output for helper stuff. Undocumented objects are output to _undocumented.lua Overdocumented objects are output to _unexported-documented.txt Missing pages are output to _missingPages.txt --- MCServer/Plugins/APIDump/main.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 0ca68e107..22c7ad764 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -308,7 +308,7 @@ function DumpAPIHtml() end -- List the undocumented objects: - f = io.open("API/undocumented.lua", "w"); + f = io.open("API/_undocumented.lua", "w"); if (f ~= nil) then f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); @@ -374,7 +374,7 @@ function DumpAPIHtml() end -- List the unexported documented API objects: - f = io.open("API/unexported-documented.txt", "w"); + f = io.open("API/_unexported-documented.txt", "w"); if (f ~= nil) then for clsname, cls in pairs(g_APIDesc.Classes) do if not(cls.IsExported) then -- cgit v1.2.3 From 201c84afb37def9f4d10f60557813d904c7001f3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 20:21:26 +0200 Subject: APIDump: using local JS files instead of networked. This allows offline API browsing. --- MCServer/Plugins/APIDump/lang-lua.js | 59 ++++++++++++++++++++++++++++++++ MCServer/Plugins/APIDump/main.lua | 11 +++--- MCServer/Plugins/APIDump/run_prettify.js | 34 ++++++++++++++++++ 3 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 MCServer/Plugins/APIDump/lang-lua.js create mode 100644 MCServer/Plugins/APIDump/run_prettify.js (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/lang-lua.js b/MCServer/Plugins/APIDump/lang-lua.js new file mode 100644 index 000000000..7a3f9766d --- /dev/null +++ b/MCServer/Plugins/APIDump/lang-lua.js @@ -0,0 +1,59 @@ +// Copyright (C) 2008 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + + + +/** + * @fileoverview + * Registers a language handler for Lua. + * + * + * To use, include prettify.js and this file in your HTML page. + * Then put your code in an HTML tag like + *
    (my Lua code)
    + * + * + * I used http://www.lua.org/manual/5.1/manual.html#2.1 + * Because of the long-bracket concept used in strings and comments, Lua does + * not have a regular lexical grammar, but luckily it fits within the space + * of irregular grammars supported by javascript regular expressions. + * + * @author mikesamuel@gmail.com + */ + +PR['registerLangHandler']( + PR['createSimpleLexer']( + [ + // Whitespace + [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], + // A double or single quoted, possibly multi-line, string. + [PR['PR_STRING'], /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/, null, '"\''] + ], + [ + // A comment is either a line comment that starts with two dashes, or + // two dashes preceding a long bracketed block. + [PR['PR_COMMENT'], /^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/], + // A long bracketed block not preceded by -- is a string. + [PR['PR_STRING'], /^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/], + [PR['PR_KEYWORD'], /^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, null], + // A number is a hex integer literal, a decimal real literal, or in + // scientific notation. + [PR['PR_LITERAL'], + /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], + // An identifier + [PR['PR_PLAIN'], /^[a-z_]\w*/i], + // A run of punctuation + [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/] + ]), + ['lua']); diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 22c7ad764..a40600349 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -307,6 +307,9 @@ function DumpAPIHtml() cssf:close(); end + cFile:Copy(g_Plugin:GetLocalDirectory() .. "/run_prettify.js", "API/run_prettify.js"); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); + -- List the undocumented objects: f = io.open("API/_undocumented.lua", "w"); if (f ~= nil) then @@ -748,8 +751,8 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) MCServer API - ]] .. a_ClassAPI.Name .. [[ Class - - + +
    @@ -849,8 +852,8 @@ function WriteHtmlHook(a_Hook) MCServer API - ]] .. HookName .. [[ Hook - - + +
    diff --git a/MCServer/Plugins/APIDump/run_prettify.js b/MCServer/Plugins/APIDump/run_prettify.js new file mode 100644 index 000000000..e3d9a9c29 --- /dev/null +++ b/MCServer/Plugins/APIDump/run_prettify.js @@ -0,0 +1,34 @@ +!function(){var r=null; +(function(){function X(e){function j(){try{J.doScroll("left")}catch(e){P(j,50);return}w("poll")}function w(j){if(!(j.type=="readystatechange"&&x.readyState!="complete")&&((j.type=="load"?n:x)[z](i+j.type,w,!1),!m&&(m=!0)))e.call(n,j.type||j)}var Y=x.addEventListener,m=!1,C=!0,t=Y?"addEventListener":"attachEvent",z=Y?"removeEventListener":"detachEvent",i=Y?"":"on";if(x.readyState=="complete")e.call(n,"lazy");else{if(x.createEventObject&&J.doScroll){try{C=!n.frameElement}catch(A){}C&&j()}x[t](i+"DOMContentLoaded", +w,!1);x[t](i+"readystatechange",w,!1);n[t](i+"load",w,!1)}}function Q(){S&&X(function(){var e=K.length;$(e?function(){for(var j=0;j=0;){var M=A[m],T=M.src.match(/^[^#?]*\/run_prettify\.js(\?[^#]*)?(?:#.*)?$/);if(T){z=T[1]||"";M.parentNode.removeChild(M); +break}}var S=!0,D=[],N=[],K=[];z.replace(/[&?]([^&=]+)=([^&]+)/g,function(e,j,w){w=decodeURIComponent(w);j=decodeURIComponent(j);j=="autorun"?S=!/^[0fn]/i.test(w):j=="lang"?D.push(w):j=="skin"?N.push(w):j=="callback"&&K.push(w)});m=0;for(z=D.length;m122||(o<65||k>90||f.push([Math.max(65,k)|32,Math.min(o,90)|32]),o<97||k>122||f.push([Math.max(97,k)&-33,Math.min(o,122)&-33]))}}f.sort(function(f, +a){return f[0]-a[0]||a[1]-f[1]});b=[];g=[];for(a=0;ak[0]&&(k[1]+1>k[0]&&c.push("-"),c.push(h(k[1])));c.push("]");return c.join("")}function e(f){for(var a=f.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],g=0,k=0;g=2&&f==="["?a[g]=b(o):f!=="\\"&&(a[g]=o.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var j=0,F=!1,l=!1,I=0,c=a.length;I=5&&"lang-"===y.substring(0,5))&&!(u&&typeof u[1]==="string"))g=!1,y="src";g||(m[B]=y)}k=c;c+=B.length;if(g){g=u[1];var o=B.indexOf(g),H=o+g.length;u[2]&&(H=B.length-u[2].length,o=H-g.length);y=y.substring(5);n(l+k,B.substring(0,o),h, +j);n(l+k+o,g,A(y,g),j);n(l+k+H,B.substring(H),h,j)}else j.push(l+k,y)}a.g=j}var b={},e;(function(){for(var h=a.concat(d),l=[],i={},c=0,p=h.length;c=0;)b[q.charAt(f)]=m;m=m[1];q=""+m;i.hasOwnProperty(q)||(l.push(m),i[q]=r)}l.push(/[\S\s]/);e=j(l)})();var i=d.length;return h}function t(a){var d=[],h=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/, +r,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,r,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,r,"\"'"]);a.verbatimStrings&&h.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,r]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,r,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/, +r,"#"]),h.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,r])):d.push(["com",/^#[^\n\r]*/,r,"#"]));a.cStyleComments&&(h.push(["com",/^\/\/[^\n\r]*/,r]),h.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,r]));if(b=a.regexLiterals){var e=(b=b>1?"":"\n\r")?".":"[\\S\\s]";h.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+ +("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+e+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+e+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&h.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&h.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),r]);d.push(["pln",/^\s+/,r," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");h.push(["lit",/^@[$_a-z][\w$@]*/i,r],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,r],["pln",/^[$_a-z][\w$@]*/i,r],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i, +r,"0123456789"],["pln",/^\\[\S\s]?/,r],["pun",RegExp(b),r]);return C(d,h)}function z(a,d,h){function b(a){var c=a.nodeType;if(c==1&&!j.test(a.className))if("br"===a.nodeName)e(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&h){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(l.createTextNode(d),a.nextSibling),e(a),c||a.parentNode.removeChild(a)}} +function e(a){function b(a,c){var d=c?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),h=a.nextSibling;f.appendChild(d);for(var e=h;e;e=h)h=e.nextSibling,f.appendChild(e)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var j=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,l=a.ownerDocument,i=l.createElement("li");a.firstChild;)i.appendChild(a.firstChild);for(var c=[i],p=0;p=0;){var b=d[h];U.hasOwnProperty(b)?V.console&&console.warn("cannot override language handler %s",b):U[b]=a}}function A(a,d){if(!a||!U.hasOwnProperty(a))a=/^\s*=o&&(b+=2);h>=H&&(t+=2)}}finally{if(g)g.style.display=k}}catch(v){V.console&&console.log(v&&v.stack||v)}}var V=window,G=["break,continue,do,else,for,if,return,while"],O=[[G,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],J=[O,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],K=[O,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], +L=[K,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],O=[O,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],M=[G,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +N=[G,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],R=[G,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],G=[G,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],Q=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, +S=/\S/,T=t({keywords:[J,L,O,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",M,N,G],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),U={};i(T,["default-code"]);i(C([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", +/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);i(C([["pln",/^\s+/,r," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,r,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/], +["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);i(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);i(t({keywords:J,hashComments:!0,cStyleComments:!0,types:Q}),["c","cc","cpp","cxx","cyc","m"]);i(t({keywords:"null,true,false"}),["json"]);i(t({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:Q}), +["cs"]);i(t({keywords:K,cStyleComments:!0}),["java"]);i(t({keywords:G,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);i(t({keywords:M,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);i(t({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);i(t({keywords:N, +hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);i(t({keywords:O,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);i(t({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);i(t({keywords:R,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]); +i(C([],[["str",/^[\S\s]+/]]),["regex"]);var X=V.PR={createSimpleLexer:C,registerLangHandler:i,sourceDecorator:t,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:function(a,d,e){var b=document.createElement("div");b.innerHTML="
    "+a+"
    ";b=b.firstChild;e&&z(b,e,!0);D({h:d,j:e,c:b,i:1});return b.innerHTML}, +prettyPrint:e=e=function(a,d){function e(){for(var b=V.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;p Date: Fri, 18 Oct 2013 20:22:24 +0200 Subject: APIDump: Ignore internal APIDump stuff. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 2ea51dbf2..fc7edb07e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3509,6 +3509,7 @@ end "os", "string", "table", + "g_TrackedPages", }, IgnoreFunctions = @@ -3528,6 +3529,7 @@ end "DumpAPITxt", "Initialize", "LinkifyString", + "ListMissingPages", "ReadDescriptions", "ReadHooks", "WriteHtmlClass", -- cgit v1.2.3 From 778d78634916a3441e53047b0e03b2731da55829 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 20:32:36 +0200 Subject: APIDump: Split long code into functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 + MCServer/Plugins/APIDump/main.lua | 202 +++++++++++++++++++---------------- 2 files changed, 110 insertions(+), 94 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index fc7edb07e..4961c9baf 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3530,6 +3530,8 @@ end "Initialize", "LinkifyString", "ListMissingPages", + "ListUndocumentedObjects", + "ListUnexportedObjects", "ReadDescriptions", "ReadHooks", "WriteHtmlClass", diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index a40600349..8d0f9f544 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -310,100 +310,9 @@ function DumpAPIHtml() cFile:Copy(g_Plugin:GetLocalDirectory() .. "/run_prettify.js", "API/run_prettify.js"); cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); - -- List the undocumented objects: - f = io.open("API/_undocumented.lua", "w"); - if (f ~= nil) then - f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); - f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); - for i, cls in ipairs(API) do - local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); - local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); - if (HasFunctions or HasConstants) then - f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); - if ((cls.Desc == nil) or (cls.Desc == "")) then - f:write("\t\t\tDesc = \"\"\n"); - end - end - - if (HasFunctions) then - f:write("\t\t\tFunctions =\n\t\t\t{\n"); - table.sort(cls.UndocumentedFunctions); - for j, fn in ipairs(cls.UndocumentedFunctions) do - f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); - end -- for j, fn - cls.Undocumented[] - f:write("\t\t\t},\n\n"); - end - - if (HasConstants) then - f:write("\t\t\tConstants =\n\t\t\t{\n"); - table.sort(cls.UndocumentedConstants); - for j, cn in ipairs(cls.UndocumentedConstants) do - f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); - end -- for j, fn - cls.Undocumented[] - f:write("\t\t\t},\n\n"); - end - - if (HasFunctions or HasConstants) then - f:write("\t\t},\n\n"); - end - end -- for i, cls - API[] - f:write("\t},\n"); - - if (#UndocumentedHooks > 0) then - f:write("\n\tHooks =\n\t{\n"); - for i, hook in ipairs(UndocumentedHooks) do - if (i > 1) then - f:write("\n"); - end - f:write("\t\t" .. hook .. " =\n\t\t{\n"); - f:write("\t\t\tCalledWhen = \"\",\n"); - f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); - f:write("\t\t\tDesc = [[\n\t\t\t\t\n\t\t\t]],\n"); - f:write("\t\t\tParams =\n\t\t\t{\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t},\n"); - f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); - f:write("\t\t}, -- " .. hook .. "\n"); - end - end - f:close(); - end - - -- List the unexported documented API objects: - f = io.open("API/_unexported-documented.txt", "w"); - if (f ~= nil) then - for clsname, cls in pairs(g_APIDesc.Classes) do - if not(cls.IsExported) then - -- The whole class is not exported - f:write("class\t" .. clsname .. "\n"); - else - if (cls.Functions ~= nil) then - for fnname, fnapi in pairs(cls.Functions) do - if not(fnapi.IsExported) then - f:write("func\t" .. clsname .. "." .. fnname .. "\n"); - end - end -- for j, fn - cls.Functions[] - end - if (cls.Constants ~= nil) then - for cnname, cnapi in pairs(cls.Constants) do - if not(cnapi.IsExported) then - f:write("const\t" .. clsname .. "." .. cnname .. "\n"); - end - end -- for j, fn - cls.Functions[] - end - end - end -- for i, cls - g_APIDesc.Classes[] - f:close(); - end - - -- List the missing pages + -- List the documentation problems: + ListUndocumentedObjects(API, UndocumentedHooks); + ListUnexportedObjects(); ListMissingPages(); LOG("API subfolder written"); @@ -904,6 +813,111 @@ end +--- Writes a list of undocumented objects into a file +function ListUndocumentedObjects(API, UndocumentedHooks) + f = io.open("API/_undocumented.lua", "w"); + if (f ~= nil) then + f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); + f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); + for i, cls in ipairs(API) do + local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); + local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); + if (HasFunctions or HasConstants) then + f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); + if ((cls.Desc == nil) or (cls.Desc == "")) then + f:write("\t\t\tDesc = \"\"\n"); + end + end + + if (HasFunctions) then + f:write("\t\t\tFunctions =\n\t\t\t{\n"); + table.sort(cls.UndocumentedFunctions); + for j, fn in ipairs(cls.UndocumentedFunctions) do + f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); + end -- for j, fn - cls.Undocumented[] + f:write("\t\t\t},\n\n"); + end + + if (HasConstants) then + f:write("\t\t\tConstants =\n\t\t\t{\n"); + table.sort(cls.UndocumentedConstants); + for j, cn in ipairs(cls.UndocumentedConstants) do + f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); + end -- for j, fn - cls.Undocumented[] + f:write("\t\t\t},\n\n"); + end + + if (HasFunctions or HasConstants) then + f:write("\t\t},\n\n"); + end + end -- for i, cls - API[] + f:write("\t},\n"); + + if (#UndocumentedHooks > 0) then + f:write("\n\tHooks =\n\t{\n"); + for i, hook in ipairs(UndocumentedHooks) do + if (i > 1) then + f:write("\n"); + end + f:write("\t\t" .. hook .. " =\n\t\t{\n"); + f:write("\t\t\tCalledWhen = \"\",\n"); + f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); + f:write("\t\t\tDesc = [[\n\t\t\t\t\n\t\t\t]],\n"); + f:write("\t\t\tParams =\n\t\t\t{\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t},\n"); + f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); + f:write("\t\t}, -- " .. hook .. "\n"); + end + end + f:close(); + end +end + + + + + +--- Lists the API objects that are documented but not available in the API: +function ListUnexportedObjects() + f = io.open("API/_unexported-documented.txt", "w"); + if (f ~= nil) then + for clsname, cls in pairs(g_APIDesc.Classes) do + if not(cls.IsExported) then + -- The whole class is not exported + f:write("class\t" .. clsname .. "\n"); + else + if (cls.Functions ~= nil) then + for fnname, fnapi in pairs(cls.Functions) do + if not(fnapi.IsExported) then + f:write("func\t" .. clsname .. "." .. fnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end + if (cls.Constants ~= nil) then + for cnname, cnapi in pairs(cls.Constants) do + if not(cnapi.IsExported) then + f:write("const\t" .. clsname .. "." .. cnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end + end + end -- for i, cls - g_APIDesc.Classes[] + f:close(); + end +end + + + + + function ListMissingPages() local MissingPages = {}; for PageName, Referrers in pairs(g_TrackedPages) do -- cgit v1.2.3 From 77af5c6fe72bee11e303924b2c3f30663e28085c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 20:49:30 +0200 Subject: APIDump: Do not list empty Constants or Functions sections. Also implemented writing inherited constants. --- MCServer/Plugins/APIDump/main.lua | 60 ++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 14 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 8d0f9f544..eadea622b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -632,6 +632,24 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" \n\n"); end + local function WriteConstants(a_Constants, a_InheritedName) + if (#a_Constants == 0) then + return; + end + + if (a_InheritedName ~= nil) then + cf:write("

    Constants inherited from " .. a_InheritedName .. "

    \n"); + end + + cf:write(" \n \n \n \n \n \n"); + for i, cons in ipairs(a_Constants) do + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); + end + cf:write("
    NameValueNotes
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "
    \n\n"); + end + local function WriteDescendants(a_Descendants) if (#a_Descendants == 0) then return; @@ -676,12 +694,25 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) local HasInheritance = ((#a_ClassAPI.Descendants > 0) or (a_ClassAPI.Inherits ~= nil)); + local HasConstants = (#a_ClassAPI.Constants > 0); + local HasFunctions = (#a_ClassAPI.Functions > 0); + if (a_ClassAPI.Inherits ~= nil) then + for idx, cls in ipairs(a_ClassAPI.Inherits) do + HasConstants = HasConstants or (#cls.Constants > 0); + HasFunctions = HasFunctions or (#cls.Functions > 0); + end + end + -- Write the table of contents: if (HasInheritance) then cf:write("
  • Inheritance
  • \n"); end - cf:write("
  • Constants
  • \n"); - cf:write("
  • Functions
  • \n"); + if (HasConstants) then + cf:write("
  • Constants
  • \n"); + end + if (HasFunctions) then + cf:write("
  • Functions
  • \n"); + end if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do cf:write("
  • " .. additional.Header .. "
  • \n"); @@ -715,20 +746,21 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end -- Write the constants: - cf:write("

    Constants

    \n"); - cf:write(" \n \n \n \n \n \n"); - for i, cons in ipairs(a_ClassAPI.Constants) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); - end - cf:write("
    NameValueNotes
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "", ClassName) .. "
    \n\n"); + if (HasConstants) then + cf:write("

    Constants

    \n"); + WriteConstants(a_ClassAPI.Constants, nil); + for i, cls in ipairs(InheritanceChain) do + WriteConstants(cls.Constants, cls.Name); + end; + end; -- Write the functions, including the inherited ones: - cf:write("

    Functions

    \n"); - WriteFunctions(a_ClassAPI.Functions, nil); - for i, cls in ipairs(InheritanceChain) do - WriteFunctions(cls.Functions, cls.Name); + if (HasFunctions) then + cf:write("

    Functions

    \n"); + WriteFunctions(a_ClassAPI.Functions, nil); + for i, cls in ipairs(InheritanceChain) do + WriteFunctions(cls.Functions, cls.Name); + end end -- Write the additional infos: -- cgit v1.2.3 From db2d4aa4e38ebf0a381f2ed13d8c26e30c79b4e6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 21:02:43 +0200 Subject: APIDump: Fixed offline JS. This time it's really offline :) --- MCServer/Plugins/APIDump/lang-lua.js | 61 ++------------------------------ MCServer/Plugins/APIDump/main.lua | 23 +++++------- MCServer/Plugins/APIDump/prettify.css | 1 + MCServer/Plugins/APIDump/prettify.js | 30 ++++++++++++++++ MCServer/Plugins/APIDump/run_prettify.js | 34 ------------------ 5 files changed, 41 insertions(+), 108 deletions(-) create mode 100644 MCServer/Plugins/APIDump/prettify.css create mode 100644 MCServer/Plugins/APIDump/prettify.js delete mode 100644 MCServer/Plugins/APIDump/run_prettify.js (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/lang-lua.js b/MCServer/Plugins/APIDump/lang-lua.js index 7a3f9766d..7e44cca0a 100644 --- a/MCServer/Plugins/APIDump/lang-lua.js +++ b/MCServer/Plugins/APIDump/lang-lua.js @@ -1,59 +1,2 @@ -// Copyright (C) 2008 Google Inc. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - - - -/** - * @fileoverview - * Registers a language handler for Lua. - * - * - * To use, include prettify.js and this file in your HTML page. - * Then put your code in an HTML tag like - *
    (my Lua code)
    - * - * - * I used http://www.lua.org/manual/5.1/manual.html#2.1 - * Because of the long-bracket concept used in strings and comments, Lua does - * not have a regular lexical grammar, but luckily it fits within the space - * of irregular grammars supported by javascript regular expressions. - * - * @author mikesamuel@gmail.com - */ - -PR['registerLangHandler']( - PR['createSimpleLexer']( - [ - // Whitespace - [PR['PR_PLAIN'], /^[\t\n\r \xA0]+/, null, '\t\n\r \xA0'], - // A double or single quoted, possibly multi-line, string. - [PR['PR_STRING'], /^(?:\"(?:[^\"\\]|\\[\s\S])*(?:\"|$)|\'(?:[^\'\\]|\\[\s\S])*(?:\'|$))/, null, '"\''] - ], - [ - // A comment is either a line comment that starts with two dashes, or - // two dashes preceding a long bracketed block. - [PR['PR_COMMENT'], /^--(?:\[(=*)\[[\s\S]*?(?:\]\1\]|$)|[^\r\n]*)/], - // A long bracketed block not preceded by -- is a string. - [PR['PR_STRING'], /^\[(=*)\[[\s\S]*?(?:\]\1\]|$)/], - [PR['PR_KEYWORD'], /^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/, null], - // A number is a hex integer literal, a decimal real literal, or in - // scientific notation. - [PR['PR_LITERAL'], - /^[+-]?(?:0x[\da-f]+|(?:(?:\.\d+|\d+(?:\.\d*)?)(?:e[+\-]?\d+)?))/i], - // An identifier - [PR['PR_PLAIN'], /^[a-z_]\w*/i], - // A run of punctuation - [PR['PR_PUNCTUATION'], /^[^\w\t\n\r \xA0][^\w\t\n\r \xA0\"\'\-\+=]*/] - ]), - ['lua']); +PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\r \xa0]+/,null,"\t\n\r \u00a0"],["str",/^(?:"(?:[^"\\]|\\[\S\s])*(?:"|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$))/,null,"\"'"]],[["com",/^--(?:\[(=*)\[[\S\s]*?(?:]\1]|$)|[^\n\r]*)/],["str",/^\[(=*)\[[\S\s]*?(?:]\1]|$)/],["kwd",/^(?:and|break|do|else|elseif|end|false|for|function|if|in|local|nil|not|or|repeat|return|then|true|until|while)\b/,null],["lit",/^[+-]?(?:0x[\da-f]+|(?:\.\d+|\d+(?:\.\d*)?)(?:e[+-]?\d+)?)/i], +["pln",/^[_a-z]\w*/i],["pun",/^[^\w\t\n\r \xa0][^\w\t\n\r "'+=\xa0-]*/]]),["lua"]); diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index eadea622b..6d85a1281 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -295,19 +295,10 @@ function DumpAPIHtml() ]]); f:close(); - -- Copy the CSS file to the output folder (overwrite any existing): - cssf = io.open("API/main.css", "w"); - if (cssf ~= nil) then - cssfi = io.open(g_Plugin:GetLocalDirectory() .. "/main.css", "r"); - if (cssfi ~= nil) then - local CSS = cssfi:read("*all"); - cssf:write(CSS); - cssfi:close(); - end - cssf:close(); - end - - cFile:Copy(g_Plugin:GetLocalDirectory() .. "/run_prettify.js", "API/run_prettify.js"); + -- Copy the static files to the output folder (overwrite any existing): + cFile:Copy(g_Plugin:GetLocalFolder() .. "/main.css", "API/main.css"); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.js", "API/prettify.js"); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.css", "API/prettify.css"); cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); -- List the documentation problems: @@ -678,7 +669,8 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) MCServer API - ]] .. a_ClassAPI.Name .. [[ Class - + + @@ -793,7 +785,8 @@ function WriteHtmlHook(a_Hook) MCServer API - ]] .. HookName .. [[ Hook - + + diff --git a/MCServer/Plugins/APIDump/prettify.css b/MCServer/Plugins/APIDump/prettify.css new file mode 100644 index 000000000..d44b3a228 --- /dev/null +++ b/MCServer/Plugins/APIDump/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} \ No newline at end of file diff --git a/MCServer/Plugins/APIDump/prettify.js b/MCServer/Plugins/APIDump/prettify.js new file mode 100644 index 000000000..7b990496d --- /dev/null +++ b/MCServer/Plugins/APIDump/prettify.js @@ -0,0 +1,30 @@ +!function(){var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; +(function(){function S(a){function d(e){var b=e.charCodeAt(0);if(b!==92)return b;var a=e.charAt(1);return(b=r[a])?b:"0"<=a&&a<="7"?parseInt(e.substring(1),8):a==="u"||a==="x"?parseInt(e.substring(2),16):e.charCodeAt(1)}function g(e){if(e<32)return(e<16?"\\x0":"\\x")+e.toString(16);e=String.fromCharCode(e);return e==="\\"||e==="-"||e==="]"||e==="^"?"\\"+e:e}function b(e){var b=e.substring(1,e.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),e=[],a= +b[0]==="^",c=["["];a&&c.push("^");for(var a=a?1:0,f=b.length;a122||(l<65||h>90||e.push([Math.max(65,h)|32,Math.min(l,90)|32]),l<97||h>122||e.push([Math.max(97,h)&-33,Math.min(l,122)&-33]))}}e.sort(function(e,a){return e[0]-a[0]||a[1]-e[1]});b=[];f=[];for(a=0;ah[0]&&(h[1]+1>h[0]&&c.push("-"),c.push(g(h[1])));c.push("]");return c.join("")}function s(e){for(var a=e.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],f=0,h=0;f=2&&e==="["?a[f]=b(l):e!=="\\"&&(a[f]=l.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var x=0,m=!1,j=!1,k=0,c=a.length;k=5&&"lang-"===w.substring(0,5))&&!(t&&typeof t[1]==="string"))f=!1,w="src";f||(r[z]=w)}h=c;c+=z.length;if(f){f=t[1];var l=z.indexOf(f),B=l+f.length;t[2]&&(B=z.length-t[2].length,l=B-f.length);w=w.substring(5);H(j+h,z.substring(0,l),g,k);H(j+h+l,f,I(w,f),k);H(j+h+B,z.substring(B),g,k)}else k.push(j+h,w)}a.g=k}var b={},s;(function(){for(var g=a.concat(d),j=[],k={},c=0,i=g.length;c=0;)b[n.charAt(e)]=r;r=r[1];n=""+r;k.hasOwnProperty(n)||(j.push(r),k[n]=q)}j.push(/[\S\s]/);s=S(j)})();var x=d.length;return g}function v(a){var d=[],g=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, +q,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&g.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),g.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,q])):d.push(["com", +/^#[^\n\r]*/,q,"#"]));a.cStyleComments&&(g.push(["com",/^\/\/[^\n\r]*/,q]),g.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));if(b=a.regexLiterals){var s=(b=b>1?"":"\n\r")?".":"[\\S\\s]";g.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+s+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+ +s+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&g.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&g.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),q]);d.push(["pln",/^\s+/,q," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");g.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/, +q],["pun",RegExp(b),q]);return C(d,g)}function J(a,d,g){function b(a){var c=a.nodeType;if(c==1&&!x.test(a.className))if("br"===a.nodeName)s(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&g){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(j.createTextNode(d),a.nextSibling),s(a),c||a.parentNode.removeChild(a)}}function s(a){function b(a,c){var d= +c?a.cloneNode(!1):a,e=a.parentNode;if(e){var e=b(e,1),g=a.nextSibling;e.appendChild(d);for(var i=g;i;i=g)g=i.nextSibling,e.appendChild(i)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var x=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,j=a.ownerDocument,k=j.createElement("li");a.firstChild;)k.appendChild(a.firstChild);for(var c=[k],i=0;i=0;){var b=d[g];F.hasOwnProperty(b)?D.console&&console.warn("cannot override language handler %s",b):F[b]=a}}function I(a,d){if(!a||!F.hasOwnProperty(a))a=/^\s*=l&&(b+=2);g>=B&&(r+=2)}}finally{if(f)f.style.display=h}}catch(u){D.console&&console.log(u&&u.stack||u)}}var D=window,y=["break,continue,do,else,for,if,return,while"],E=[[y,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], +"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],M=[E,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],N=[E,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], +O=[N,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],E=[E,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],P=[y,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], +Q=[y,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],W=[y,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],y=[y,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],R=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, +V=/\S/,X=v({keywords:[M,O,E,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",P,Q,y],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),F={};p(X,["default-code"]);p(C([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", +/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);p(C([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/], +["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);p(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);p(v({keywords:M,hashComments:!0,cStyleComments:!0,types:R}),["c","cc","cpp","cxx","cyc","m"]);p(v({keywords:"null,true,false"}),["json"]);p(v({keywords:O,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:R}), +["cs"]);p(v({keywords:N,cStyleComments:!0}),["java"]);p(v({keywords:y,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);p(v({keywords:P,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);p(v({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);p(v({keywords:Q, +hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);p(v({keywords:E,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);p(v({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);p(v({keywords:W,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]); +p(C([],[["str",/^[\S\s]+/]]),["regex"]);var Y=D.PR={createSimpleLexer:C,registerLangHandler:p,sourceDecorator:v,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:D.prettyPrintOne=function(a,d,g){var b=document.createElement("div");b.innerHTML="
    "+a+"
    ";b=b.firstChild;g&&J(b,g,!0);K({h:d,j:g,c:b,i:1}); +return b.innerHTML},prettyPrint:D.prettyPrint=function(a,d){function g(){for(var b=D.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;i=0;){var M=A[m],T=M.src.match(/^[^#?]*\/run_prettify\.js(\?[^#]*)?(?:#.*)?$/);if(T){z=T[1]||"";M.parentNode.removeChild(M); -break}}var S=!0,D=[],N=[],K=[];z.replace(/[&?]([^&=]+)=([^&]+)/g,function(e,j,w){w=decodeURIComponent(w);j=decodeURIComponent(j);j=="autorun"?S=!/^[0fn]/i.test(w):j=="lang"?D.push(w):j=="skin"?N.push(w):j=="callback"&&K.push(w)});m=0;for(z=D.length;m122||(o<65||k>90||f.push([Math.max(65,k)|32,Math.min(o,90)|32]),o<97||k>122||f.push([Math.max(97,k)&-33,Math.min(o,122)&-33]))}}f.sort(function(f, -a){return f[0]-a[0]||a[1]-f[1]});b=[];g=[];for(a=0;ak[0]&&(k[1]+1>k[0]&&c.push("-"),c.push(h(k[1])));c.push("]");return c.join("")}function e(f){for(var a=f.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),c=a.length,d=[],g=0,k=0;g=2&&f==="["?a[g]=b(o):f!=="\\"&&(a[g]=o.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return a.join("")}for(var j=0,F=!1,l=!1,I=0,c=a.length;I=5&&"lang-"===y.substring(0,5))&&!(u&&typeof u[1]==="string"))g=!1,y="src";g||(m[B]=y)}k=c;c+=B.length;if(g){g=u[1];var o=B.indexOf(g),H=o+g.length;u[2]&&(H=B.length-u[2].length,o=H-g.length);y=y.substring(5);n(l+k,B.substring(0,o),h, -j);n(l+k+o,g,A(y,g),j);n(l+k+H,B.substring(H),h,j)}else j.push(l+k,y)}a.g=j}var b={},e;(function(){for(var h=a.concat(d),l=[],i={},c=0,p=h.length;c=0;)b[q.charAt(f)]=m;m=m[1];q=""+m;i.hasOwnProperty(q)||(l.push(m),i[q]=r)}l.push(/[\S\s]/);e=j(l)})();var i=d.length;return h}function t(a){var d=[],h=[];a.tripleQuotedStrings?d.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/, -r,"'\""]):a.multiLineStrings?d.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/,r,"'\"`"]):d.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,r,"\"'"]);a.verbatimStrings&&h.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,r]);var b=a.hashComments;b&&(a.cStyleComments?(b>1?d.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,r,"#"]):d.push(["com",/^#(?:(?:define|e(?:l|nd)if|else|error|ifn?def|include|line|pragma|undef|warning)\b|[^\n\r]*)/, -r,"#"]),h.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h(?:h|pp|\+\+)?|[a-z]\w*)>/,r])):d.push(["com",/^#[^\n\r]*/,r,"#"]));a.cStyleComments&&(h.push(["com",/^\/\/[^\n\r]*/,r]),h.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,r]));if(b=a.regexLiterals){var e=(b=b>1?"":"\n\r")?".":"[\\S\\s]";h.push(["lang-regex",RegExp("^(?:^^\\.?|[+-]|[!=]=?=?|\\#|%=?|&&?=?|\\(|\\*=?|[+\\-]=|->|\\/=?|::?|<>?>?=?|,|;|\\?|@|\\[|~|{|\\^\\^?=?|\\|\\|?=?|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*("+ -("/(?=[^/*"+b+"])(?:[^/\\x5B\\x5C"+b+"]|\\x5C"+e+"|\\x5B(?:[^\\x5C\\x5D"+b+"]|\\x5C"+e+")*(?:\\x5D|$))+/")+")")])}(b=a.types)&&h.push(["typ",b]);b=(""+a.keywords).replace(/^ | $/g,"");b.length&&h.push(["kwd",RegExp("^(?:"+b.replace(/[\s,]+/g,"|")+")\\b"),r]);d.push(["pln",/^\s+/,r," \r\n\t\u00a0"]);b="^.[^\\s\\w.$@'\"`/\\\\]*";a.regexLiterals&&(b+="(?!s*/)");h.push(["lit",/^@[$_a-z][\w$@]*/i,r],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,r],["pln",/^[$_a-z][\w$@]*/i,r],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i, -r,"0123456789"],["pln",/^\\[\S\s]?/,r],["pun",RegExp(b),r]);return C(d,h)}function z(a,d,h){function b(a){var c=a.nodeType;if(c==1&&!j.test(a.className))if("br"===a.nodeName)e(a),a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)b(a);else if((c==3||c==4)&&h){var d=a.nodeValue,i=d.match(m);if(i)c=d.substring(0,i.index),a.nodeValue=c,(d=d.substring(i.index+i[0].length))&&a.parentNode.insertBefore(l.createTextNode(d),a.nextSibling),e(a),c||a.parentNode.removeChild(a)}} -function e(a){function b(a,c){var d=c?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),h=a.nextSibling;f.appendChild(d);for(var e=h;e;e=h)h=e.nextSibling,f.appendChild(e)}return d}for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),d;(d=a.parentNode)&&d.nodeType===1;)a=d;c.push(a)}for(var j=/(?:^|\s)nocode(?:\s|$)/,m=/\r\n?|\n/,l=a.ownerDocument,i=l.createElement("li");a.firstChild;)i.appendChild(a.firstChild);for(var c=[i],p=0;p=0;){var b=d[h];U.hasOwnProperty(b)?V.console&&console.warn("cannot override language handler %s",b):U[b]=a}}function A(a,d){if(!a||!U.hasOwnProperty(a))a=/^\s*=o&&(b+=2);h>=H&&(t+=2)}}finally{if(g)g.style.display=k}}catch(v){V.console&&console.log(v&&v.stack||v)}}var V=window,G=["break,continue,do,else,for,if,return,while"],O=[[G,"auto,case,char,const,default,double,enum,extern,float,goto,inline,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], -"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],J=[O,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,delegate,dynamic_cast,explicit,export,friend,generic,late_check,mutable,namespace,nullptr,property,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],K=[O,"abstract,assert,boolean,byte,extends,final,finally,implements,import,instanceof,interface,null,native,package,strictfp,super,synchronized,throws,transient"], -L=[K,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,internal,into,is,let,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var,virtual,where"],O=[O,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],M=[G,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], -N=[G,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],R=[G,"as,assert,const,copy,drop,enum,extern,fail,false,fn,impl,let,log,loop,match,mod,move,mut,priv,pub,pure,ref,self,static,struct,true,trait,type,unsafe,use"],G=[G,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],Q=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)\b/, -S=/\S/,T=t({keywords:[J,L,O,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",M,N,G],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),U={};i(T,["default-code"]);i(C([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-", -/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);i(C([["pln",/^\s+/,r," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,r,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/], -["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css",/^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);i(C([],[["atv",/^[\S\s]+/]]),["uq.val"]);i(t({keywords:J,hashComments:!0,cStyleComments:!0,types:Q}),["c","cc","cpp","cxx","cyc","m"]);i(t({keywords:"null,true,false"}),["json"]);i(t({keywords:L,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:Q}), -["cs"]);i(t({keywords:K,cStyleComments:!0}),["java"]);i(t({keywords:G,hashComments:!0,multiLineStrings:!0}),["bash","bsh","csh","sh"]);i(t({keywords:M,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}),["cv","py","python"]);i(t({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:2}),["perl","pl","pm"]);i(t({keywords:N, -hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb","ruby"]);i(t({keywords:O,cStyleComments:!0,regexLiterals:!0}),["javascript","js"]);i(t({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,throw,true,try,unless,until,when,while,yes",hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);i(t({keywords:R,cStyleComments:!0,multilineStrings:!0}),["rc","rs","rust"]); -i(C([],[["str",/^[\S\s]+/]]),["regex"]);var X=V.PR={createSimpleLexer:C,registerLangHandler:i,sourceDecorator:t,PR_ATTRIB_NAME:"atn",PR_ATTRIB_VALUE:"atv",PR_COMMENT:"com",PR_DECLARATION:"dec",PR_KEYWORD:"kwd",PR_LITERAL:"lit",PR_NOCODE:"nocode",PR_PLAIN:"pln",PR_PUNCTUATION:"pun",PR_SOURCE:"src",PR_STRING:"str",PR_TAG:"tag",PR_TYPE:"typ",prettyPrintOne:function(a,d,e){var b=document.createElement("div");b.innerHTML="
    "+a+"
    ";b=b.firstChild;e&&z(b,e,!0);D({h:d,j:e,c:b,i:1});return b.innerHTML}, -prettyPrint:e=e=function(a,d){function e(){for(var b=V.PR_SHOULD_USE_CONTINUATION?c.now()+250:Infinity;p Date: Fri, 18 Oct 2013 21:27:35 +0200 Subject: APIDump: Added prettify's license. --- MCServer/Plugins/APIDump/LICENSE-prettify.txt | 191 ++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 MCServer/Plugins/APIDump/LICENSE-prettify.txt (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/LICENSE-prettify.txt b/MCServer/Plugins/APIDump/LICENSE-prettify.txt new file mode 100644 index 000000000..b7f86df20 --- /dev/null +++ b/MCServer/Plugins/APIDump/LICENSE-prettify.txt @@ -0,0 +1,191 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + Copyright 2011 Mike Samuel et al + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. -- cgit v1.2.3 From 07ba48840da5447e12d8c54a20c0f049a3ec67a7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 21:29:38 +0200 Subject: APIDump: Added support for member variables. --- MCServer/Plugins/APIDump/APIDesc.lua | 9 ++++-- MCServer/Plugins/APIDump/main.lua | 54 ++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4961c9baf..0a1e91a54 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -31,6 +31,11 @@ g_APIDesc = ConstantName = { Notes = "Notes about the constant" }, } , + Variables = + { + VariableName = { Type = "string", Notes = "Notes about the variable" }, + } , + AdditionalInfo = -- Paragraphs to be exported after the function definitions table { { @@ -610,8 +615,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), }, Variables = { - p1 = { Notes = "{{Vector3i}} of one corner. Usually the lesser of the two coords in each set" }, - p2 = { Notes = "{{Vector3i}} of the other corner. Usually the larger of the two coords in each set" }, + p1 = { Type = "{{Vector3i}}", Notes = "The first corner. Usually the lesser of the two coords in each set" }, + p2 = { Type = "{{Vector3i}}", Notes = "The second corner. Usually the larger of the two coords in each set" }, }, }, diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 6d85a1281..93f3e7258 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -459,10 +459,21 @@ function ReadDescriptions(a_API) end end -- for j, cons end -- if (APIDesc.Constants ~= nil) - else + + -- Process member variables: + local vars = {}; + for name, desc in pairs(APIDesc.Variables or {}) do + desc.Name = name; + table.insert(vars, desc); + end + cls.Variables = vars; + + else -- if (APIDesc ~= nil) + -- Class is not documented at all, add all its members to Undocumented lists: cls.UndocumentedFunctions = {}; cls.UndocumentedConstants = {}; + cls.Variables = {}; for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then @@ -505,6 +516,13 @@ function ReadDescriptions(a_API) return (c1.Name < c2.Name); end ); + + -- Sort the member variables: + table.sort(cls.Variables, + function(v1, v2) + return (v1.Name < v2.Name); + end + ); end -- for i, cls -- Sort the descendants lists: @@ -618,7 +636,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" \n " .. func.Name .. "\n"); cf:write(" " .. LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)).. "\n"); cf:write(" " .. LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)).. "\n"); - cf:write(" " .. LinkifyString(func.Notes or "", (a_InheritedName or a_ClassAPI.Name)) .. "\n \n"); + cf:write(" " .. LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)) .. "\n \n"); end cf:write(" \n\n"); end @@ -641,6 +659,24 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" \n\n"); end + local function WriteVariables(a_Variables, a_InheritedName) + if (#a_Variables == 0) then + return; + end + + if (a_InheritedName ~= nil) then + cf:write("

    Member variables inherited from " .. a_InheritedName .. "

    \n"); + end + + cf:write(" \n \n \n \n \n \n"); + for i, var in ipairs(a_Variables) do + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); + end + cf:write("
    NameTypeNotes
    " .. var.Name .. "" .. LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name) .. "" .. LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "
    \n\n"); + end + local function WriteDescendants(a_Descendants) if (#a_Descendants == 0) then return; @@ -688,10 +724,12 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) local HasConstants = (#a_ClassAPI.Constants > 0); local HasFunctions = (#a_ClassAPI.Functions > 0); + local HasVariables = (#a_ClassAPI.Variables > 0); if (a_ClassAPI.Inherits ~= nil) then for idx, cls in ipairs(a_ClassAPI.Inherits) do HasConstants = HasConstants or (#cls.Constants > 0); HasFunctions = HasFunctions or (#cls.Functions > 0); + HasVariables = HasVariables or (#cls.Variables > 0); end end @@ -702,6 +740,9 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) if (HasConstants) then cf:write("
  • Constants
  • \n"); end + if (HasVariables) then + cf:write("
  • Member variables
  • \n"); + end if (HasFunctions) then cf:write("
  • Functions
  • \n"); end @@ -746,6 +787,15 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end; end; + -- Write the member variables: + if (HasVariables) then + cf:write("

    Member variables

    \n"); + WriteVariables(a_ClassAPI.Variables, nil); + for i, cls in ipairs(InheritanceChain) do + WriteVariables(cls.Variables, cls.Name); + end; + end + -- Write the functions, including the inherited ones: if (HasFunctions) then cf:write("

    Functions

    \n"); -- cgit v1.2.3 From 373900964c669403ddc0f3ffb22b758f51957342 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 21:38:44 +0200 Subject: APIDump: Documented cItem's variables. --- MCServer/Plugins/APIDump/APIDesc.lua | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0a1e91a54..74b5a6351 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1065,7 +1065,10 @@ These ItemGrids are available in the API and can be manipulated by the plugins, cItem is what defines an item or stack of items in the game, it contains the item ID, damage, quantity and enchantments. Each slot in a {{cInventory}} class or a {{cItemGrid}} class is a cItem and each {{cPickup}} contains a cItem. The enchantments are contained in a separate - {{cEnchantments}} class and are accessible through the m_Enchantments variable. + {{cEnchantments}} class and are accessible through the m_Enchantments variable.

    +

    + To test if a cItem object represents an empty item, do not compare the item type nor the item count, + but rather use the IsEmpty() function. ]], Functions = @@ -1086,11 +1089,15 @@ These ItemGrids are available in the API and can be manipulated by the plugins, IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if this object represents an empty item (zero count or invalid ID)" }, IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" }, IsFullStack = { Params = "", Return = "bool", Notes = "Returns true if the item is stacked up to its maximum stacking" }, - IsSameType = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is of the same ItemType as the one stored in the object" }, - IsStackableWith = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is stackable with the one stored in the object" }, + IsSameType = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is of the same ItemType as the one stored in the object. This is true even if the two items have different enchantments" }, + IsStackableWith = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is stackable with the one stored in the object. Two items with different enchantments cannot be stacked" }, }, - Constants = + Variables = { + m_Enchantments = { Type = "{{cEnchantments}}", Notes = "The enchantments that this item has" }, + m_ItemCount = { Type = "number", Notes = "Number of items in this stack" }, + m_ItemDamage = { Type = "number", Notes = "The damage of the item. Zero means no damage. Maximum damage can be queried with GetMaxDamage()" }, + m_ItemType = { Type = "number", Notes = "The item type. One of E_ITEM_ or E_BLOCK_ constants" }, }, }, -- cgit v1.2.3 From 1e67ff3499a7c369adc4945f22e67201aab0fb6c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 21:49:07 +0200 Subject: APIDump: Added example code to cItem. --- MCServer/Plugins/APIDump/APIDesc.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 74b5a6351..544e02049 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1099,6 +1099,38 @@ These ItemGrids are available in the API and can be manipulated by the plugins, m_ItemDamage = { Type = "number", Notes = "The damage of the item. Zero means no damage. Maximum damage can be queried with GetMaxDamage()" }, m_ItemType = { Type = "number", Notes = "The item type. One of E_ITEM_ or E_BLOCK_ constants" }, }, + AdditionalInfo = + { + { + Header = "Example code", + Contents = [[ + The following code shows how to create items in several different ways (adapted from the Debuggers plugin): +

    +-- empty item:
    +local Item1 = cItem();
    +
    +-- enchanted sword, enchantment given as numeric string (bad style; see Item5):
    +local Item2 = cItem(E_ITEM_DIAMOND_SWORD, 1, 0, "1=1");
    +
    +-- 1 undamaged shovel, no enchantment:
    +local Item3 = cItem(E_ITEM_DIAMOND_SHOVEL);
    +
    +-- Add the Unbreaking enchantment. Note that Vanilla's levelcap isn't enforced:
    +Item3.m_Enchantments:SetLevel(cEnchantments.enchUnbreaking, 4);
    +
    +-- 1 undamaged pickaxe, no enchantment:
    +local Item4 = cItem(E_ITEM_DIAMOND_PICKAXE);
    +
    +-- Add multiple enchantments:
    +Item4.m_Enchantments:SetLevel(cEnchantments.enchUnbreaking, 5);
    +Item4.m_Enchantments:SetLevel(cEnchantments.enchEfficiency, 3);
    +
    +-- enchanted chestplate, enchantment given as textual stringdesc (good style)
    +local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3");
    +
    +]], + }, + }, }, cItemGrid = -- cgit v1.2.3 From 1b7a84d494a5d9025ef72e6d985a194202fb38f8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 22:02:06 +0200 Subject: APIDump: Offline prettify is working. --- MCServer/Plugins/APIDump/main.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 93f3e7258..fe4df751b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -813,7 +813,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end end - cf:write("
    \n \n"); + cf:write([[ +
    + + + + ]]); cf:close(); end @@ -879,6 +886,9 @@ function WriteHtmlHook(a_Hook) f:write("
    " .. (example.Code or "missing Code") .. "\n			
    \n\n"); end f:write([[ + ]]); f:close(); -- cgit v1.2.3 From be996c16626e6f7c8a7c43595f5c6efaacf668eb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 18 Oct 2013 23:22:26 +0200 Subject: APIDump: Added cIniFile additional info. --- MCServer/Plugins/APIDump/APIDesc.lua | 28 ++++++++++++++++++++++++++++ MCServer/Plugins/APIDump/main.lua | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 544e02049..a57a7a342 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1003,6 +1003,34 @@ cFile:Delete("/usr/bin/virus.exe"); Constants = { }, + AdditionalInfo = + { + { + Header = "Practical usage", + Contents = [[ + If you want to use cIniFile you need to know a couple of things; what is the key name and what + is the value name. Below is a demonstration of what is what.

    +
    +; Comment line
    +[KeyName1]
    +ValueName1=Value1
    +ValueName2=Value2
    +
    +[KeyName2]
    +ValueName1=Value3
    +

    +

    + cIniFile is very easy to use. For example, you can find out what port the server is supposed to + use according to settings.ini by using this little snippet: +

    +local IniFile = cIniFile("settings.ini");
    +if (IniFile:ReadFile()) then
    +	ServerPort = IniFile:GetValueI("Server", "Port");
    +end
    +
    + ]], + }, + }, }, cInventory = diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index fe4df751b..285b0c1c3 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -748,7 +748,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("
  • " .. additional.Header .. "
  • \n"); + cf:write("
  • " .. (additional.Header or "(No header)").. "
  • \n"); end end cf:write(" \n\n"); -- cgit v1.2.3 From b59329bf3a5ef290e1ee66bd291ecb84519331ba Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Oct 2013 21:47:59 +0200 Subject: APIDump: Better header text for classes. --- MCServer/Plugins/APIDump/main.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 285b0c1c3..8952ef3ea 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -754,7 +754,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write(" \n\n"); -- Write the class description: - cf:write("

    Class " .. ClassName .. "

    \n"); + cf:write("

    " .. ClassName .. " class

    \n"); if (a_ClassAPI.Desc ~= nil) then cf:write("

    "); cf:write(LinkifyString(a_ClassAPI.Desc, ClassName)); -- cgit v1.2.3 From 9f8df5f70280d4fbd2d22bca2135cb662f9615f3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Oct 2013 22:07:06 +0200 Subject: APIDump: Member variables are read from the API. --- MCServer/Plugins/APIDump/main.lua | 58 ++++++++++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 8952ef3ea..74ae94b15 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -117,7 +117,7 @@ function CreateAPITables() }; --]] - local Globals = {Functions = {}, Constants = {}, Descendants = {}}; + local Globals = {Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; local API = {}; local function Add(a_APIContainer, a_ObjName, a_ObjValue) @@ -132,10 +132,18 @@ function CreateAPITables() end local function ParseClass(a_ClassName, a_ClassObj) - local res = {Name = a_ClassName, Functions = {}, Constants = {}, Descendants = {}}; + local res = {Name = a_ClassName, Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; + -- Add functions and constants: for i, v in pairs(a_ClassObj) do Add(res, i, v); end + + -- Member variables: + if ((a_ClassObj[".get"] ~= nil) and (type(a_ClassObj[".get"]) == "table")) then + for k, v in pairs(a_ClassObj[".get"]) do + table.insert(res.Variables, { Name = k }); + end + end return res; end @@ -353,6 +361,19 @@ function ReadDescriptions(a_API) return false; end + -- Returns true if the member variable (specified by its fully qualified name) is to be ignored + local function IsVariableIgnored(a_VarName) + if (g_APIDesc.IgnoreVariables == nil) then + return false; + end; + for i, name in ipairs(g_APIDesc.IgnoreVariables) do + if (a_VarName:match(name)) then + return true; + end + end + return false; + end + -- Remove ignored classes from a_API: local APICopy = {}; for i, cls in ipairs(a_API) do @@ -407,6 +428,7 @@ function ReadDescriptions(a_API) cls.UndocumentedFunctions = {}; -- This will contain names of all the functions that are not documented cls.UndocumentedConstants = {}; -- This will contain names of all the constants that are not documented + cls.UndocumentedVariables = {}; -- This will contain names of all the variables that are not documented local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation @@ -460,20 +482,31 @@ function ReadDescriptions(a_API) end -- for j, cons end -- if (APIDesc.Constants ~= nil) - -- Process member variables: - local vars = {}; - for name, desc in pairs(APIDesc.Variables or {}) do - desc.Name = name; - table.insert(vars, desc); - end - cls.Variables = vars; + -- Assign member variables' descriptions: + if (APIDesc.Variables ~= nil) then + for j, var in ipairs(cls.Variables) do + local VarDesc = APIDesc.Variables[var.Name]; + if (VarDesc == nil) then + -- Not documented + if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + else + -- Copy all documentation: + for k, v in pairs(VarDesc) do + var[k] = v + end + end + end -- for j, var + end -- if (APIDesc.Variables ~= nil) else -- if (APIDesc ~= nil) -- Class is not documented at all, add all its members to Undocumented lists: cls.UndocumentedFunctions = {}; cls.UndocumentedConstants = {}; - cls.Variables = {}; + cls.UndocumentedVariables = {}; + cls.Variables = cls.Variables or {}; for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then @@ -485,6 +518,11 @@ function ReadDescriptions(a_API) table.insert(cls.UndocumentedConstants, cons.Name); end end -- for j, cons - cls.Constants[] + for j, var in ipairs(cls.Variables) do + if not(IsConstantIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + end -- for j, var - cls.Variables[] end -- else if (APIDesc ~= nil) -- Remove ignored functions: -- cgit v1.2.3 From d1ddd2492b2e69cdec9a014c807cfc40440350f8 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 19 Oct 2013 21:18:27 +0100 Subject: Added a APIDump description for GetHTMLEscapedString. --- MCServer/Plugins/APIDump/APIDesc.lua | 129 ++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 63 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index a57a7a342..6209bfa76 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -15,7 +15,7 @@ g_APIDesc = ExampleClassName = { Desc = "Description, exported as the first paragraph of the class page. Usually enclosed within double brackets." - + Functions = { FunctionName = { Params = "Parameter list", Return = "Return values list", Notes = "Notes" ), @@ -25,17 +25,17 @@ g_APIDesc = { Params = "Parameter list 2", Return = "Return values list 2", Notes = "Notes 2" }, } } , - + Constants = { ConstantName = { Notes = "Notes about the constant" }, } , - + Variables = { VariableName = { Type = "string", Notes = "Notes about the variable" }, } , - + AdditionalInfo = -- Paragraphs to be exported after the function definitions table { { @@ -47,17 +47,17 @@ g_APIDesc = Contents = "Contents of the additional section 2", } }, - + Inherits = "ParentClassName", -- Only present if the class inherits from another API class }, ]]-- - + cArrowEntity = { Desc = [[ Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}. ]], - + Functions = { CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" }, @@ -68,17 +68,17 @@ g_APIDesc = SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" }, SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" }, }, - + Constants = { psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" }, psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" }, psNoPickup = { Notes = "The arrow cannot be picked up at all" }, }, - + Inherits = "cProjectileEntity", }, - + cBlockArea = { Desc = [[ @@ -182,7 +182,7 @@ g_APIDesc = msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" }, msLake = { Notes = "Special mode for merging lake images" }, }, - + AdditionalInfo = { { @@ -268,7 +268,7 @@ g_APIDesc = or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. The cBlockEntity class acts as a common ancestor for all the individual block entities. ]], - + Functions = { GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" }, @@ -295,9 +295,9 @@ g_APIDesc = number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage is monitored for changes and the changes are immediately sent to clients of the UI window. ]], - + Inherits = "cBlockEntity", - + Functions = { GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, @@ -306,7 +306,7 @@ g_APIDesc = { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, }, - SetSlot = + SetSlot = { { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, @@ -316,8 +316,8 @@ g_APIDesc = { }, }, - - cBoundingBox = + + cBoundingBox = { Desc = [[ Represents two sets of coordinates, minimum and maximum for each direction; thus defining an @@ -362,7 +362,7 @@ g_APIDesc = Desc = [[ A wrapper class for constants representing colors or effects. ]], - + Functions = { MakeColor = { Params = "ColorCodeConstant", Return = "string", Notes = "Creates the complete color-code-sequence from the color or effect constant" }, @@ -390,9 +390,9 @@ g_APIDesc = To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with either DoWithChestAt() or ForEachChestInChunk() function. See the code example below ]], - + Inherits = "cBlockEntityWithItems", - + Functions = { constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cChestEntity", Notes = "Creates a new cChestEntity object. To be used only in the chunk generating hooks {{OnChunkGenerating}} and {{OnChunkGenerated}}." }, @@ -431,7 +431,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), {{OnChunkGenerated|OnChunkGenerated}} hooks and cannot be constructed on its own. Plugins can use this class in both those hooks to manipulate generated chunks. ]], - + Functions = { FillBlocks = { Params = "BlockType, BlockMeta", Return = "", Notes = "Fills the entire chunk with the specified blocks" }, @@ -493,7 +493,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), connection. Internally, it handles all the incoming and outgoing packets, the chunks that are to be sent to the client, ping times etc. ]], - + Functions = { GetPing = { Params = "", Return = "number", Notes = "Returns the ping time, in ms" }, @@ -525,7 +525,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), specifying the exact number of ingredients to consume in that recipe; plugins may use this to apply the crafting recipe.

    ]], - + Functions = { constructor = { Params = "Width, Height", Return = "cCraftingGrid", Notes = "Creates a new CraftingGrid object. This new crafting grid is not related to any player, but may be needed for {{cCraftingRecipe}}'s ConsumeIngredients function." }, @@ -535,7 +535,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), GetHeight = { Params = "", Return = "number", Notes = "Returns the height of the grid" }, GetItem = { Params = "x, y", Return = "{{cItem|cItem}}", Notes = "Returns the item at the specified coords" }, GetWidth = { Params = "", Return = "number", Notes = "Returns the width of the grid" }, - SetItem = + SetItem = { { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the item at the specified coords" }, { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" }, @@ -562,7 +562,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), GetIngredientsHeight = { Params = "", Return = "number", Notes = "Returns the height of the ingredients' grid" }, GetIngredientsWidth = { Params = "", Return = "number", Notes = "Returns the width of the ingredients' grid" }, GetResult = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the result of the recipe" }, - SetIngredient = + SetIngredient = { { Params = "x, y, {{cItem|cItem}}", Return = "", Notes = "Sets the ingredient at the specified coords" }, { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the ingredient at the specified coords" }, @@ -624,7 +624,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), { Desc = [[This class represents a dispenser block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with a {{cDropperEntity|dropper}} entity.

    -

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). +

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). ]], Functions = { @@ -640,7 +640,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), { Desc = [[This class represents a dropper block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with the {{cDispenserEntity|dispenser}} entity.

    -

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). +

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). ]], Functions = { @@ -667,13 +667,13 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, }, - + Inherits = "cBlockEntity"; }, cEnchantments = { - Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly. + Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly.

    Enchantments can be initialized either programmatically by calling the individual functions (SetLevel()), or by using a string description of the enchantment combination. This string description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the enchantment, or its textual representation from the table below, and lvl is the desired enchantment level. The class can also create its string description from its current contents; however that string description will only have the numerical IDs. ]], @@ -855,7 +855,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cFile:Delete("/usr/bin/virus.exe");

    ]], - + Functions = { Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, @@ -870,14 +870,14 @@ cFile:Delete("/usr/bin/virus.exe"); }, - cFireChargeEntity = + cFireChargeEntity = { Desc = "", Functions = {}, Constants = {}, Inherits = "cProjectileEntity", } , - + cFurnaceEntity = { Desc = [[This class represents a furnace block entity in the world. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks) @@ -914,7 +914,7 @@ cFile:Delete("/usr/bin/virus.exe"); Constants = {}, Inherits = "cProjectileEntity", } , - + cGroup = { Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat. @@ -1098,7 +1098,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, To test if a cItem object represents an empty item, do not compare the item type nor the item count, but rather use the IsEmpty() function. ]], - + Functions = { constructor = @@ -1278,7 +1278,7 @@ various events. See below for further information. { Trace = { Params = "{{cWorld}}, Callbacks, StartX, StartY, StartZ, EndX, EndY, EndZ", Return = "bool", Notes = "(STATIC) Performs the trace on the specified line. Returns true if the entire trace was processed (no callback returned true)" }, }, - + AdditionalInfo = { { @@ -1333,17 +1333,17 @@ function HandleSpideyCmd(a_Split, a_Player) World:SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_COBWEB, 0); end }; - + local EyePos = a_Player:GetEyePosition(); local LookVector = a_Player:GetLookVector(); LookVector:Normalize(); -- Make the vector 1 m long - + -- Start cca 2 blocks away from the eyes local Start = EyePos + LookVector + LookVector; local End = EyePos + LookVector * 50; - + cLineBlockTracer.Trace(World, Callbacks, Start.x, Start.y, Start.z, End.x, End.y, End.z); - + return true; end
    @@ -1352,7 +1352,7 @@ end }, }, -- AdditionalInfo }, -- cLineBlockTracer - + cLuaWindow = { Desc = [[This class is used by plugins wishing to display a custom window to the player, unrelated to block entities or entities near the player. The window can be of any type and have any contents that the plugin defines. Callbacks for when the player modifies the window contents and when the player closes the window can be set. @@ -1447,7 +1447,7 @@ a_Player:OpenWindow(Window); Constants = {}, Inherits = "cPawn", }, - + cPawn = { Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}} @@ -1554,7 +1554,7 @@ a_Player:OpenWindow(Window); Constants = {}, Inherits = "cPlugin", }, - + cPluginManager = { Desc = [[ @@ -1667,7 +1667,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Constants = {}, Inherits = "cEntity", }, - + cRoot = { Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} @@ -1728,7 +1728,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa Constants = { }, - + Inherits = "cBlockEntity"; }, @@ -1743,7 +1743,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa { }, }, - + cThrownEggEntity = { Desc = "", @@ -1751,7 +1751,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa Constants = {}, Inherits = "cProjectileEntity", }, - + cThrownEnderPearlEntity = { Desc = "", @@ -1759,7 +1759,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa Constants = {}, Inherits = "cProjectileEntity", }, - + cThrownSnowballEntity = { Desc = "", @@ -1767,7 +1767,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa Constants = {}, Inherits = "cProjectileEntity", }, - + cTracer = { Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want. @@ -1785,17 +1785,20 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa cWebAdmin = { Desc = "", - Functions = {}, + Functions = + { + GetHTMLEscapedString = { Params = "string", Return = "string", Notes = "Gets the HTML escaped representation of a requested string. This is useful for user input and game data that is not guaranteed to be escaped already." }, + }, Constants = {}, }, - + cWebPlugin = { Desc = "", Functions = {}, Constants = {}, }, - + cWindow = { Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window. @@ -1861,7 +1864,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa

    Game time is also handled by the world. It provides the time-of-day and the total world age. ]], - + Functions = { BroadcastChat = { Params = "Message, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the Message to all players in this world, except the optional ExceptClient" }, @@ -2126,8 +2129,8 @@ World:ForEachEntity( }, }, }, - - + + Hooks = { HOOK_BLOCK_TO_PICKUPS = @@ -2173,10 +2176,10 @@ function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_Blo -- Not a tall grass being washed away return false; end - + -- Remove all pickups suggested by MCServer: a_Pickups:Clear(); - + -- Drop a diamond: a_Pickups:Add(cItem(E_ITEM_DIAMOND)); return true; @@ -2269,17 +2272,17 @@ function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) PseudoRandom = PseudoRandom * 8192 + PseudoRandom; PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff; PseudoRandom = PseudoRandom / 7; - + -- Based on the PseudoRandom value, choose a location for the ore: local OreX = PseudoRandom % 16; local OreY = 2 + ((PseudoRandom / 16) % 20); local OreZ = (PseudoRandom / 320) % 16; - + -- Check if the location is in ExtremeHills: if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then return false; end - + -- Only replace allowed blocks with the ore: local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ); if ( @@ -3569,7 +3572,7 @@ end }, -- HOOK_WORLD_TICK }, -- Hooks[] - + IgnoreClasses = { @@ -3583,7 +3586,7 @@ end "table", "g_TrackedPages", }, - + IgnoreFunctions = { "Globals.assert", @@ -3594,7 +3597,7 @@ end "%a+\.new", -- AnyClass.new "%a+.new_local", -- AnyClass.new_local "%a+.delete", -- AnyClass.delete - + -- Functions global in the APIDump plugin: "CreateAPITables", "DumpAPIHtml", @@ -3609,7 +3612,7 @@ end "WriteHtmlClass", "WriteHtmlHook", }, - + ExtraPages = { -- No sorting is provided for these, they will be output in the same order as defined here -- cgit v1.2.3 From 3f2813d6fffa98bc7b4b61164b6feca2e5b07d3c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Oct 2013 22:21:38 +0200 Subject: APIDump: Added member-variable filtering. --- MCServer/Plugins/APIDump/APIDesc.lua | 5 +++++ MCServer/Plugins/APIDump/main.lua | 9 +++++++++ 2 files changed, 14 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index a57a7a342..1c8edfb3f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3610,6 +3610,11 @@ end "WriteHtmlHook", }, + IgnoreVariables = + { + "__.*__", -- tolua exports multiple inheritance this way + } , + ExtraPages = { -- No sorting is provided for these, they will be output in the same order as defined here diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 74ae94b15..abc0f9293 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -555,6 +555,15 @@ function ReadDescriptions(a_API) end ); + -- Remove ignored functions: + local NewVariables = {}; + for j, var in ipairs(cls.Variables) do + if (not(IsVariableIgnored(cls.Name .. "." .. var.Name))) then + table.insert(NewVariables, var); + end + end -- for j, var + cls.Variables = NewVariables; + -- Sort the member variables: table.sort(cls.Variables, function(v1, v2) -- cgit v1.2.3 From bbcb0ead7355e33bef766d374f9ba73d470e7b88 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Oct 2013 22:28:58 +0200 Subject: APIDump: Extra pages use the local prettify and CSS. --- MCServer/Plugins/APIDump/WebWorldThreads.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/WebWorldThreads.html b/MCServer/Plugins/APIDump/WebWorldThreads.html index 7cc94e9fa..2f117ab7c 100644 --- a/MCServer/Plugins/APIDump/WebWorldThreads.html +++ b/MCServer/Plugins/APIDump/WebWorldThreads.html @@ -2,8 +2,10 @@ MCServer - Webserver vs World threads - - + + + +

    Webserver vs World threads

    @@ -60,5 +62,8 @@ end ) + \ No newline at end of file -- cgit v1.2.3 From 769c98403be49179626d04be0adb06ea5b17c42e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 19 Oct 2013 22:44:28 +0200 Subject: APIDump: Undocumented member variables are listed. --- MCServer/Plugins/APIDump/main.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index abc0f9293..75fc15965 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -954,7 +954,8 @@ function ListUndocumentedObjects(API, UndocumentedHooks) for i, cls in ipairs(API) do local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); - if (HasFunctions or HasConstants) then + local HasVariables = ((cls.UndocumentedVariables ~= nil) and (#cls.UndocumentedVariables > 0)); + if (HasFunctions or HasConstants or HasVariables) then f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); if ((cls.Desc == nil) or (cls.Desc == "")) then f:write("\t\t\tDesc = \"\"\n"); @@ -966,7 +967,7 @@ function ListUndocumentedObjects(API, UndocumentedHooks) table.sort(cls.UndocumentedFunctions); for j, fn in ipairs(cls.UndocumentedFunctions) do f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); - end -- for j, fn - cls.Undocumented[] + end -- for j, fn - cls.UndocumentedFunctions[] f:write("\t\t\t},\n\n"); end @@ -975,11 +976,20 @@ function ListUndocumentedObjects(API, UndocumentedHooks) table.sort(cls.UndocumentedConstants); for j, cn in ipairs(cls.UndocumentedConstants) do f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); - end -- for j, fn - cls.Undocumented[] + end -- for j, fn - cls.UndocumentedConstants[] f:write("\t\t\t},\n\n"); end - if (HasFunctions or HasConstants) then + if (HasVariables) then + f:write("\t\t\tVariables =\n\t\t\t{\n"); + table.sort(cls.UndocumentedVariables); + for j, vn in ipairs(cls.UndocumentedVariables) do + f:write("\t\t\t\t" .. vn .. " = { Type = \"\", Notes = \"\" },\n"); + end -- for j, fn - cls.UndocumentedVariables[] + f:write("\t\t\t},\n\n"); + end + + if (HasFunctions or HasConstants or HasVariables) then f:write("\t\t},\n\n"); end end -- for i, cls - API[] @@ -1008,7 +1018,9 @@ function ListUndocumentedObjects(API, UndocumentedHooks) f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); f:write("\t\t}, -- " .. hook .. "\n"); end + f:write("\t},\n"); end + f:write("}\n\n\n\n"); f:close(); end end -- cgit v1.2.3 From 4f40eb7f55e580675f85086709986c971f4872a9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 10:33:40 +0200 Subject: APIDump: Fixed listing undocumented objects. Classes with undefined "Functions" section would not list their functions as undocumented; similar for "Constants" and "Variables". --- MCServer/Plugins/APIDump/main.lua | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 75fc15965..f47d9c25a 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -89,7 +89,9 @@ function CreateAPITables() {Name = "IsInside"} }, Constants = { - } + }, + Variables = { + }, Descendants = {}, -- Will be filled by ReadDescriptions(), array of class APIs (references to other member in the tree) }}, { @@ -98,12 +100,14 @@ function CreateAPITables() {Name = "Clear"}, {Name = "CopyFrom"}, ... - } + }, Constants = { {Name = "baTypes", Value = 0}, {Name = "baMetas", Value = 1}, ... - } + }, + Variables = { + }, ... }} }; @@ -464,6 +468,12 @@ function ReadDescriptions(a_API) -- Replace functions with their described and overload-expanded versions: cls.Functions = DoxyFunctions; + else -- if (APIDesc.Functions ~= nil) + for j, func in ipairs(cls.Functions) do + if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + table.insert(cls.UndocumentedFunctions, FnName); + end + end end -- if (APIDesc.Functions ~= nil) if (APIDesc.Constants ~= nil) then @@ -480,7 +490,13 @@ function ReadDescriptions(a_API) CnDesc.IsExported = true; end end -- for j, cons - end -- if (APIDesc.Constants ~= nil) + else -- if (APIDesc.Constants ~= nil) + for j, cons in ipairs(cls.Constants) do + if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then + table.insert(cls.UndocumentedConstants, cons.Name); + end + end + end -- else if (APIDesc.Constants ~= nil) -- Assign member variables' descriptions: if (APIDesc.Variables ~= nil) then @@ -498,7 +514,13 @@ function ReadDescriptions(a_API) end end end -- for j, var - end -- if (APIDesc.Variables ~= nil) + else -- if (APIDesc.Variables ~= nil) + for j, var in ipairs(cls.Variables) do + if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + end + end -- else if (APIDesc.Variables ~= nil) else -- if (APIDesc ~= nil) -- cgit v1.2.3 From 07a117b096ad1d88e62f9fa002680f67939c4100 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 11:12:33 +0200 Subject: APIDump: Added basic statistics about the docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 + MCServer/Plugins/APIDump/main.lua | 87 +++++++++++++++++++++++++++++++++--- 2 files changed, 83 insertions(+), 6 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 246103acc..260a18800 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3585,6 +3585,7 @@ end "string", "table", "g_TrackedPages", + "g_Stats", }, IgnoreFunctions = @@ -3611,6 +3612,7 @@ end "ReadHooks", "WriteHtmlClass", "WriteHtmlHook", + "WriteStats", }, IgnoreVariables = diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index f47d9c25a..69cbfbfa5 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -11,6 +11,21 @@ g_Plugin = nil; g_PluginFolder = ""; g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames. +g_Stats = -- Statistics about the documentation +{ + NumTotalClasses = 0, + NumUndocumentedClasses = 0, + NumTotalFunctions = 0, + NumUndocumentedFunctions = 0, + NumTotalConstants = 0, + NumUndocumentedConstants = 0, + NumTotalVariables = 0, + NumUndocumentedVariables = 0, + NumTotalHooks = 0, + NumUndocumentedHooks = 0, + NumTrackedLinks = 0, + NumInvalidLinks = 0, +} @@ -187,6 +202,8 @@ function DumpAPIHtml() end ); + g_Stats.NumTotalClasses = #API; + -- Add Globals into the API: Globals.Name = "Globals"; table.insert(API, Globals); @@ -243,6 +260,7 @@ function DumpAPIHtml()
  • Class index
  • Hooks
  • Extra pages
  • +
  • Documentation statistics

  • @@ -301,12 +319,8 @@ function DumpAPIHtml() f:write("
  • " .. extra.Title .. " (file is missing)
  • \n"); end end - f:write([[ - - -]]); - f:close(); - + f:write(""); + -- Copy the static files to the output folder (overwrite any existing): cFile:Copy(g_Plugin:GetLocalFolder() .. "/main.css", "API/main.css"); cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.js", "API/prettify.js"); @@ -318,6 +332,14 @@ function DumpAPIHtml() ListUnexportedObjects(); ListMissingPages(); + WriteStats(f); + + f:write([[ + + +]]); + f:close(); + LOG("API subfolder written"); end @@ -529,6 +551,7 @@ function ReadDescriptions(a_API) cls.UndocumentedConstants = {}; cls.UndocumentedVariables = {}; cls.Variables = cls.Variables or {}; + g_Stats.NumUndocumentedClasses = g_Stats.NumUndocumentedClasses + 1; for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then @@ -625,6 +648,7 @@ function ReadHooks(a_Hooks) end end end -- for i, hook - a_Hooks[] + g_Stats.NumTotalHooks = #a_Hooks; end @@ -851,6 +875,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) if (HasConstants) then cf:write("

    Constants

    \n"); WriteConstants(a_ClassAPI.Constants, nil); + g_Stats.NumTotalConstants = g_Stats.NumTotalConstants + #a_ClassAPI.Constants; for i, cls in ipairs(InheritanceChain) do WriteConstants(cls.Constants, cls.Name); end; @@ -860,6 +885,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) if (HasVariables) then cf:write("

    Member variables

    \n"); WriteVariables(a_ClassAPI.Variables, nil); + g_Stats.NumTotalVariables = g_Stats.NumTotalVariables + #a_ClassAPI.Variables; for i, cls in ipairs(InheritanceChain) do WriteVariables(cls.Variables, cls.Name); end; @@ -869,6 +895,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) if (HasFunctions) then cf:write("

    Functions

    \n"); WriteFunctions(a_ClassAPI.Functions, nil); + g_Stats.NumTotalFunctions = g_Stats.NumTotalFunctions + #a_ClassAPI.Functions; for i, cls in ipairs(InheritanceChain) do WriteFunctions(cls.Functions, cls.Name); end @@ -977,6 +1004,9 @@ function ListUndocumentedObjects(API, UndocumentedHooks) local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); local HasVariables = ((cls.UndocumentedVariables ~= nil) and (#cls.UndocumentedVariables > 0)); + g_Stats.NumUndocumentedFunctions = g_Stats.NumUndocumentedFunctions + #cls.UndocumentedFunctions; + g_Stats.NumUndocumentedConstants = g_Stats.NumUndocumentedConstants + #cls.UndocumentedConstants; + g_Stats.NumUndocumentedVariables = g_Stats.NumUndocumentedVariables + #cls.UndocumentedVariables; if (HasFunctions or HasConstants or HasVariables) then f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); if ((cls.Desc == nil) or (cls.Desc == "")) then @@ -1045,6 +1075,7 @@ function ListUndocumentedObjects(API, UndocumentedHooks) f:write("}\n\n\n\n"); f:close(); end + g_Stats.NumUndocumentedHooks = #UndocumentedHooks; end @@ -1086,11 +1117,14 @@ end function ListMissingPages() local MissingPages = {}; + local NumLinks = 0; for PageName, Referrers in pairs(g_TrackedPages) do + NumLinks = NumLinks + 1; if not(cFile:Exists("API/" .. PageName .. ".html")) then table.insert(MissingPages, {Name = PageName, Refs = Referrers} ); end end; + g_Stats.NumTrackedLinks = NumLinks; g_TrackedPages = {}; if (#MissingPages == 0) then @@ -1119,6 +1153,47 @@ function ListMissingPages() f:write("\n\n"); end f:close(); + g_Stats.NumInvalidLinks = #MissingPages; +end + + + + + +--- Writes the documentation statistics (in g_Stats) into the given HTML file +function WriteStats(f) + f:write([[ +

    Documentation statistics

    + + ]]); + f:write(""); + + f:write(""); + + f:write(""); + + f:write(""); + + f:write([[ +
    ObjectTotalDocumentedUndocumentedDocumented %
    Classes", g_Stats.NumTotalClasses); + f:write("", g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses); + f:write("", g_Stats.NumUndocumentedClasses); + f:write("", 100 * (g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses) / g_Stats.NumTotalClasses); + f:write("
    Functions", g_Stats.NumTotalFunctions); + f:write("", g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions); + f:write("", g_Stats.NumUndocumentedFunctions); + f:write("", 100 * (g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions) / g_Stats.NumTotalFunctions); + f:write("
    Member variables", g_Stats.NumTotalVariables); + f:write("", g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables); + f:write("", g_Stats.NumUndocumentedVariables); + f:write("", 100 * (g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables) / g_Stats.NumTotalVariables); + f:write("
    Constants", g_Stats.NumTotalConstants); + f:write("", g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants); + f:write("", g_Stats.NumUndocumentedConstants); + f:write("", 100 * (g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants) / g_Stats.NumTotalConstants); + f:write("
    +

    There are ]], g_Stats.NumTrackedLinks, " internal links, ", g_Stats.NumInvalidLinks, " of them are invalid.

    " + ); end -- cgit v1.2.3 From 0230936f619e8dcce6144e6489debca1a9bcc121 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 14:56:09 +0200 Subject: APIDump: Statistics have a graphical meter; added hooks. --- MCServer/Plugins/APIDump/main.lua | 48 +++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 69cbfbfa5..b608ce256 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -1162,33 +1162,63 @@ end --- Writes the documentation statistics (in g_Stats) into the given HTML file function WriteStats(f) + local function ExportMeter(a_Percent) + local Color; + if (a_Percent > 95) then + Color = "green"; + elseif (a_Percent > 50) then + Color = "orange"; + else + Color = "red"; + end + + local meter = { + "\n", + "
    \n", + "
    \n", + string.format("%.2f", a_Percent), + " %", + }; + return table.concat(meter, ""); + end + f:write([[

    Documentation statistics

    - +
    ObjectTotalDocumentedUndocumentedDocumented %
    ]]); f:write(""); + f:write("\n"); f:write(""); + f:write("\n"); f:write(""); + f:write("\n"); f:write(""); + f:write("\n"); + + f:write("\n"); f:write([[
    ObjectTotalDocumentedUndocumentedDocumented %
    Classes", g_Stats.NumTotalClasses); f:write("", g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses); f:write("", g_Stats.NumUndocumentedClasses); - f:write("", 100 * (g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses) / g_Stats.NumTotalClasses); - f:write("
    ", ExportMeter(100 * (g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses) / g_Stats.NumTotalClasses)); + f:write("
    Functions", g_Stats.NumTotalFunctions); f:write("", g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions); f:write("", g_Stats.NumUndocumentedFunctions); - f:write("", 100 * (g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions) / g_Stats.NumTotalFunctions); - f:write("
    ", ExportMeter(100 * (g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions) / g_Stats.NumTotalFunctions)); + f:write("
    Member variables", g_Stats.NumTotalVariables); f:write("", g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables); f:write("", g_Stats.NumUndocumentedVariables); - f:write("", 100 * (g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables) / g_Stats.NumTotalVariables); - f:write("
    ", ExportMeter(100 * (g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables) / g_Stats.NumTotalVariables)); + f:write("
    Constants", g_Stats.NumTotalConstants); f:write("", g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants); f:write("", g_Stats.NumUndocumentedConstants); - f:write("", 100 * (g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants) / g_Stats.NumTotalConstants); - f:write("
    ", ExportMeter(100 * (g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants) / g_Stats.NumTotalConstants)); + f:write("
    Hooks", g_Stats.NumTotalHooks); + f:write("", g_Stats.NumTotalHooks - g_Stats.NumUndocumentedHooks); + f:write("", g_Stats.NumUndocumentedHooks); + f:write("", ExportMeter(100 * (g_Stats.NumTotalHooks - g_Stats.NumUndocumentedHooks) / g_Stats.NumTotalHooks)); + f:write("
    -- cgit v1.2.3 From 16afec96debc34258c8c53e84c2cd6405f69a1f9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 15:08:30 +0200 Subject: APIDump: Fixed a few broken links. --- MCServer/Plugins/APIDump/APIDesc.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 260a18800..2f92d424a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -841,7 +841,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), etMinecart = { Notes = "The entity is a {{cMinecart}} descendant" }, etPlayer = { Notes = "The entity is a {{cPlayer}}" }, etPickup = { Notes = "The entity is a {{cPickup}}" }, - etProjectile = { Notes = "The entity is a {{cProjectile}} descendant" }, + etProjectile = { Notes = "The entity is a {{cProjectileEntity}} descendant" }, etTNT = { Notes = "The entity is a {{cTNTEntity}}" }, }, }, @@ -1872,7 +1872,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa BroadcastSoundParticleEffect = { Params = "EffectID, X, Y, Z, EffectData, [{{cClientHandle|ExcludeClient}}]", Return = "", Notes = "Sends the specified effect to all players in this world, except the optional ExceptClient" }, CastThunderbolt = { Params = "X, Y, Z", Return = "", Notes = "Creates a thunderbolt at the specified coords" }, ChangeWeather = { Params = "", Return = "", Notes = "Forces the weather to change in the next game tick. Weather is changed according to the normal rules: wSunny <-> wRain <-> wStorm" }, - CreateProjectile = { Params = "X, Y, Z, {{cProjectile|ProjectileKind}}, {{cEntity|Creator}}, [{{Vector3d|Speed}}]", Return = "", Notes = "Creates a new projectile of the specified kind at the specified coords. The projectile's creator is set to Creator (may be nil). Optional speed indicates the initial speed for the projectile." }, + CreateProjectile = { Params = "X, Y, Z, {{cProjectileEntity|ProjectileKind}}, {{cEntity|Creator}}, [{{Vector3d|Speed}}]", Return = "", Notes = "Creates a new projectile of the specified kind at the specified coords. The projectile's creator is set to Creator (may be nil). Optional speed indicates the initial speed for the projectile." }, DigBlock = { Params = "X, Y, Z", Return = "", Notes = "Replaces the specified block with air, without dropping the usual pickups for the block. Wakes up the simulators for the block and its neighbors." }, DoExplosionAt = { Params = "Force, X, Y, Z, CanCauseFire, Source, SourceData", Return = "", Notes = "Creates an explosion of the specified relative force in the specified position. If CanCauseFire is set, the explosion will set blocks on fire, too. The Source parameter specifies the source of the explosion, one of the esXXX constants. The SourceData parameter is specific to each source type, usually it provides more info about the source." }, DoWithChestAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a chest at the specified coords, calls the CallbackFunction with the {{cChestEntity}} parameter representing the chest. The CallbackFunction has the following signature:
    function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
    The function returns false if there is no chest, or if there is, it returns the bool value that the callback has returned." }, @@ -2483,7 +2483,7 @@ end; Desc = [[ This hook is called after an explosion has been processed in a world.

    - See also {{OnHookExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.

    + See also {{OnExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.

    The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, etc. It also carries the identification of the actual source. The exact type of the identification @@ -2526,7 +2526,7 @@ end; Desc = [[ This hook is called before an explosion has been processed in a world.

    - See also {{OnHookExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.

    + See also {{OnExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.

    The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, etc. It also carries the identification of the actual source. The exact type of the identification -- cgit v1.2.3 From 70a734d4f9804b8d46becc9ec458c3e60f12a6a5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 15:32:33 +0200 Subject: APIDump: Various small fixes and additions. --- MCServer/Plugins/APIDump/APIDesc.lua | 59 ++++++++++++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 2f92d424a..4f7ed5121 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -668,7 +668,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, }, - Inherits = "cBlockEntity"; + Inherits = "cBlockEntityWithItems"; }, cEnchantments = @@ -1040,8 +1040,12 @@ Internally, the class uses three {{cItemGrid|cItemGrid}} objects to store the co

  • Armor
  • Inventory
  • Hotbar
  • -These ItemGrids are available in the API and can be manipulated by the plugins, too. -]], +These ItemGrids are available in the API and can be manipulated by the plugins, too.

    +

    + When using the raw slot access functions, such as GetSlot() and SetSlot(), the slots are numbered + consecutively, each ItemGrid has its offset and count. To future-proff your plugins, use the named + constants instead of hard-coded numbers. + ]], Functions = { AddItem = { Params = "{{cItem|cItem}}, [AllowNewStacks]", Return = "number", Notes = "Adds an item to the storage; if AllowNewStacks is true (default), will also create new stacks in empty slots. Returns the number of items added" }, @@ -1129,6 +1133,15 @@ These ItemGrids are available in the API and can be manipulated by the plugins, }, AdditionalInfo = { + { + Header = "Usage notes", + Contents = [[ + Note that the object contained in a cItem class is quite complex and quite often new Minecraft + versions add more stuff. Therefore it is recommended to copy cItem objects using the + copy-constructor ("local copy = cItem(original);"), this is the only way that guarantees that + the object will be copied at full, even with future versions of MCServer. + ]], + }, { Header = "Example code", Contents = [[ @@ -1164,14 +1177,14 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); cItemGrid = { Desc = [[This class represents a 2D array of items. It is used as the underlying storage and API for all cases that use a grid of items: -

  • Chest contents
  • +
  • {{cChestEntity|Chest}} contents
  • (TODO) Chest minecart contents
  • -
  • {{cDispenserEntity|Dispenser|| contents
  • +
  • {{cDispenserEntity|Dispenser}} contents
  • {{cDropperEntity|Dropper}} contents
  • {{cFurnaceEntity|Furnace}} contents (?)
  • {{cHopperEntity|Hopper}} contents
  • (TODO) Hopper minecart contents
  • -
  • Player Inventory areas
  • +
  • {{cPlayer|Player}} Inventory areas
  • (TODO) Trapped chest contents
  • The items contained in this object are accessed either by a pair of XY coords, or a slot number (x + Width * y). There are functions available for converting between the two formats. @@ -1232,6 +1245,40 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); Constants = { }, + AdditionalInfo = + { + { + Header = "Code example: Add items to player inventory", + Contents = [[ + The following code tries to add 32 sticks to a player's main inventory: +

    +local Items = cItem(E_ITEM_STICK, 32);
    +local PlayerMainInventory = Player:GetInventorySlots();  -- PlayerMainInventory is of type cItemGrid
    +local NumAdded = PlayerMainInventory:AddItem(Items);
    +if (NumAdded == Items.m_ItemCount) then
    +  -- All the sticks did fit
    +  LOG("Added 32 sticks");
    +else
    +  -- Some (or all) of the sticks didn't fit
    +  LOG("Tried to add 32 sticks, but only " .. NumAdded .. " could fit");
    +end
    +
    + ]], + }, + { + Header = "Code example: Damage an item", + Contents = [[ + The following code damages the helmet in the player's armor and destroys it if it reaches max damage: +
    +local PlayerArmor = Player:GetArmorSlots();  -- PlayerArmor is of type cItemGrid
    +if (PlayerArmor:DamageItem(0)) then  -- Helmet is at SlotNum 0
    +  -- The helmet has reached max damage, destroy it:
    +  PlayerArmor:EmptySlot(0);
    +end
    +
    + ]], + }, + }, -- AdditionalInfo }, cItems = -- cgit v1.2.3 From 83d2d375c964314bb2f3447effd29ba2b03979d6 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 23:36:00 +0200 Subject: APIDump: Fixed link in cPawn's desc. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 4f7ed5121..5893825b8 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1497,7 +1497,7 @@ a_Player:OpenWindow(Window); cPawn = { - Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{centity|centity}} + Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{cEntity}} ]], Functions = { -- cgit v1.2.3 From b571294b6e24c3ae152f2017caf4013365efdccf Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 23:43:09 +0200 Subject: APIDump: Added link from cItem to the global ItemToString() et al. --- MCServer/Plugins/APIDump/APIDesc.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 5893825b8..1a7072f04 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1100,7 +1100,11 @@ These ItemGrids are available in the API and can be manipulated by the plugins, {{cEnchantments}} class and are accessible through the m_Enchantments variable.

    To test if a cItem object represents an empty item, do not compare the item type nor the item count, - but rather use the IsEmpty() function. + but rather use the IsEmpty() function.

    +

    + To translate from a cItem to its string representation, use the {{Globals#functions|global function}} + ItemToString(), ItemTypeToString() or ItemToFullString(). To translate from a string to a cItem, + use the StringToItem() global function. ]], Functions = -- cgit v1.2.3 From ec94104a3ce4f88ed1490fd4283ed5a429bf675c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Oct 2013 21:53:35 +0200 Subject: APIDump: Inheritance is tested properly. This fixes #195 's second iteration. --- MCServer/Plugins/APIDump/main.lua | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index b608ce256..eb0555d67 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -818,12 +818,10 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) local HasConstants = (#a_ClassAPI.Constants > 0); local HasFunctions = (#a_ClassAPI.Functions > 0); local HasVariables = (#a_ClassAPI.Variables > 0); - if (a_ClassAPI.Inherits ~= nil) then - for idx, cls in ipairs(a_ClassAPI.Inherits) do - HasConstants = HasConstants or (#cls.Constants > 0); - HasFunctions = HasFunctions or (#cls.Functions > 0); - HasVariables = HasVariables or (#cls.Variables > 0); - end + for idx, cls in ipairs(InheritanceChain) do + HasConstants = HasConstants or (#cls.Constants > 0); + HasFunctions = HasFunctions or (#cls.Functions > 0); + HasVariables = HasVariables or (#cls.Variables > 0); end -- Write the table of contents: -- cgit v1.2.3 From 34de5210d60d0a026a83ad051ae580c60db0dc4d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 22 Oct 2013 22:07:39 +0200 Subject: APIDump: member variables without a setter are considered constants. This fixes cChatColor constants being reported erroneously as member variables. --- MCServer/Plugins/APIDump/main.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index eb0555d67..2db8b4b1b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -158,9 +158,16 @@ function CreateAPITables() end -- Member variables: + local SetField = a_ClassObj[".set"] or {}; if ((a_ClassObj[".get"] ~= nil) and (type(a_ClassObj[".get"]) == "table")) then for k, v in pairs(a_ClassObj[".get"]) do - table.insert(res.Variables, { Name = k }); + if (SetField[k] == nil) then + -- It is a read-only variable, add it as a constant: + table.insert(res.Constants, {Name = k, Value = ""}); + else + -- It is a read-write variable, add it as a variable: + table.insert(res.Variables, { Name = k }); + end end end return res; -- cgit v1.2.3 From a91b422594ef75c500694adb0cb7968a5d336632 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Oct 2013 12:09:34 +0200 Subject: APIDump: Linkified cEntity returns. --- MCServer/Plugins/APIDump/APIDesc.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1a7072f04..63928e64c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -755,12 +755,12 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), GetHealth = { Params = "", Return = "number", Notes = "Returns the current health of the entity." }, GetHeight = { Params = "", Return = "number", Notes = "Returns the height (Y size) of the entity" }, GetKnockbackAmountAgainst = { Params = "ReceiverEntity", Return = "number", Notes = "Returns the amount of knockback that the currently equipped items would cause when attacking the ReceiverEntity." }, - GetLookVector = { Params = "", Return = "Vector3f", Notes = "Returns the vector that defines the direction in which the entity is looking" }, + GetLookVector = { Params = "", Return = "{{Vector3f}}", Notes = "Returns the vector that defines the direction in which the entity is looking" }, GetMass = { Params = "", Return = "number", Notes = "Returns the mass of the entity. Currently unused." }, GetMaxHealth = { Params = "", Return = "number", Notes = "Returns the maximum number of hitpoints this entity is allowed to have." }, GetParentClass = { Params = "", Return = "string", Notes = "Returns the name of the direct parent class for this entity" }, GetPitch = { Params = "", Return = "number", Notes = "Returns the pitch (nose-down rotation) of the entity" }, - GetPosition = { Params = "", Return = "Vector3d", Notes = "Returns the entity's pivot position as a 3D vector" }, + GetPosition = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the entity's pivot position as a 3D vector" }, GetPosX = { Params = "", Return = "number", Notes = "Returns the X-coord of the entity's pivot" }, GetPosY = { Params = "", Return = "number", Notes = "Returns the Y-coord of the entity's pivot" }, GetPosZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the entity's pivot" }, @@ -768,23 +768,26 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), GetRoll = { Params = "", Return = "number", Notes = "Returns the roll (sideways rotation) of the entity. Currently unused." }, GetRot = { Params = "", Return = "{{Vector3f}}", Notes = "Returns the entire rotation vector (Yaw, Pitch, Roll)" }, GetRotation = { Params = "", Return = "number", Notes = "Returns the yaw (direction) of the entity. FIXME: Rename to GetYaw()." }, - GetSpeed = { Params = "", Return = "Vector3d", Notes = "Returns the complete speed vector of the entity" }, + GetSpeed = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the complete speed vector of the entity" }, GetSpeedX = { Params = "", Return = "number", Notes = "Returns the X-part of the speed vector" }, GetSpeedY = { Params = "", Return = "number", Notes = "Returns the Y-part of the speed vector" }, GetSpeedZ = { Params = "", Return = "number", Notes = "Returns the Z-part of the speed vector" }, GetUniqueID = { Params = "", Return = "number", Notes = "Returns the ID that uniquely identifies the entity within the running server. Note that this ID is not persisted to the data files." }, GetWidth = { Params = "", Return = "number", Notes = "Returns the width (X and Z size) of the entity." }, - GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world where the entity resides" }, + GetWorld = { Params = "", Return = "{{cWorld}}", Notes = "Returns the world where the entity resides" }, Heal = { Params = "Hitpoints", Return = "", Notes = "Heals the specified number of hitpoints. Hitpoints is expected to be a positive number." }, IsA = { Params = "ClassName", Return = "bool", Notes = "Returns true if the entity class is a descendant of the specified class name, or the specified class itself" }, IsBoat = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cBoat|boat}}." }, IsCrouched = { Params = "", Return = "bool", Notes = "Returns true if the entity is crouched. Always false for entities that don't support crouching." }, IsDestroyed = { Params = "", Return = "bool", Notes = "Returns true if the entity has been destroyed and is awaiting removal from the internal structures." }, + IsFallingBlock = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cFallingBlock}} entity." }, + IsInvisible = { Params = "", Return = "bool", Notes = "Returns true if the entity is invisible" }, IsMinecart = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cMinecart|minecart}}" }, IsMob = { Params = "", Return = "bool", Notes = "Returns true if the entity represents any {{cMonster|mob}}." }, IsOnFire = { Params = "", Return = "bool", Notes = "Returns true if the entity is on fire" }, IsPickup = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cPickup|pickup}}." }, IsPlayer = { Params = "", Return = "bool", Notes = "Returns true if the entity represents a {{cPlayer|player}}" }, + IsProjectile = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cProjectileEntity}} descendant." }, IsRclking = { Params = "", Return = "bool", Notes = "Currently unimplemented" }, IsRiding = { Params = "", Return = "bool", Notes = "Returns true if the entity is attached to (riding) another entity." }, IsSprinting = { Params = "", Return = "bool", Notes = "Returns true if the entity is sprinting. Entities that cannot sprint return always false" }, -- cgit v1.2.3 From 60abe99d5e993408c5de3ab25dc91bbb9900d785 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Oct 2013 12:19:43 +0200 Subject: APIDump: Documented the cHopperEntity class. --- MCServer/Plugins/APIDump/APIDesc.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 63928e64c..3fcb68919 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -938,6 +938,28 @@ cFile:Delete("/usr/bin/virus.exe"); }, }, + cHopperEntity = + { + Desc = [[ + This class represents a hopper block entity in the world.

    +

    + Plugins may use this class during chunk generation ({{OnChunkGenerated|HOOK_CHUNK_GENERATED}} and + {{OnChunkGenerating|HOOK_CHUNK_GENERATING}}) to add hoppers to the generated chunk. + ]], + Functions = + { + constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cHopperEntity", Notes = "Creates and returns a new hopper at the specified coords." }, + GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." }, + }, + Constants = + { + ContentsHeight = { Notes = "Height (Y) of the internal {{cItemGrid}} representing the hopper contents." }, + ContentsWidth = { Notes = "Width (X) of the internal {{cItemGrid}} representing the hopper contents." }, + TICKS_PER_TRANSFER = { Notes = "Number of ticks between when the hopper transfers items." }, + }, + Inherits = "cBlockEntityWithItems", + }, + cIniFile = { Desc = [[The cIniFile is a class that makes it simple to read from and write to INI files. MCServer uses mostly INI files for settings and options. -- cgit v1.2.3 From 2cf196a892fb6d13dcb5f38369150da921ad8eb1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 23 Oct 2013 13:34:44 +0200 Subject: APIDump: Added cChatColor constants. They don't really need much documentation, so just ignoring them in the Undocumented output. --- MCServer/Plugins/APIDump/APIDesc.lua | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3fcb68919..0940931cd 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -369,10 +369,30 @@ g_APIDesc = }, Constants = { - Color = { Notes = "The first character of the color-code-sequence, §" }, - Delimiter = { Notes = "The first character of the color-code-sequence, §" }, - Random = { Notes = "Random letters and symbols animate instead of the text" }, + Black = { Notes = "" }, + Blue = { Notes = "" }, + Bold = { Notes = "" }, + Color = { Notes = "The first character of the color-code-sequence, §" }, + DarkPurple = { Notes = "" }, + Delimiter = { Notes = "The first character of the color-code-sequence, §" }, + Gold = { Notes = "" }, + Gray = { Notes = "" }, + Green = { Notes = "" }, + Italic = { Notes = "" }, + LightBlue = { Notes = "" }, + LightGray = { Notes = "" }, + LightGreen = { Notes = "" }, + LightPurple = { Notes = "" }, + Navy = { Notes = "" }, Plain = { Notes = "Resets all formatting to normal" }, + Purple = { Notes = "" }, + Random = { Notes = "Random letters and symbols animate instead of the text" }, + Red = { Notes = "" }, + Rose = { Notes = "" }, + Strikethrough = { Notes = "" }, + Underlined = { Notes = "" }, + White = { Notes = "" }, + Yellow = { Notes = "" }, }, }, -- cgit v1.2.3 From 6cad07c4295dbc720992335a0f114f468cb2d670 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 12:24:11 +0200 Subject: APIDump: Documented cItemGrid and cPlayer. --- MCServer/Plugins/APIDump/APIDesc.lua | 105 +++++++++++++++++++++++++---------- 1 file changed, 75 insertions(+), 30 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0940931cd..3b459e686 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1260,9 +1260,12 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); { Params = "X, Y", Return = "", Notes = "Destroys the item in the specified slot" }, }, GetFirstEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the first empty slot, -1 if all slots are full" }, + GetFirstUsedSlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the first non-empty slot, -1 if all slots are empty" }, GetHeight = { Params = "", Return = "number", Notes = "Returns the Y dimension of the grid" }, GetLastEmptySlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the last empty slot, -1 if all slots are full" }, + GetLastUsedSlot = { Params = "", Return = "number", Notes = "Returns the SlotNumber of the last non-empty slot, -1 if all slots are empty" }, GetNextEmptySlot = { Params = "StartFrom", Return = "number", Notes = "Returns the SlotNumber of the first empty slot following StartFrom, -1 if all the following slots are full" }, + GetNextUsedSlot = { Params = "StartFrom", Return = "number", Notes = "Returns the SlotNumber of the first non-empty slot following StartFrom, -1 if all the following slots are full" }, GetNumSlots = { Params = "", Return = "number", Notes = "Returns the total number of slots in the grid (Width * Height)" }, GetSlot = { @@ -1581,42 +1584,84 @@ a_Player:OpenWindow(Window); cPlayer = { - Desc = [[cPlayer describes a human player in the server. cPlayer inherits all functions and members of {{cPawn|cPawn}} -]], + Desc = [[ + This class describes a player in the server. cPlayer inherits all functions and members of + {{cPawn|cPawn}}. It handles all the aspects of the gameplay, such as hunger, sprinting, inventory + etc. + ]], Functions = { - GetEyeHeight = { Return = "number" }, - GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}" }, - GetFlying = { Return = "bool" }, - GetStance = { Return = "number" }, - GetInventory = { Return = "{{cInventory|Inventory}}" }, + AddFoodExhaustion = { Params = "Exhaustion", Return = "", Notes = "Adds the specified number to the food exhaustion. Only positive numbers expected." }, + AddToGroup = { Params = "GroupName", Return = "", Notes = "Temporarily adds the player to the specified group. The assignment is lost when the player disconnects." }, + CanUseCommand = { Params = "Command", Return = "bool", Notes = "Returns true if the player is allowed to use the specified command." }, + CloseWindow = { Params = "[CanRefuse]", Return = "", Notes = "Closes the currently open UI window. If CanRefuse is true (default), the window may refuse the closing." }, + CloseWindowIfID = { Params = "WindowID, [CanRefuse]", Return = "", Notes = "Closes the currently open UI window if its ID matches the given ID. If CanRefuse is true (default), the window may refuse the closing." }, + Feed = { Params = "AddFood, AddSaturation", Return = "bool", Notes = "Tries to add the specified amounts to food level and food saturation level (only positive amounts expected). Returns true if player was hungry and the food was consumed, false if too satiated." }, + FoodPoison = { Params = "NumTicks", Return = "", Notes = "Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two" }, + GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left)." }, + GetClientHandle = { Params = "", Return = "{{cClientHandle}}", Notes = "Returns the client handle representing the player's connection. May be nil (AI players)." }, + GetColor = { Return = "string", Notes = "Returns the full color code to be used for this player (based on the first group). Prefix player messages with this code." }, + GetEquippedItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that the player is currently holding; empty item if holding nothing." }, + GetEyeHeight = { Return = "number", Notes = "Returns the height of the player's eyes, in absolute coords" }, + GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}", Notes = "Returns the position of the player's eyes, as a {{Vector3d}}" }, + GetFoodExhaustionLevel = { Params = "", Return = "number", Notes = "Returns the food exhaustion level" }, + GetFoodLevel = { Params = "", Return = "number", Notes = "Returns the food level (number of half-drumsticks on-screen)" }, + GetFoodPoisonedTicksRemaining = { Params = "", Return = "", Notes = "Returns the number of ticks left for the food posoning effect" }, + GetFoodSaturationLevel = { Params = "", Return = "number", Notes = "Returns the food saturation (overcharge of the food level, is depleted before food level)" }, + GetFoodTickTimer = { Params = "", Return = "", Notes = "Returns the number of ticks past the last food-based heal or damage action; when this timer reaches 80, a new heal / damage is applied." }, GetGameMode = { Return = "{{eGameMode|GameMode}}", Notes = "Returns the player's gamemode. The player may have their gamemode unassigned, in which case they inherit the gamemode from the current {{cWorld|world}}.
    NOTE: Instead of comparing the value returned by this function to the gmXXX constants, use the IsGameModeXXX() functions. These functions handle the gamemode inheritance automatically."}, - GetIP = { Return = "string" }, - SetGameMode = { Return = "" }, - MoveTo = { Return = "" }, - GetClientHandle = { Return = "{{cClientHandle|ClientHandle}}" }, - SendMessage = { Return = "" }, - GetName = { Return = "String" }, - SetName = { Return = "" }, - AddToGroup = { Return = "" }, - CanUseCommand = { Return = "bool" }, - HasPermission = { Return = "bool" }, - IsInGroup = { Return = "bool" }, - GetColor = { Return = "string" }, - TossItem = { Return = "" }, - Heal = { Return = "" }, - TakeDamage = { Return = "" }, - KilledBy = { Return = "" }, - Respawn = { Return = "" }, - SetVisible = { Return = "" }, - IsVisible = { Return = "bool" }, - MoveToWorld = { Return = "bool" }, - LoadPermissionsFromDisk = { Return = "" }, - GetGroups = { Return = "list<{{cGroup|cGroup}}>" }, - GetResolvedPermissions = { Return = "string" }, + GetGroups = { Return = "array-table of {{cGroup}}", Notes = "Returns all the groups that this player is member of, as a table. The groups are stored in the array part of the table, beginning with index 1."}, + GetIP = { Return = "string", Notes = "Returns the IP address of the player, if available. Returns an empty string if there's no IP to report."}, + GetInventory = { Return = "{{cInventory|Inventory}}", Notes = "Returns the player's inventory"}, + GetMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's current maximum speed (as reported by the 1.6.1+ protocols)" }, + GetName = { Return = "string", Notes = "Returns the player's name" }, + GetNormalMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's maximum walking speed (as reported by the 1.6.1+ protocols)" }, + GetResolvedPermissions = { Return = "array-table of string", Notes = "Returns all the player's permissions, as a table. The permissions are stored in the array part of the table, beginning with index 1." }, + GetSprintingMaxSpeed = { Params = "", Return = "number", Notes = "Returns the player's maximum sprinting speed (as reported by the 1.6.1+ protocols)" }, + GetStance = { Return = "number", Notes = "Returns the player's stance (Y-pos of player's eyes)" }, + GetThrowSpeed = { Params = "SpeedCoeff", Return = "{{Vector3d}}", Notes = "Returns the speed vector for an object thrown with the specified speed coeff. Basically returns the normalized look vector multiplied by the coeff, with a slight random variation." }, + GetThrowStartPos = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the position where the projectiles should start when thrown by this player." }, + GetWindow = { Params = "", Return = "{{cWindow}}", Notes = "Returns the currently open UI window. If the player doesn't have any UI window open, returns the inventory window." }, + HasPermission = { Params = "PermissionString", Return = "bool", Notes = "Returns true if the player has the specified permission" }, + Heal = { Params = "HitPoints", Return = "", Notes = "Heals the player by the specified amount of HPs. Only positive amounts are expected. Sends a health update to the client." }, + IsEating = { Params = "", Return = "bool", Notes = "Returns true if the player is currently eating the item in their hand." }, + IsGameModeAdventure = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmAdventure gamemode, or has their gamemode unset and the world is a gmAdventure world." }, + IsGameModeCreative = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmCreative gamemode, or has their gamemode unset and the world is a gmCreative world." }, + IsGameModeSurvival = { Params = "", Return = "bool", Notes = "Returns true if the player is in the gmSurvival gamemode, or has their gamemode unset and the world is a gmSurvival world." }, + IsInGroup = { Params = "GroupNameString", Return = "bool", Notes = "Returns true if the player is a member of the specified group." }, + IsOnGround = { Params = "", Return = "bool", Notes = "Returns true if the player is on ground (not falling, not jumping, not flying)" }, + IsSatiated = { Params = "", Return = "bool", Notes = "Returns true if the player is satiated (cannot eat)." }, + IsSubmerged = { Params = "", Return = "bool", Notes = "Returns true if the player is submerged in water (the player's head is in a water block)" }, + IsSwimming = { Params = "", Return = "bool", Notes = "Returns true if the player is swimming in water (the player's feet are in a water block)" }, + IsVisible = { Params = "", Return = "bool", Notes = "Returns true if the player is visible to other players" }, + LoadPermissionsFromDisk = { Params = "", Return = "", Notes = "Reloads the player's permissions from the disk. This loses any temporary changes made to the player's groups." }, + MoveTo = { Params = "{{Vector3d|NewPosition}}", Return = "Tries to move the player into the specified position." }, + MoveToWorld = { Params = "WorldName", Return = "bool", Return = "Moves the player to the specified world. Returns true if successful." }, + OpenWindow = { Params = "{{cWindow|Window}}", Return = "", Notes = "Opens the specified UI window for the player." }, + RemoveFromGroup = { Params = "GroupName", Return = "", Notes = "Temporarily removes the player from the specified group. This change is lost when the player disconnects." }, + Respawn = { Params = "", Return = "", Notes = "Restores the health, extinguishes fire, makes visible and sends the Respawn packet." }, + SendMessage = { Params = "MessageString", Return = "", Notes = "Sends the specified message to the player." }, + SetCrouch = { Params = "IsCrouched", Return = "", Notes = "Sets the crouch state, broadcasts the change to other players." }, + SetFoodExhaustionLevel = { Params = "ExhaustionLevel", Return = "", Notes = "Sets the food exhaustion to the specified level." }, + SetFoodLevel = { Params = "FoodLevel", Return = "", Notes = "Sets the food level (number of half-drumsticks on-screen)" }, + SetFoodPoisonedTicksRemaining = { Params = "FoodPoisonedTicksRemaining", Return = "", Notes = "Sets the number of ticks remaining for food poisoning. Doesn't send foodpoisoning effect to the client, use FoodPoison() for that." }, + SetFoodSaturationLevel = { Params = "FoodSaturationLevel", Return = "", Notes = "Sets the food saturation (overcharge of the food level)." }, + SetFoodTickTimer = { Params = "FoodTickTimer", Return = "", Notes = "Sets the number of ticks past the last food-based heal or damage action; when this timer reaches 80, a new heal / damage is applied." }, + SetGameMode = { Params = "{{eGameMode|NewGameMode}}", Return = "", Notes = "Sets the gamemode for the player. The new gamemode overrides the world's default gamemode, unless it is set to gmInherit." }, + SetName = { Params = "Name", Return = "", Notes = "Sets the player name. This rename will NOT be visible to any players already in the server who are close enough to see this player." }, + SetNormalMaxSpeed = { Params = "NormalMaxSpeed", Return = "", Notes = "Sets the normal (walking) maximum speed (as reported by the 1.6.1+ protocols)" }, + SetSprint = { Params = "IsSprinting", Return = "", Notes = "Sets whether the player is sprinting or not." }, + SetSprintingMaxSpeed = { Params = "SprintingMaxSpeed", Return = "", Notes = "Sets the sprinting maximum speed (as reported by the 1.6.1+ protocols)" }, + SetVisible = { Params = "IsVisible", Return = "", Notes = "Sets the player visibility to other players" }, + TossItem = { Params = "DraggedItem, [Amount], [CreateType], [CreateDamage]", Return = "", Notes = "FIXME: This function will be rewritten, avoid it. It tosses an item, either from the inventory, dragged in hand (while in UI window) or a newly created one." }, }, Constants = { + DROWNING_TICKS = { Notes = "Number of ticks per heart of damage when drowning (zero AirLevel)" }, + EATING_TICKS = { Notes = "Number of ticks required for consuming an item." }, + MAX_AIR_LEVEL = { Notes = "The maximum air level value. AirLevel gets reset to this value when the player exits water." }, + MAX_FOOD_LEVEL = { Notes = "The maximum food level value. When the food level is at this value, the player cannot eat." }, + MAX_HEALTH = { Notes = "The maximum health value" }, }, Inherits = "cPawn", }, -- cgit v1.2.3 From 785301c9a07c22df204323cde261f93649e9481b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 16:27:48 +0200 Subject: APIDump: Documented cPickup. --- MCServer/Plugins/APIDump/APIDesc.lua | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3b459e686..0d7770a49 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1568,16 +1568,18 @@ a_Player:OpenWindow(Window); cPickup = { - Desc = [[cPickup is a pickup object representation. It is also commonly known as "drops". With this class you could create your own "drop" or modify automatically created. -]], + Desc = [[ + This class represents a pickup entity (an item that the player or mobs can pick up). It is also + commonly known as "drops". With this class you could create your own "drop" or modify those + created automatically. + ]], Functions = { - cPickup = { Notes = "[[cPickup}}" }, - GetItem = { Notes = "{{cItem|cItem}}" }, - CollectedBy = { Return = "bool" }, - }, - Constants = - { + constructor = { Params = "PosX, PosY, PosZ, {{cItem|Item}}, IsPlayerCreated, [SpeedX, SpeedY, SpeedZ]", Return = "cPickup", Notes = "Creates a new pickup at the specified coords. If IsPlayerCreated is true, the pickup has a longer initial collection interval." }, + CollectedBy = { Params = "{{cPlayer}}", Return = "bool", Notes = "Tries to make the player collect the pickup. Returns true if the pickup was collected, at least partially." }, + GetAge = { Params = "", Return = "number", Notes = "Returns the number of ticks that the pickup has existed." }, + GetItem = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item represented by this pickup" }, + IsCollected = { Params = "", Return = "bool", Notes = "Returns true if this pickup has already been collected (is waiting to be destroyed)" }, }, Inherits = "cEntity", }, -- cgit v1.2.3 From 7c2ba5544205a4b59ec34b8b487f7f3b7e32af74 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 16:32:51 +0200 Subject: APIDump: Documented cEnchantments. The constants are self-documenting, no need to describe them further. --- MCServer/Plugins/APIDump/APIDesc.lua | 41 ++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0d7770a49..e273924be 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -693,10 +693,20 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cEnchantments = { - Desc = [[This class is the storage for enchantments for a single {{cItem|cItem}} object, through its m_Enchantments member variable. Although it is possible to create a standalone object of this class, it is not yet used in any API directly. -

    -

    Enchantments can be initialized either programmatically by calling the individual functions (SetLevel()), or by using a string description of the enchantment combination. This string description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the enchantment, or its textual representation from the table below, and lvl is the desired enchantment level. The class can also create its string description from its current contents; however that string description will only have the numerical IDs. -]], + Desc = [[ + This class is the storage for enchantments for a single {{cItem|cItem}} object, through its + m_Enchantments member variable. Although it is possible to create a standalone object of this class, + it is not yet used in any API directly.

    +

    + Enchantments can be initialized either programmatically by calling the individual functions + (SetLevel()), or by using a string description of the enchantment combination. This string + description is in the form "id=lvl;id=lvl;...;id=lvl;", where id is either a numerical ID of the + enchantment, or its textual representation from the table below, and lvl is the desired enchantment + level. The class can also create its string description from its current contents; however that + string description will only have the numerical IDs.

    +

    + See the {{cItem}} class for usage examples. + ]], Functions = { constructor = @@ -715,6 +725,29 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), }, Constants = { + -- Only list these enchantment IDs, as they don't really need any kind of documentation: + enchAquaAffinity = { Notes = "" }, + enchBaneOfArthropods = { Notes = "" }, + enchBlastProtection = { Notes = "" }, + enchEfficiency = { Notes = "" }, + enchFeatherFalling = { Notes = "" }, + enchFireAspect = { Notes = "" }, + enchFireProtection = { Notes = "" }, + enchFlame = { Notes = "" }, + enchFortune = { Notes = "" }, + enchInfinity = { Notes = "" }, + enchKnockback = { Notes = "" }, + enchLooting = { Notes = "" }, + enchPower = { Notes = "" }, + enchProjectileProtection = { Notes = "" }, + enchProtection = { Notes = "" }, + enchPunch = { Notes = "" }, + enchRespiration = { Notes = "" }, + enchSharpness = { Notes = "" }, + enchSilkTouch = { Notes = "" }, + enchSmite = { Notes = "" }, + enchThorns = { Notes = "" }, + enchUnbreaking = { Notes = "" }, }, }, -- cgit v1.2.3 From c875b887589144b19109f4d9f2cb2815c1a79411 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 24 Oct 2013 17:20:52 +0200 Subject: APIDump: Documented cMonster. --- MCServer/Plugins/APIDump/APIDesc.lua | 55 ++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e273924be..0de6afbb8 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1574,9 +1574,58 @@ a_Player:OpenWindow(Window); cMonster = { - Desc = "", - Functions = {}, - Constants = {}, + Desc = [[ + This class is the base class for all computer-controlled mobs in the game.

    +

    + To spawn a mob in a world, use the {{cWorld}}:SpawnMob() function. + ]], + Functions = + { + FamilyFromType = { Params = "MobType", Return = "MobFamily", Notes = "(STATIC) Returns the mob family (mfXXX constants) based on the mob type (mtXXX constants)" }, + GetMobFamily = { Params = "", Return = "MobFamily", Notes = "Returns this mob's family (mfXXX constant)" }, + GetMobType = { Params = "", Return = "MobType", Notes = "Returns the type of this mob (mtXXX constant)" }, + GetSpawnDelay = { Params = "MobFamily", Return = "number", Notes = "(STATIC) Returns the spawn delay - the number of game ticks between spawn attempts - for the specified mob family." }, + MobTypeToString = { Params = "MobType", Return = "string", Notes = "(STATIC) Returns the string representing the given mob type (mtXXX constant), or empty string if unknown type." }, + StringToMobType = { Params = "string", Return = "MobType", Notes = "(STATIC) Returns the mob type (mtXXX constant) parsed from the string type (\"creeper\"), or mtInvalidType if unrecognized." }, + }, + Constants = + { + mfAmbient = { Notes = "Family: ambient (bat)" }, + mfHostile = { Notes = "Family: hostile (blaze, cavespider, creeper, enderdragon, enderman, ghast, giant, magmacube, silverfish, skeleton, slime, spider, witch, wither, zombie, zombiepigman)" }, + mfMaxplusone = { Notes = "The maximum family value, plus one. Returned when monster family not recognized." }, + mfPassive = { Notes = "Family: passive (chicken, cow, horse, irongolem, mooshroom, ocelot, pig, sheep, snowgolem, villager, wolf)" }, + mfWater = { Notes = "Family: water (squid)" }, + mtBat = { Notes = "" }, + mtBlaze = { Notes = "" }, + mtCaveSpider = { Notes = "" }, + mtChicken = { Notes = "" }, + mtCow = { Notes = "" }, + mtCreeper = { Notes = "" }, + mtEnderDragon = { Notes = "" }, + mtEnderman = { Notes = "" }, + mtGhast = { Notes = "" }, + mtGiant = { Notes = "" }, + mtHorse = { Notes = "" }, + mtInvalidType = { Notes = "Invalid monster type. Returned when monster type not recognized" }, + mtIronGolem = { Notes = "" }, + mtMagmaCube = { Notes = "" }, + mtMooshroom = { Notes = "" }, + mtOcelot = { Notes = "" }, + mtPig = { Notes = "" }, + mtSheep = { Notes = "" }, + mtSilverfish = { Notes = "" }, + mtSkeleton = { Notes = "" }, + mtSlime = { Notes = "" }, + mtSnowGolem = { Notes = "" }, + mtSpider = { Notes = "" }, + mtSquid = { Notes = "" }, + mtVillager = { Notes = "" }, + mtWitch = { Notes = "" }, + mtWither = { Notes = "" }, + mtWolf = { Notes = "" }, + mtZombie = { Notes = "" }, + mtZombiePigman = { Notes = "" }, + }, Inherits = "cPawn", }, -- cgit v1.2.3 From de6f628d2e7ce08f695e524eda0b682347c5e1e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 25 Oct 2013 12:36:39 +0200 Subject: ChunkWorx: Updated for the cIniFile changes. --- MCServer/Plugins/ChunkWorx/chunkworx_main.lua | 53 ++++++++++------------- MCServer/Plugins/ChunkWorx/chunkworx_web.lua | 61 +++++++++++++++++---------- 2 files changed, 62 insertions(+), 52 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua index ab9962387..f74c4ea2d 100644 --- a/MCServer/Plugins/ChunkWorx/chunkworx_main.lua +++ b/MCServer/Plugins/ChunkWorx/chunkworx_main.lua @@ -6,20 +6,27 @@ CX = 0 CZ = 0 CURRENT = 0 TOTAL = 0 + -- AREA Variables AreaStartX = -10 AreaStartZ = -10 AreaEndX = 10 AreaEndZ = 10 + -- RADIAL Variables RadialX = 0 RadialZ = 0 -Radius = 1 +Radius = 10 + -- WORLD WORK_WORLD = cRoot:Get():GetDefaultWorld():GetName() WW_instance = cRoot:Get():GetDefaultWorld() WORLDS = {} + + + + function Initialize(Plugin) PLUGIN = Plugin @@ -36,39 +43,25 @@ function Initialize(Plugin) LOG("" .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. ": NO WORLD found :(") end - PLUGIN.IniFile = cIniFile("ChunkWorx.ini") - if (PLUGIN.IniFile:ReadFile() == false) then - PLUGIN.IniFile:HeaderComment("ChunkWorx Save") - PLUGIN.IniFile:AddKeyName("Area data") - PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX) - PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ) - PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX) - PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ) - PLUGIN.IniFile:AddKeyName("Radial data") - PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX) - PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ) - PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius) - PLUGIN.IniFile:WriteFile() - end - - AreaStartX = PLUGIN.IniFile:GetValueI("Area data", "StartX") - AreaStartZ = PLUGIN.IniFile:GetValueI("Area data", "StartZ") - AreaEndX = PLUGIN.IniFile:GetValueI("Area data", "EndX") - AreaEndZ = PLUGIN.IniFile:GetValueI("Area data", "EndZ") - - RadialX = PLUGIN.IniFile:GetValueI("Radial data", "RadialX") - RadialZ = PLUGIN.IniFile:GetValueI("Radial data", "RadialZ") - Radius = PLUGIN.IniFile:GetValueI("Radial data", "Radius") + -- Read the stored values: + local SettingsIni = cIniFile(); + SettingsIni:ReadFile("ChunkWorx.ini"); -- ignore any read errors + AreaStartX = SettingsIni:GetValueSetI("Area data", "StartX", AreaStartX) + AreaStartZ = SettingsIni:GetValueSetI("Area data", "StartZ", AreaStartZ) + AreaEndX = SettingsIni:GetValueSetI("Area data", "EndX", AreaEndX) + AreaEndZ = SettingsIni:GetValueSetI("Area data", "EndZ", AreaEndZ) + RadialX = SettingsIni:GetValueSetI("Radial data", "RadialX", RadialX) + RadialZ = SettingsIni:GetValueSetI("Radial data", "RadialZ", RadialZ) + Radius = SettingsIni:GetValueSetI("Radial data", "Radius", Radius) + SettingsIni:WriteFile("ChunkWorx.ini"); LOG("Initialized " .. PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion()) - --LOG("Test1: " .. math.fmod(1.5, 1)) - return fractional part! return true end -function OnDisable() - PLUGIN.IniFile:WriteFile() - LOG(PLUGIN:GetName() .. " v" .. PLUGIN:GetVersion() .. " is shutting down...") -end + + + function OnTick( DeltaTime ) if (GENERATION_STATE == 1 or GENERATION_STATE == 3) then @@ -128,7 +121,7 @@ function OnTick( DeltaTime ) end end end - WW_instance:SaveAllChunks() + WW_instance:QueueSaveAllChunks() WW_instance:UnloadUnusedChunks() end end diff --git a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua index e9a930c92..44993f81c 100644 --- a/MCServer/Plugins/ChunkWorx/chunkworx_web.lua +++ b/MCServer/Plugins/ChunkWorx/chunkworx_web.lua @@ -1,11 +1,44 @@ + +-- chunkworx_web.lua + +-- WebAdmin-related functions + + + + + local function Buttons_Player( Name ) return "

    " end + + + + local function Button_World( Name ) return "
    " end + + + + +local function SaveSettings() + local SettingsIni = cIniFile() + SettingsIni:SetValueI("Area data", "StartX", AreaStartX) + SettingsIni:SetValueI("Area data", "StartZ", AreaStartZ) + SettingsIni:SetValueI("Area data", "EndX", AreaEndX) + SettingsIni:SetValueI("Area data", "EndZ", AreaEndZ) + SettingsIni:SetValueI("Radial data", "RadialX", RadialX) + SettingsIni:SetValueI("Radial data", "RadialZ", RadialZ) + SettingsIni:SetValueI("Radial data", "Radius", Radius) + SettingsIni:WriteFile("ChunkWorx.ini") +end + + + + + function HandleRequest_Generation( Request ) local Content = "" if (Request.PostParams["AGHRRRR"] ~= nil) then @@ -69,21 +102,12 @@ function HandleRequest_Generation( Request ) AreaStartZ = tonumber(Request.PostParams["FormAreaStartZ"]) AreaEndX = tonumber(Request.PostParams["FormAreaEndX"]) AreaEndZ = tonumber(Request.PostParams["FormAreaEndZ"]) - - PLUGIN.IniFile:DeleteValue("Area data", "StartX") - PLUGIN.IniFile:DeleteValue("Area data", "StartZ") - PLUGIN.IniFile:DeleteValue("Area data", "EndX") - PLUGIN.IniFile:DeleteValue("Area data", "EndZ") - PLUGIN.IniFile:SetValueI("Area data", "StartX", AreaStartX) - PLUGIN.IniFile:SetValueI("Area data", "StartZ", AreaStartZ) - PLUGIN.IniFile:SetValueI("Area data", "EndX", AreaEndX) - PLUGIN.IniFile:SetValueI("Area data", "EndZ", AreaEndZ) + SaveSettings(); if (OPERATION_CODE == 0) then GENERATION_STATE = 1 elseif (OPERATION_CODE == 1) then GENERATION_STATE = 3 end - PLUGIN.IniFile:WriteFile() Content = ProcessingContent() return Content end @@ -93,26 +117,19 @@ function HandleRequest_Generation( Request ) and Request.PostParams["FormRadius"] ~= nil ) then --(Re)Generation valid! -- COMMON (Re)gen if( Request.PostParams["StartRadial"]) then - RadialX = tonumber(Request.PostParams["FormRadialX"]) - RadialZ = tonumber(Request.PostParams["FormRadialZ"]) - Radius = tonumber(Request.PostParams["FormRadius"]) + RadialX = tonumber(Request.PostParams["FormRadialX"]) or 0 + RadialZ = tonumber(Request.PostParams["FormRadialZ"]) or 0 + Radius = tonumber(Request.PostParams["FormRadius"]) or 10 AreaStartX = RadialX - Radius AreaStartZ = RadialZ - Radius AreaEndX = RadialX + Radius AreaEndZ = RadialZ + Radius - - PLUGIN.IniFile:DeleteValue("Radial data", "RadialX") - PLUGIN.IniFile:DeleteValue("Radial data", "RadialZ") - PLUGIN.IniFile:DeleteValue("Radial data", "Radius") - PLUGIN.IniFile:SetValueI("Radial data", "RadialX", RadialX) - PLUGIN.IniFile:SetValueI("Radial data", "RadialZ", RadialZ) - PLUGIN.IniFile:SetValueI("Radial data", "Radius", Radius) + SaveSettings() if (OPERATION_CODE == 0) then GENERATION_STATE = 1 elseif (OPERATION_CODE == 1) then GENERATION_STATE = 3 end - PLUGIN.IniFile:WriteFile() Content = ProcessingContent() return Content end @@ -214,7 +231,7 @@ function HandleRequest_Generation( Request ) Content = Content .. "" -- SELECTING RADIAL - Content = Content .. "

    Radial:

    Center X, Center Z, Raduis (0 to any)" + Content = Content .. "

    Radial:

    Center X, Center Z, Radius" Content = Content .. "
    " Content = Content .. "" Content = Content .. "" -- cgit v1.2.3 From e7b3ced70b14a9cb24d61036be9b740a0a14897b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 26 Oct 2013 10:33:44 +0200 Subject: APIDump: Documented cIniFile. --- MCServer/Plugins/APIDump/APIDesc.lua | 216 ++++++++++++++++++++++------------- 1 file changed, 135 insertions(+), 81 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0de6afbb8..b60a6f746 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1015,101 +1015,155 @@ cFile:Delete("/usr/bin/virus.exe"); cIniFile = { - Desc = [[The cIniFile is a class that makes it simple to read from and write to INI files. MCServer uses mostly INI files for settings and options. -]], + Desc = [[ + This class implements a simple name-value storage represented on disk by an INI file. These files + are suitable for low-volume high-latency human-readable information storage, such as for + configuration. MCServer itself uses INI files for settings and options.

    +

    + The INI files follow this basic structure: +

    +; Header comment line
    +[KeyName0]
    +; Key comment line 0
    +ValueName0=Value0
    +ValueName1=Value1
    +
    +[KeyName1]
    +; Key comment line 0
    +; Key comment line 1
    +ValueName0=SomeOtherValue
    +
    + The cIniFile object stores all the objects in numbered arrays and provides access to the information + either based on names (KeyName, ValueName) or zero-based indices.

    +

    + The objects of this class are created empty. You need to either load a file using ReadFile(), or + insert values by hand. Then you can store the object's contents to a disk file using WriteFile(), or + just forget everything by destroying the object. Note that the file operations are quite slow.

    +

    + For storing high-volume low-latency data, use the {{sqlite}} class. For storing + hierarchically-structured data, use the XML format, using the LuaExpat parser in the {{lxp}} class. + ]], Functions = { - constructor = { Return = "{{cIniFile|cIniFile}}" }, - CaseSensitive = { Return = "" }, - CaseInsensitive = { Return = "" }, - Path = { Return = "" }, - Path = { Return = "string" }, - SetPath = { Return = "" }, - ReadFile = { Return = "bool" }, - WriteFile = { Return = "bool" }, - Erase = { Return = "" }, - Clear = { Return = "" }, - Reset = { Return = "" }, - FindKey = { Notes = "long i" }, - FindValue = { Notes = "long i" }, - NumKeys = { Notes = "unsigned i" }, - GetNumKeys = { Notes = "unsigned i" }, - AddKeyName = { Notes = "unsigned int" }, - KeyName = { Notes = "Stri" }, - GetKeyName = { Notes = "Stri" }, - NumValues = { Notes = "unsigned int" }, - GetNumValues = { Notes = "unsigned int" }, - NumValues = { Notes = "unsigned int" }, - GetNumValues = { Notes = "unsigned int" }, - ValueName = { Notes = "Stri" }, - GetValueName = { Notes = "Stri" }, - ValueName = { Notes = "Stri" }, - GetValueName = { Notes = "Stri" }, - GetValue = { Notes = "Stri" }, - GetValue = { Notes = "Stri" }, - GetValueI = { Notes = "i" }, - GetValueB = { Notes = "bo" }, - GetValueF = { Notes = "doub" }, - GetValueSet = { Notes = "Stri" }, - GetValueSetI = { Notes = "i" }, - GetValueSetB = { Notes = "bo" }, - GetValueSetF = { Notes = "doub" }, - SetValue = { Return = "bool" }, - SetValue = { Return = "bool" }, - SetValueI = { Return = "bool" }, - SetValueB = { Return = "bool" }, - SetValueF = { Return = "bool" }, - DeleteValueByID = { Return = "bool" }, - DeleteValue = { Return = "bool" }, - DeleteKey = { Return = "bool" }, - NumHeaderComments = { Notes = "unsigned int" }, - HeaderComment = { Return = "" }, - HeaderComment = { Notes = "Stri" }, - DeleteHeaderComment = { Return = "bool" }, - DeleteHeaderComments = { Return = "" }, - NumKeyComments = { Notes = "unsigned i" }, - NumKeyComments = { Notes = "unsigned i" }, - KeyComment = { Return = "bool" }, - KeyComment = { Return = "bool" }, - KeyComment = { Notes = "Stri" }, - KeyComment = { Notes = "Stri" }, - DeleteKeyComment = { Return = "bool" }, - DeleteKeyComment = { Return = "bool" }, - DeleteKeyComments = { Return = "bool" }, - DeleteKeyComments = { Return = "bool" }, + constructor = { Params = "", Return = "cIniFile", Notes = "Creates a new empty cIniFile object." }, + AddHeaderComment = { Params = "Comment", Return = "", Notes = "Adds a comment to be stored in the file header." }, + AddKeyComment = + { + { Params = "KeyID, Comment", Return = "", Notes = "Adds a comment to be stored in the file under the specified key" }, + { Params = "KeyName, Comment", Return = "", Notes = "Adds a comment to be stored in the file under the specified key" }, + }, + AddKeyName = { Params = "KeyName", Returns = "number", Notes = "Adds a new key of the specified name. Returns the KeyID of the new key." }, + CaseInsensitive = { Params = "", Return = "", Notes = "Sets key names' and value names' comparisons to case insensitive (default)." }, + CaseSensitive = { Params = "", Return = "", Notes = "Sets key names and value names comparisons to case sensitive." }, + Clear = { Params = "", Return = "", Notes = "Removes all the in-memory data. Note that , like all the other operations, this doesn't affect any file data." }, + DeleteHeaderComment = { Params = "CommentID", Return = "bool" , Notes = "Deletes the specified header comment. Returns true if successful."}, + DeleteHeaderComments = { Params = "", Return = "", Notes = "Deletes all headers comments." }, + DeleteKey = { Params = "KeyName", Return = "bool", Notes = "Deletes the specified key, and all values in that key. Returns true if successful." }, + DeleteKeyComment = + { + { Params = "KeyID, CommentID", Return = "bool", Notes = "Deletes the specified key comment. Returns true if successful." }, + { Params = "KeyName, CommentID", Return = "bool", Notes = "Deletes the specified key comment. Returns true if successful." }, + }, + DeleteKeyComments = + { + { Params = "KeyID", Return = "bool", Notes = "Deletes all comments for the specified key. Returns true if successful." }, + { Params = "KeyName", Return = "bool", Notes = "Deletes all comments for the specified key. Returns true if successful." }, + }, + DeleteValue = { Params = "KeyName, ValueName", Return = "bool", Notes = "Deletes the specified value. Returns true if successful." }, + DeleteValueByID = { Params = "KeyID, ValueID", Return = "bool", Notes = "Deletes the specified value. Returns true if successful." }, + FindKey = { Params = "KeyName", Return = "number", Notes = "Returns the KeyID for the specified key name, or the noID constant if the key doesn't exist." }, + FindValue = { Params = "KeyID, ValueName", Return = "numebr", Notes = "Returns the ValueID for the specified value name, or the noID constant if the specified key doesn't contain a value of that name." }, + GetHeaderComment = { Params = "CommentID", Return = "string", Notes = "Returns the specified header comment, or an empty string if such comment doesn't exist" }, + GetKeyComment = + { + { Params = "KeyID, CommentID", Return = "string", Notes = "Returns the specified key comment, or an empty string if such a comment doesn't exist" }, + { Params = "KeyName, CommentID", Return = "string", Notes = "Returns the specified key comment, or an empty string if such a comment doesn't exist" }, + }, + GetKeyName = { Params = "KeyID", Return = "string", Notes = "Returns the key name for the specified key ID. Inverse for FindKey()." }, + GetNumHeaderComments = { Params = "", Return = "number", Notes = "Retuns the number of header comments." }, + GetNumKeyComments = + { + { Params = "KeyID", Return = "number", Notes = "Returns the number of comments under the specified key" }, + { Params = "KeyName", Return = "number", Notes = "Returns the number of comments under the specified key" }, + }, + GetNumKeys = { Params = "", Return = "number", Notes = "Returns the total number of keys. This is the range for the KeyID (0 .. GetNumKeys() - 1)" }, + GetNumValues = + { + { Params = "KeyID", Return = "number", Notes = "Returns the number of values stored under the specified key." }, + { Params = "KeyName", Return = "number", Notes = "Returns the number of values stored under the specified key." }, + }, + GetValue = + { + { Params = "KeyName, ValueName", Return = "string", Notes = "Returns the value of the specified name under the specified key. Returns an empty string if the value doesn't exist." }, + { Params = "KeyID, ValueID", Return = "string", Notes = "Returns the value of the specified name under the specified key. Returns an empty string if the value doesn't exist." }, + }, + GetValueB = { Params = "KeyName, ValueName", Return = "bool", Notes = "Returns the value of the specified name under the specified key, as a bool. Returns false if the value doesn't exist." }, + GetValueF = { Params = "KeyName, ValueName", Return = "number", Notes = "Returns the value of the specified name under the specified key, as a floating-point number. Returns zero if the value doesn't exist." }, + GetValueI = { Params = "KeyName, ValueName", Return = "number", Notes = "Returns the value of the specified name under the specified key, as an integer. Returns zero if the value doesn't exist." }, + GetValueName = + { + { Params = "KeyID, ValueID", Return = "string", Notes = "Returns the name of the specified value Inverse for FindValue()." }, + { Params = "KeyName, ValueID", Return = "string", Notes = "Returns the name of the specified value Inverse for FindValue()." }, + }, + GetValueSet = { Params = "KeyName, ValueName, Default", Return = "string", Notes = "Returns the value of the specified name under the specified key. If the value doesn't exist, creates it with the specified default." }, + GetValueSetB = { Params = "KeyName, ValueName, Default", Return = "bool", Notes = "Returns the value of the specified name under the specified key, as a bool. If the value doesn't exist, creates it with the specified default." }, + GetValueSetF = { Params = "KeyName, ValueName, Default", Return = "number", Notes = "Returns the value of the specified name under the specified key, as a floating-point number. If the value doesn't exist, creates it with the specified default." }, + GetValueSetI = { Params = "KeyName, ValueName, Default", Return = "number", Notes = "Returns the value of the specified name under the specified key, as an integer. If the value doesn't exist, creates it with the specified default." }, + ReadFile = { Params = "FileName, [AllowExampleFallback]", Return = "bool", Notes = "Reads the values from the specified file. Previous in-memory contents are lost. If the file cannot be opened, and AllowExample is true, another file, \"filename.example.ini\", is loaded and then saved as \"filename.ini\". Returns true if successful, false if not." }, + SetValue = + { + { Params = "KeyID, ValueID, NewValue", Return = "bool", Notes = "Overwrites the specified value with a new value. If the specified value doesn't exist, returns false (doesn't add)." }, + { Params = "KeyName, ValueName, NewValue, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + }, + SetValueB = { Params = "KeyName, ValueName, NewValueBool, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new bool value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + SetValueF = { Params = "KeyName, ValueName, NewValueFloat, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new floating-point number value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + SetValueI = { Params = "KeyName, ValueName, NewValueInt, [CreateIfNotExists]", Return = "bool", Notes = "Overwrites the specified value with a new integer value. If CreateIfNotExists is true (default) and the value doesn't exist, it is first created. Returns true if the value was successfully set, false if not (didn't exists, CreateIfNotExists false)." }, + WriteFile = { Params = "FileName", Return = "bool", Notes = "Writes the current in-memory data into the specified file. Returns true if successful, false if not." }, }, Constants = { + noID = { Notes = "" }, }, AdditionalInfo = { { - Header = "Practical usage", + Header = "Code example: Reading a simple value", Contents = [[ - If you want to use cIniFile you need to know a couple of things; what is the key name and what - is the value name. Below is a demonstration of what is what.

    -
    -; Comment line
    -[KeyName1]
    -ValueName1=Value1
    -ValueName2=Value2
    -
    -[KeyName2]
    -ValueName1=Value3
    -

    -

    cIniFile is very easy to use. For example, you can find out what port the server is supposed to use according to settings.ini by using this little snippet:

    -local IniFile = cIniFile("settings.ini");
    -if (IniFile:ReadFile()) then
    +local IniFile = cIniFile();
    +if (IniFile:ReadFile("settings.ini")) then
     	ServerPort = IniFile:GetValueI("Server", "Port");
     end
     
    ]], }, - }, - }, + { + Header = "Code example: Enumerating all objects in a file", + Contents = [[ + To enumerate all keys in a file, you need to query the total number of keys, using GetNumKeys(), + and then query each key's name using GetKeyName(). Similarly, to enumerate all values under a + key, you need to query the total number of values using GetNumValues() and then query each + value's name using GetValueName().

    +

    + The following code logs all keynames and their valuenames into the server log: +

    +local IniFile = cIniFile();
    +IniFile:ReadFile("somefile.ini")
    +local NumKeys = IniFile:GetNumKeys();
    +for k = 0, NumKeys do
    +	local NumValues = IniFile:GetNumValues(k);
    +	LOG("key \"" .. IniFile:GetKeyName(k) .. "\" has " .. NumValues .. " values:");
    +	for v = 0, NumValues do
    +		LOG("  value \"" .. IniFile:GetValueName(k, v) .. "\".");
    +	end
    +end
    +
    + ]], + }, + }, -- AdditionalInfo + }, -- cIniFile cInventory = { @@ -1167,7 +1221,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, invHotbarOffset = { Notes = "Starting slot number of the Hotbar part" }, invNumSlots = { Notes = "Total number of slots in a cInventory" }, }, - }, + }, -- cInventory cItem = { @@ -1254,7 +1308,7 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); ]], }, }, - }, + }, -- cItem cItemGrid = { @@ -1364,7 +1418,7 @@ end ]], }, }, -- AdditionalInfo - }, + }, -- cItemGrid cItems = { @@ -1394,7 +1448,7 @@ end Constants = { }, - }, + }, -- cItems cLineBlockTracer = { -- cgit v1.2.3 From 73e7d213878ca4ae8b89d1d999b6d80f487c6a27 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 26 Oct 2013 19:54:51 +0200 Subject: APIDump: Documented cPickup. --- MCServer/Plugins/APIDump/APIDesc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b60a6f746..dfada998f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1716,9 +1716,10 @@ a_Player:OpenWindow(Window); GetAge = { Params = "", Return = "number", Notes = "Returns the number of ticks that the pickup has existed." }, GetItem = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item represented by this pickup" }, IsCollected = { Params = "", Return = "bool", Notes = "Returns true if this pickup has already been collected (is waiting to be destroyed)" }, + IsPlayerCreated = { Params = "", Return = "bool", Notes = "Returns true if the pickup was created by a player" }, }, Inherits = "cEntity", - }, + }, -- cPickup cPlayer = { -- cgit v1.2.3 From 5d58457c9e950093ce14ce10eb74626ecec57025 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Oct 2013 09:29:02 +0100 Subject: APIDump: Documented cProjectileEntity. --- MCServer/Plugins/APIDump/APIDesc.lua | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index dfada998f..b7a5b7e47 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1040,7 +1040,7 @@ ValueName0=SomeOtherValue insert values by hand. Then you can store the object's contents to a disk file using WriteFile(), or just forget everything by destroying the object. Note that the file operations are quite slow.

    - For storing high-volume low-latency data, use the {{sqlite}} class. For storing + For storing high-volume low-latency data, use the {{sqlite3}} class. For storing hierarchically-structured data, use the XML format, using the LuaExpat parser in the {{lxp}} class. ]], Functions = @@ -1943,8 +1943,26 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cProjectileEntity = { Desc = "", - Functions = {}, - Constants = {}, + Functions = + { + GetCreator = { Params = "", Return = "{{cEntity}} descendant", Notes = "Returns the entity who created this projectile. May return nil." }, + GetMCAClassName = { Params = "", Return = "string", Notes = "Returns the string that identifies the projectile type (class name) in MCA files" }, + GetProjectileKind = { Params = "", Return = "ProjectileKind", Notes = "Returns the kind of this projectile (pkXXX constant)" }, + IsInGround = { Params = "", Return = "bool", Notes = "Returns true if this projectile has hit the ground." }, + }, + Constants = + { + pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" }, + pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" }, + pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" }, + pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" }, + pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" }, + pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" }, + pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" }, + pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" }, + pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" }, + pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" }, + }, Inherits = "cEntity", }, -- cgit v1.2.3 From 4871968bc9114de9db5ae52cd123641d8e909832 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Oct 2013 09:39:11 +0100 Subject: APIDump: Documented cRoot. --- MCServer/Plugins/APIDump/APIDesc.lua | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b7a5b7e47..14b4a3184 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1968,11 +1968,18 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cRoot = { - Desc = [[There is always only one cRoot object in MCServer. cRoot manages all the important objects such as {{cServer|cServer}} -]], + Desc = [[ + This class represents the root of MCServer's object hierarchy. There is always only one cRoot + object. It manages and allows querying all the other objects, such as {{cServer}}, + {{cPluginManager}}, individual {{cWorld|worlds}} etc.

    +

    + To get the singleton instance of this object, you call the cRoot:Get() function. Then you can call + the individual functions on this object. Note that some of the functions are static and don't need + the instance, they are to be called directly on the cRoot class, such as cRoot:GetPhysicalRAMUsage() + ]], Functions = { - Get = { Params = "", Return = "Root object", Notes = "This function returns the cRoot object." }, + Get = { Params = "", Return = "Root object", Notes = "(STATIC)This function returns the cRoot object." }, BroadcastChat = { Params = "Message", Return = "", Notes = "Broadcasts a message to every player in the server." }, FindAndDoWithPlayer = { Params = "PlayerName, CallbackFunction", Return = "", Notes = "Calls the given callback function for the given player." }, ForEachPlayer = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each player. The callback function has the following signature:

    function Callback({{cPlayer|cPlayer}})
    " }, @@ -1981,11 +1988,13 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." }, GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object." }, GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object." }, + GetPhysicalRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of physical RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetPluginManager = { Params = "", Return = "{{cPluginManager|cPluginManager}}", Notes = "Returns the cPluginManager object." }, GetPrimaryServerVersion = { Params = "", Return = "number", Notes = "Returns the servers primary server version." }, GetProtocolVersionTextFromInt = { Params = "Protocol Version", Return = "string", Notes = "Returns the Minecraft version from the given Protocol. If there is no version found, it returns 'Unknown protocol(Parameter)'" }, GetServer = { Params = "", Return = "{{cServer|cServer}}", Notes = "Returns the cServer object." }, GetTotalChunkCount = { Params = "", Return = "number", Notes = "Returns the amount of loaded chunks." }, + GetVirtualRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of virtual RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." }, GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." }, QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' }, -- cgit v1.2.3 From 4f32079692e42e7d29520e4d22902ac15e7e16ea Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 27 Oct 2013 09:45:02 +0100 Subject: APIDump: Documented cWorld. --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 14b4a3184..8e9122ba2 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2257,6 +2257,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa QueueBlockForTick = { Params = "BlockX, BlockY, BlockZ, TicksToWait", Return = "", Notes = "Queues the specified block to be ticked after the specified number of gameticks." }, QueueSaveAllChunks = { Params = "", Return = "", Notes = "Queues all chunks to be saved in the world storage thread" }, QueueSetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta, TickDelay", Return = "", Notes = "Queues the block to be set to the specified blocktype and meta after the specified amount of game ticks. Uses SetBlock() for the actual setting, so simulators are woken up and block entities are handled correctly." }, + QueueTask = { Params = "TaskFunction", Return = "", Notes = "Queues the specified function to be executed in the tick thread. This is the primary means of interaction with a cWorld from the WebAdmin page handlers (see {{WebWorldThreads}}). The function signature is
    function()
    All return values from the function are ignored. Note that this function is actually called *after* the QueueTask() function returns." }, RegenerateChunk = { Params = "ChunkX, ChunkZ", Return = "", Notes = "Queues the specified chunk to be re-generated, overwriting the current data. To queue a chunk for generating only if it doesn't exist, use the GenerateChunk() instead." }, SendBlockTo = { Params = "BlockX, BlockY, BlockZ, {{cPlayer|Player}}", Return = "", Notes = "Sends the block at the specified coords to the specified player's client, as an UpdateBlock packet." }, SetBlock = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, replaces the block entities for the previous block type, creates a new block entity for the new block, if appropriate, and wakes up the simulators. This is the preferred way to set blocks, as opposed to FastSetBlock(), which is only to be used under special circumstances." }, -- cgit v1.2.3 From aca526d158b1b15f8e00a110313896878595f62f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:07:30 +0100 Subject: APIDump: Fixed a failure in documented classes with no functions. --- MCServer/Plugins/APIDump/main.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index 2db8b4b1b..a9cdf143b 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -499,6 +499,7 @@ function ReadDescriptions(a_API) cls.Functions = DoxyFunctions; else -- if (APIDesc.Functions ~= nil) for j, func in ipairs(cls.Functions) do + local FnName = func.DocID or func.Name; if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end -- cgit v1.2.3 From 1a29c19619a70cd78ce7a2e18881ebdde83650ac Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:08:14 +0100 Subject: APIDump: Documented HTTPFormData and HTTPRequest. --- MCServer/Plugins/APIDump/APIDesc.lua | 44 ++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8e9122ba2..e3b804c32 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2348,7 +2348,40 @@ World:ForEachEntity( ]], }, }, -- AdditionalInfo - }, + }, -- cWorld + + HTTPFormData = + { + Desc = "This class stores data for one form element for a {{HTTPRequest|HTTP request}}.", + Variables = + { + Name = { Type = "string", Notes = "Name of the form element" }, + Type = { Type = "string", Notes = "Type of the data (usually empty)" }, + Value = { Type = "string", Notes = "Value of the form element. Contains the raw data as sent by the browser." }, + }, + }, -- HTTPFormData + + HTTPRequest = + { + Desc = [[ + This class encapsulates all the data that is sent to the WebAdmin through one HTTP request. Plugins + receive this class as a parameter to the function handling the web requests, as registered in the + FIXME: {{cPluginLua}}:AddWebPage(). + ]], + Constants = + { + FormData = { Notes = "Array-table of {{HTTPFormData}}, contains the values of individual form elements submitted by the client" }, + Params = { Notes = "Map-table of parameters given to the request in the URL (?param=value); if a form uses GET method, this is the same as FormData. For each parameter given as \"param=value\", there is an entry in the table with \"param\" as its key and \"value\" as its value." }, + PostParams = { Notes = "Map-table of data posted through a FORM - either a GET or POST method. Logically the same as FormData, but in a map-table format (for each parameter given as \"param=value\", there is an entry in the table with \"param\" as its key and \"value\" as its value)." }, + }, + + Variables = + { + Method = { Type = "string", Notes = "The HTTP method used to make the request. Usually GET or POST." }, + Path = { Type = "string", Notes = "The Path part of the URL (excluding the parameters)" }, + Username = { Type = "string", Notes = "Name of the logged-in user." }, + }, + }, -- HTTPRequest TakeDamageInfo = { @@ -2360,7 +2393,7 @@ World:ForEachEntity( Constants = { }, - }, + }, -- TakeDamageInfo Vector3d = { @@ -2373,7 +2406,7 @@ World:ForEachEntity( Constants = { }, - }, + }, -- Vector3d Vector3f = { @@ -2385,7 +2418,7 @@ World:ForEachEntity( Constants = { }, - }, + }, -- Vector3f Vector3i = { @@ -2397,7 +2430,8 @@ World:ForEachEntity( Constants = { }, - }, + }, -- Vector3i + Globals = { Desc = [[These functions are available directly, without a class instance. Any plugin cal call them at any time.]], -- cgit v1.2.3 From 2bb1dd50152667eec230f49d75fd5b903a99f1a5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:32:10 +0100 Subject: APIDump: Documented cWindow. --- MCServer/Plugins/APIDump/APIDesc.lua | 54 ++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 21 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index e3b804c32..8b007101a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2108,36 +2108,48 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa cWindow = { - Desc = [[This class is the common ancestor for all window classes used by MCServer. It is inherited by the {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be used for window-related hooks in the future. It implements the basic functionality of any window. -

    -

    Note that one cWindow object can be used for multiple players at the same time, and therefore the slot contents are player-specific (e. g. crafting grid, or player inventory). Thus the GetSlot() and SetSlot() functions need to have the {{cPlayer|cPlayer}} parameter that specifies the player for which the contents are to be queried. -]], + Desc = [[ + This class is the common ancestor for all window classes used by MCServer. It is inherited by the + {{cLuaWindow|cLuaWindow}} class that plugins use for opening custom windows. It is planned to be + used for window-related hooks in the future. It implements the basic functionality of any + window.

    +

    + Note that one cWindow object can be used for multiple players at the same time, and therefore the + slot contents are player-specific (e. g. crafting grid, or player inventory). Thus the GetSlot() and + SetSlot() functions need to have the {{cPlayer|cPlayer}} parameter that specifies the player for + whom the contents are to be queried.

    +

    + Windows also have numeric properties, these are used to set the progressbars for furnaces or the XP + costs for enchantment tables. + ]], Functions = { + GetSlot = { Params = "{{cPlayer|Player}}, SlotNumber", Return = "{{cItem}}", Notes = "Returns the item at the specified slot for the specified player. Returns nil and logs to server console on error." }, GetWindowID = { Params = "", Return = "number", Notes = "Returns the ID of the window, as used by the network protocol" }, GetWindowTitle = { Params = "", Return = "string", Notes = "Returns the window title that will be displayed to the player" }, GetWindowType = { Params = "", Return = "number", Notes = "Returns the type of the window, one of the constants in the table above" }, - IsSlotInPlayerHotbar = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player hotbar" }, - IsSlotInPlayerInventory = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory or in the hotbar. Note that this returns false for armor slots!" }, - IsSlotInPlayerMainInventory = { Params = "number", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory" }, - SetSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the contents of the specified slot for the specified player. Ignored if the slot number is invalid" }, + IsSlotInPlayerHotbar = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot number is in the player hotbar" }, + IsSlotInPlayerInventory = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory or in the hotbar. Note that this returns false for armor slots!" }, + IsSlotInPlayerMainInventory = { Params = "SlotNum", Return = "bool", Notes = "Returns true if the specified slot number is in the player's main inventory" }, + SetProperty = { Params = "PropertyID, PropartyValue, {{cPlayer|Player}}", Return = "", Notes = "Sends the UpdateWindowProperty (0x69) packet to the specified player; or to all players who are viewing this window if Player is not specified or nil." }, + SetSlot = { Params = "{{cPlayer|Player}}, SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the contents of the specified slot for the specified player. Ignored if the slot number is invalid" }, SetWindowTitle = { Params = "string", Return = "", Notes = "Sets the window title that will be displayed to the player" }, }, Constants = { - Inventory = { Notes = "" }, - Chest = { Notes = "0" }, - Workbench = { Notes = "1" }, - Furnace = { Notes = "2" }, - DropSpenser = { Notes = "3" }, - Enchantment = { Notes = "4" }, - Brewery = { Notes = "5" }, - NPCTrade = { Notes = "6" }, - Beacon = { Notes = "7" }, - Anvil = { Notes = "8" }, - Hopper = { Notes = "9" }, - }, - }, + wtInventory = { Notes = "An inventory window" }, + wtChest = { Notes = "A {{cChestEntity|chest}} or doublechest window" }, + wtWorkbench = { Notes = "A workbench (crafting table) window" }, + wtFurnace = { Notes = "A {{cFurnaceEntity|furnace}} window" }, + wtDropSpenser = { Notes = "A {{cDropperEntity|dropper}} or a {{cDispenserEntity|dispenser}} window" }, + wtEnchantment = { Notes = "An enchantment table window" }, + wtBrewery = { Notes = "A brewing stand window" }, + wtNPCTrade = { Notes = "A villager trade window" }, + wtBeacon = { Notes = "A beacon window" }, + wtAnvil = { Notes = "An anvil window" }, + wtHopper = { Notes = "A {{cHopperEntity|hopper}} window" }, + }, + }, -- cWindow cWorld = { -- cgit v1.2.3 From d41d5c15b1828e71990c0e31d7c11c0ac768ed59 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 28 Oct 2013 13:44:57 +0100 Subject: Debuggers: Fixed after the cWindow API change. --- MCServer/Plugins/Debuggers/Debuggers.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index b895da05e..04a15a002 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -606,7 +606,7 @@ end function HandleTestWndCmd(a_Split, a_Player) - local WindowType = cWindow.Hopper; + local WindowType = cWindow.wtHopper; local WindowSizeX = 5; local WindowSizeY = 1; if (#a_Split == 4) then @@ -789,7 +789,7 @@ end function HandleEnchCmd(a_Split, a_Player) - local Wnd = cLuaWindow(cWindow.Enchantment, 1, 1, "Ench"); + local Wnd = cLuaWindow(cWindow.wtEnchantment, 1, 1, "Ench"); a_Player:OpenWindow(Wnd); Wnd:SetProperty(0, 10); Wnd:SetProperty(1, 15); -- cgit v1.2.3 From d1e51886e533521707c76fa1d31200685553ce97 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 31 Oct 2013 23:47:46 +0100 Subject: APIDump: Fixed HOOK_LOGIN short desc. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8b007101a..f8e201244 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -3017,7 +3017,7 @@ end; HOOK_LOGIN = { - CalledWhen = "Right after player authentication. If auth is disabled, right after the player sends their name.", + CalledWhen = "Right before player authentication. If auth is disabled, right after the player sends their name.", DefaultFnName = "OnLogin", -- also used as pagename Desc = [[ This hook is called whenever a client logs in. It is called right before the client's name is sent -- cgit v1.2.3 From 13800a0023da222b1cd95402f0944035301e0fa1 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 5 Nov 2013 22:16:42 +0100 Subject: APIDump: Documented ItemCategory. --- MCServer/Plugins/APIDump/APIDesc.lua | 38 ++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f8e201244..ebe284ad6 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2395,6 +2395,44 @@ World:ForEachEntity( }, }, -- HTTPRequest + ItemCategory = + { + Desc = [[ + This class contains static functions for determining item categories. All of the functions are + called directly on the class table, unlike most other object, which require an instance first. + ]], + Functions = + { + IsArmor = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of an armor." }, + IsAxe = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of an axe." }, + IsBoots = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of boots." }, + IsChestPlate = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a chestplate." }, + IsHelmet = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a helmet." }, + IsHoe = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a hoe." }, + IsLeggings = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a leggings." }, + IsPickaxe = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a pickaxe." }, + IsShovel = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a shovel." }, + IsSword = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a sword." }, + IsTool = { Params = "ItemType", Return = "bool", Notes = "(STATIC) Returns true if the specified item type is any kind of a tool (axe, hoe, pickaxe, shovel or FIXME: sword)" }, + }, + AdditionalInfo = + { + { + Header = "Code example", + Contents = [[ + The following code snippet checks if the player holds a shovel. +

    +-- a_Player is a {{cPlayer}} object, possibly received as a hook param
    +local HeldItem = a_Player:GetEquippedItem();
    +if (cItemCategory:IsShovel(HeldItem.m_ItemType)) then
    +	-- It's a shovel
    +end
    +
    + ]], + } + }, + }, -- ItemCategory + TakeDamageInfo = { Desc = [[The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the {{OnTakeDamage|OnTakeDamage}}() hook and in the {{cEntity|cEntity}}'s TakeDamage() function. -- cgit v1.2.3 From 9e38c00b5e0364ea924af1fd04d3e90c77259674 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 9 Nov 2013 14:22:59 +0100 Subject: Updated Core and ProtectionAreas. --- MCServer/Plugins/Core | 2 +- MCServer/Plugins/ProtectionAreas | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index e3a45f343..de53a607f 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit e3a45f34303331be77aceacf2ba53e503ad7284f +Subproject commit de53a607f30c583e08c06b6e5eb936cd278ab8cd diff --git a/MCServer/Plugins/ProtectionAreas b/MCServer/Plugins/ProtectionAreas index 3019c7b39..70d95481e 160000 --- a/MCServer/Plugins/ProtectionAreas +++ b/MCServer/Plugins/ProtectionAreas @@ -1 +1 @@ -Subproject commit 3019c7b396221b987cd3f89d422276f764834ffe +Subproject commit 70d95481e323874b147e3296a2bd0c35563b0bea -- cgit v1.2.3 From 157bd150fd648dccf26466a7c4b8b90c5bb6bdb2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 9 Nov 2013 18:55:24 +0100 Subject: APIDump: Added logging to see what takes so long. --- MCServer/Plugins/APIDump/main.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index a9cdf143b..d84926b53 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -198,11 +198,13 @@ end function DumpAPIHtml() LOG("Dumping all available functions and constants to API subfolder..."); + LOG("Creating API tables..."); local API, Globals = CreateAPITables(); local Hooks = {}; local UndocumentedHooks = {}; -- Sort the classes by name: + LOG("Sorting..."); table.sort(API, function (c1, c2) return (string.lower(c1.Name) < string.lower(c2.Name)); @@ -233,6 +235,7 @@ function DumpAPIHtml() ); -- Read in the descriptions: + LOG("Reading descriptions..."); ReadDescriptions(API); ReadHooks(Hooks); @@ -243,6 +246,7 @@ function DumpAPIHtml() -- Create a "class index" file, write each class as a link to that file, -- then dump class contents into class-specific file + LOG("Writing HTML files..."); local f = io.open("API/index.html", "w"); if (f == nil) then LOGINFO("Cannot output HTML API: " .. err); @@ -335,6 +339,7 @@ function DumpAPIHtml() cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); -- List the documentation problems: + LOG("Listing leftovers..."); ListUndocumentedObjects(API, UndocumentedHooks); ListUnexportedObjects(); ListMissingPages(); -- cgit v1.2.3 From d74b0dbd5baa2666de933464e93bcc9a18c36876 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 9 Nov 2013 19:16:44 +0100 Subject: APIDump: Documented the relevant tolua functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 50 ++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index ebe284ad6..3b0beaa2d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -820,7 +820,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), GetRawDamageAgainst = { Params = "ReceiverEntity", Return = "number", Notes = "Returns the raw damage that this entity's equipment would cause when attacking the ReceiverEntity. This includes this entity's weapon {{cEnchantments|enchantments}}, but excludes the receiver's armor or potion effects. See {{TakeDamageInfo}} for more information on attack damage." }, GetRoll = { Params = "", Return = "number", Notes = "Returns the roll (sideways rotation) of the entity. Currently unused." }, GetRot = { Params = "", Return = "{{Vector3f}}", Notes = "Returns the entire rotation vector (Yaw, Pitch, Roll)" }, - GetRotation = { Params = "", Return = "number", Notes = "Returns the yaw (direction) of the entity. FIXME: Rename to GetYaw()." }, + GetRotation = { Params = "", Return = "number", Notes = "Returns the yaw (direction) of the entity. OBSOLETE, use GetYaw() instead." }, GetSpeed = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the complete speed vector of the entity" }, GetSpeedX = { Params = "", Return = "number", Notes = "Returns the X-part of the speed vector" }, GetSpeedY = { Params = "", Return = "number", Notes = "Returns the Y-part of the speed vector" }, @@ -828,6 +828,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), GetUniqueID = { Params = "", Return = "number", Notes = "Returns the ID that uniquely identifies the entity within the running server. Note that this ID is not persisted to the data files." }, GetWidth = { Params = "", Return = "number", Notes = "Returns the width (X and Z size) of the entity." }, GetWorld = { Params = "", Return = "{{cWorld}}", Notes = "Returns the world where the entity resides" }, + GetYaw = { Params = "", Return = "number", Notes = "Returns the yaw (direction) of the entity." }, Heal = { Params = "Hitpoints", Return = "", Notes = "Heals the specified number of hitpoints. Hitpoints is expected to be a positive number." }, IsA = { Params = "ClassName", Return = "bool", Notes = "Returns true if the entity class is a descendant of the specified class name, or the specified class itself" }, IsBoat = { Params = "", Return = "bool", Notes = "Returns true if the entity is a {{cBoat|boat}}." }, @@ -864,7 +865,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), SetPosZ = { Params = "number", Return = "", Notes = "Sets the Z-coord of the entity's pivot" }, SetRoll = { Params = "number", Return = "", Notes = "Sets the roll (sideways rotation) of the entity. Currently unused." }, SetRot = { Params = "{{Vector3f|Rotation}}", Return = "", Notes = "Sets the entire rotation vector (Yaw, Pitch, Roll)" }, - SetRotation = { Params = "number", Return = "", Notes = "Sets the yaw (direction) of the entity. FIXME: Rename to SetYaw()." }, + SetRotation = { Params = "number", Return = "", Notes = "Sets the yaw (direction) of the entity. OBSOLETE, use SetYaw() instead." }, SetRotationFromSpeed = { Params = "", Return = "", Notes = "Sets the entity's yaw to match its current speed (entity looking forwards as it moves). (FIXME: Rename to SetYawFromSpeed)" }, SetSpeed = { @@ -875,6 +876,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), SetSpeedY = { Params = "SpeedY", Return = "", Notes = "Sets the Y component of the entity speed" }, SetSpeedZ = { Params = "SpeedZ", Return = "", Notes = "Sets the Z component of the entity speed" }, SetWidth = { Params = "", Return = "", Notes = "FIXME: Remove this from API" }, + SetYaw = { Params = "number", Return = "", Notes = "Sets the yaw (direction) of the entity." }, StartBurning = { Params = "NumTicks", Return = "", Notes = "Sets the entity on fire for the specified number of ticks. If entity is on fire already, makes it burn for either NumTicks or the number of ticks left from the previous fire, whichever is larger." }, SteerVehicle = { Params = "ForwardAmount, SidewaysAmount", Return = "", Notes = "Applies the specified steering to the vehicle this entity is attached to. Ignored if not attached to any entity." }, StopBurning = { Params = "", Return = "", Notes = "Extinguishes the entity fire, cancels all fire timers." }, @@ -1740,6 +1742,7 @@ a_Player:OpenWindow(Window); GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left)." }, GetClientHandle = { Params = "", Return = "{{cClientHandle}}", Notes = "Returns the client handle representing the player's connection. May be nil (AI players)." }, GetColor = { Return = "string", Notes = "Returns the full color code to be used for this player (based on the first group). Prefix player messages with this code." }, + GetEffectiveGameMode = { Params = "", Return = "{{eGameMode|GameMode}}", Notes = "Returns the current resolved game mode of the player. If the player is set to inherit the world's gamemode, returns that instead. See also GetGameMode() and IsGameModeXXX() functions." }, GetEquippedItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that the player is currently holding; empty item if holding nothing." }, GetEyeHeight = { Return = "number", Notes = "Returns the height of the player's eyes, in absolute coords" }, GetEyePosition = { Return = "{{Vector3d|EyePositionVector}}", Notes = "Returns the position of the player's eyes, as a {{Vector3d}}" }, @@ -2445,6 +2448,49 @@ end }, }, -- TakeDamageInfo + tolua = + { + Desc = [[ + This class represents the tolua bridge between the Lua API and MCServer. It supports some low + level operations and queries on the objects. See also the tolua++'s documentation at + {{http://www.codenix.com/~tolua/tolua++.html#utilities}}. Normally you shouldn't use any of these + functions except for cast() and type() + ]], + Functions = + { + cast = { Params = "Object, TypeStr", Return = "Object", Notes = "Casts the object to the specified type through the inheritance hierarchy." }, + getpeer = { Params = "", Return = "", Notes = "" }, + inherit = { Params = "", Return = "", Notes = "" }, + releaseownership = { Params = "", Return = "", Notes = "" }, + setpeer = { Params = "", Return = "", Notes = "" }, + takeownership = { Params = "", Return = "", Notes = "" }, + type = { Params = "Object", Return = "TypeStr", Notes = "Returns a string representing the type of the object. This works similar to Lua's built-in type() function, but recognizes the underlying C++ types, too." }, + }, + AdditionalInfo = + { + { + Header = "Usage example", + Contents = + [[ + The tolua.cast() function is normally used to cast between related types. For example in the + hook callbacks you often receive a generic {{cEntity}} object, when in fact you know that the + object is a {{cMonster}}. You can cast the object to access its cMonster functions: +
    +function OnTakeDamage(a_ReceiverEntity, TDI)
    +	if (a_ReceiverEntity.IsMob()) then
    +		local Mob = tolua.cast(a_ReceiverEntity, "cMonster");  -- Cast a_ReceiverEntity into a {{cMonster}} instance
    +		if (Mob:GetMonsterType() == cMonster.mtSheep) then
    +			local Sheep = tolua.cast(Mob, "cSheep");  -- Cast Mob into a {{cSheep}} instance
    +			-- Do something sheep-specific
    +		end
    +	end
    +end
    +
    + ]], + } + } -- AdditionalInfo + }, -- tolua + Vector3d = { Desc = [[A Vector3d object uses double precision floating point values to describe a point in space. Vector3d is part of the {{vector3|vector3}} family. -- cgit v1.2.3 From 148f723632e9fb1ee419ac8dd2b2b76543435828 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 9 Nov 2013 19:25:03 +0100 Subject: APIDump: Documented TakeDamageInfo. --- MCServer/Plugins/APIDump/APIDesc.lua | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 3b0beaa2d..9f303ff0e 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2438,14 +2438,38 @@ end TakeDamageInfo = { - Desc = [[The TakeDamageInfo is a struct that contains the amount of damage, and the entity that caused the damage. It is used in the {{OnTakeDamage|OnTakeDamage}}() hook and in the {{cEntity|cEntity}}'s TakeDamage() function. -]], - Functions = + Desc = [[ + This class contains the amount of damage, and the entity that caused the damage. It is used in the + {{OnTakeDamage|HOOK_TAKE_DAMAGE}} hook and in the {{cEntity}}'s TakeDamage() function. + ]], + Variables = { + Attacker = { Type = "{{cEntity}}", Notes = "The entity who is attacking. Only valid if dtAttack." }, + DamageType = { Type = "eDamageType", Notes = "Source of the damage. One of the dtXXX constants." }, + FinalDamage = { Type = "number", Notes = " The final amount of damage that will be applied to the Receiver. It is the RawDamage minus any Receiver's armor-protection " }, + Knockback = { Type = "{{Vector3d}}", Notes = "Vector specifying the amount and direction of knockback that will be applied to the Receiver " }, + RawDamage = { Type = "number", Notes = "Amount of damage that the attack produces on the Receiver, including the Attacker's equipped weapon, but excluding the Receiver's armor." }, }, - Constants = + AdditionalInfo = { - }, + { + Header = "", + Contents = [[ + The TDI is passed as the second parameter in the HOOK_TAKE_DAMAGE hook, and can be used to + modify the damage before it is applied to the receiver: +
    +function Plugin:OnTakeDamage(Receiver, TDI)
    +	LOG("Damage: Raw ".. TDI.RawDamage .. ", Final:" .. TDI.FinalDamage);
    +
    +	-- If the attacker is a spider, make it deal 999 points of damage (insta-death spiders):
    +	if ((TDI.Attacker ~= nil) and TDI.Attacker:IsA("cSpider")) then
    +		TDI.FinalDamage = 999;
    +	end
    +end
    +
    + ]], + }, + }, -- AdditionalInfo }, -- TakeDamageInfo tolua = -- cgit v1.2.3 From 0762893ee1ccb46cee7e8b71ce143bd601823b98 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 9 Nov 2013 21:18:03 +0100 Subject: APIDump: Documented cServer:IsHardCore() --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 9f303ff0e..b238a3b6c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2020,6 +2020,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); SetMaxPlayers = { Params = "number", Notes = "Sets the max amount of players who can join." }, GetNumPlayers = { Return = "number", Notes = "Returns the amount of players online." }, GetServerID = { Return = "string", Notes = "Returns the ID of the server?" }, + IsHardcore = { Params = "", Return = "bool", Notes = "Returns true if the server is hardcore (players get banned on death)." }, }, Constants = { -- cgit v1.2.3 From 9287349cc2b553598000cf0888e7e1e63301565e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Mon, 11 Nov 2013 16:01:18 +0100 Subject: APIDump: Documented Vector3d. --- MCServer/Plugins/APIDump/APIDesc.lua | 51 ++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index b238a3b6c..321f50732 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2011,8 +2011,13 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cServer = { - Desc = [[cServer is typically only used by plugins to broadcast a chat message(Now replaced by the {{cRoot|cRoot}} BroadcastChat function) to all players in the server. Natively however, cServer accepts connections from clients and adds those clients to the game. -]], + Desc = [[ + This class manages all the client connections internally. In the API layer, it allows to get and set + the general properties of the server, such as the description and max players.

    +

    + It used to support broadcasting chat messages to all players, this functionality has been moved to + {{cRoot}}:BroadcastChat(). + ]], Functions = { GetDescription = { Return = "string", Notes = "Returns the server description set in the settings.ini." }, @@ -2030,9 +2035,9 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); cSignEntity = { Desc = [[ -A sign entity represents a sign in the world. -Sign entities are saved and loaded from disk when the chunk they reside in is saved or loaded -]], + A sign entity represents a sign in the world. This class is only used when generating chunks, so + that the plugins may generate signs within new chunks. + ]], Functions = { }, @@ -2152,6 +2157,7 @@ Sign entities are saved and loaded from disk when the chunk they reside in is sa wtBeacon = { Notes = "A beacon window" }, wtAnvil = { Notes = "An anvil window" }, wtHopper = { Notes = "A {{cHopperEntity|hopper}} window" }, + wtAnimalChest = { Notes = "A horse or donkey window" }, }, }, -- cWindow @@ -2518,14 +2524,43 @@ end Vector3d = { - Desc = [[A Vector3d object uses double precision floating point values to describe a point in space. Vector3d is part of the {{vector3|vector3}} family. -]], + Desc = [[ + A Vector3d object uses double precision floating point values to describe a point in 3D space. + ]], Functions = { - operator_plus = {Params = "{{Vector3d}}", Return = "{{Vector3d}}", Notes = "Returns the sum of this vector with the specified vector" }, + constructor = + { + { Params = "{{Vector3f}}", Return = "Vector3d", Notes = "Creates a new Vector3d object by copying the coords from the given Vector3f." }, + { Params = "", Return = "Vector3d", Notes = "Creates a new Vector3d object with all its coords set to 0." }, + { Params = "X, Y, Z", Return = "Vector3d", Notes = "Creates a new Vector3d object with its coords set to the specified values." }, + }, + operator_div = { Params = "number", Return = "Vector3d", Notes = "Returns a new Vector3d with each coord divided by the specified number." }, + operator_mul = { Params = "number", Return = "Vector3d", Notes = "Returns a new Vector3d with each coord multiplied." }, + operator_sub = { Params = "Vector3d", Return = "Vector3d", Notes = "Returns a new Vector3d containing the difference between this object and the specified vector." }, + operator_plus = {Params = "Vector3d", Return = "Vector3d", Notes = "Returns a new Vector3d containing the sum of this vector and the specified vector" }, + Cross = { Params = "Vector3d", Return = "Vector3d", Notes = "Returns a new Vector3d that is a {{http://en.wikipedia.org/wiki/Cross_product|cross product}} of this vector and the specified vector." }, + Dot = { Params = "Vector3d", Return = "number", Notes = "Returns the dot product of this vector and the specified vector." }, + Equals = { Params = "Vector3d", Return = "bool", Notes = "Returns true if this vector is exactly equal to the specified vector." }, + Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of the vector." }, + LineCoeffToXYPlane = { Params = "Vector3d, Z", Return = "number", Notes = "Returns the coefficient for the line from the specified vector through this vector to reach the specified Z coord. The result satisfies the following equation: (this + Result * (Param - this)).z = Z. Returns the NO_INTERSECTION constant if there's no intersection." }, + LineCoeffToXZPlane = { Params = "Vector3d, Y", Return = "number", Notes = "Returns the coefficient for the line from the specified vector through this vector to reach the specified Y coord. The result satisfies the following equation: (this + Result * (Param - this)).y = Y. Returns the NO_INTERSECTION constant if there's no intersection." }, + LineCoeffToYZPlane = { Params = "Vector3d, X", Return = "number", Notes = "Returns the coefficient for the line from the specified vector through this vector to reach the specified X coord. The result satisfies the following equation: (this + Result * (Param - this)).x = X. Returns the NO_INTERSECTION constant if there's no intersection." }, + Normalize = { Params = "", Return = "", Notes = "Changes this vector so that it keeps current direction but is exactly 1 unit long. FIXME: Fails for a zero vector." }, + NormalizeCopy = { Params = "", Return = "Vector3d", Notes = "Returns a new vector that has the same directino as this but is exactly 1 unit long. FIXME: Fails for a zero vector." }, + Set = { Params = "X, Y, Z", Return = "", Notes = "Sets all the coords in this object." }, + SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison. " }, }, Constants = { + EPS = { Notes = "The max difference between two coords for which the coords are assumed equal (in LineCoeffToXYPlane() et al)." }, + NO_INTERSECTION = { Notes = "Special return value for the LineCoeffToXYPlane() et al meaning that there's no intersectino with the plane." }, + }, + Variables = + { + x = { Type = "number", Notes = "The X coord of the vector." }, + y = { Type = "number", Notes = "The Y coord of the vector." }, + z = { Type = "number", Notes = "The Z coord of the vector." }, }, }, -- Vector3d -- cgit v1.2.3 From e48dabfb101706b4a64d2c4e17f3cc925978955a Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 13 Nov 2013 23:01:57 +0100 Subject: Updated the Core. --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index de53a607f..9ec55bcdc 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit de53a607f30c583e08c06b6e5eb936cd278ab8cd +Subproject commit 9ec55bcdcaf8b3eea8e98e3e502890295dda14d6 -- cgit v1.2.3 From f6e16ce15082d867ed182690e3a80435cf60dc84 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Fri, 15 Nov 2013 08:35:02 +1100 Subject: cProtocol add SendExperience() and debugging --- MCServer/Plugins/Debuggers/Debuggers.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 04a15a002..119e1525e 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -44,6 +44,7 @@ function Initialize(Plugin) PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); + PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -839,3 +840,8 @@ end +function HandleAddExperience(a_Split, a_Player) + a_Player->AddExperience(200); + + return true; +end \ No newline at end of file -- cgit v1.2.3 From 15c330664a78a34b5138ec5fc8089b77656e172e Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 14 Nov 2013 22:39:14 +0000 Subject: Fixed arrow bugs * Fixed arrows hitting blocks wrong --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index 9ec55bcdc..de53a607f 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit 9ec55bcdcaf8b3eea8e98e3e502890295dda14d6 +Subproject commit de53a607f30c583e08c06b6e5eb936cd278ab8cd -- cgit v1.2.3 From 7fddf4479df7f454d340c23c1a93b982dbbbee4d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 09:49:40 +0100 Subject: Debuggers: Added the BlockEntity test harness when generating chunks. --- MCServer/Plugins/Debuggers/Debuggers.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 04a15a002..248433ddd 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -26,6 +26,7 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); + cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); PluginManager = cRoot:Get():GetPluginManager(); PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); @@ -531,6 +532,27 @@ end +function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) + -- Get the topmost block coord: + local Height = a_ChunkDesc:GetHeight(0, 0); + + -- Create a sign there: + a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0); + local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0); + if (BlockEntity ~= nil) then + LOG("Setting sign lines..."); + local SignEntity = tolua.cast(BlockEntity, "cSignEntity"); + SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)"); + end + + -- Update the heightmap: + a_ChunkDesc:SetHeight(0, 0, Height + 1); +end + + + + + -- Function "round" copied from http://lua-users.org/wiki/SimpleRound function round(num, idp) local mult = 10^(idp or 0) -- cgit v1.2.3 From 6e5d7b70a15214078ec6a5b973ee43217cea6897 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 10:09:54 +0100 Subject: APIDump: Removed the BlockEntity constructors' docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 86 ++++++++++-------------------------- 1 file changed, 24 insertions(+), 62 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 321f50732..cd3fe366a 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -403,20 +403,12 @@ g_APIDesc = in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate in any way.

    - The chest entity can be created by the plugins only in the {{OnChunkGenerating}} and - {{OnChunkGenerated}} hooks, as part of the new chunk being generated. Plugins may generate chests - with contents in this way.

    -

    To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with either DoWithChestAt() or ForEachChestInChunk() function. See the code example below ]], Inherits = "cBlockEntityWithItems", - Functions = - { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cChestEntity", Notes = "Creates a new cChestEntity object. To be used only in the chunk generating hooks {{OnChunkGenerating}} and {{OnChunkGenerated}}." }, - }, Constants = { ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, @@ -642,40 +634,31 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cDispenserEntity = { - Desc = [[This class represents a dispenser block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with a {{cDropperEntity|dropper}} entity. -

    -

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). -]], - Functions = - { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDispenserEntity", Notes = "Creates a new cDispenserEntity at the specified coords" }, - }, - Constants = - { - }, + Desc = [[ + This class represents a dispenser block entity in the world. Most of this block entity's + functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents + the behavior common with a {{cDropperEntity|dropper}} entity. + ]], Inherits = "cDropSpenserEntity", }, cDropperEntity = { - Desc = [[This class represents a dropper block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with the {{cDispenserEntity|dispenser}} entity. -

    -

    An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). -]], - Functions = - { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDropperEntity", Notes = "Creates a new cDropperEntity at the specified coords" }, - }, - Constants = - { - }, + Desc = [[ + This class represents a dropper block entity in the world. Most of this block entity's functionality + is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior + common with the {{cDispenserEntity|dispenser}} entity.

    +

    + An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). + ]], Inherits = "cDropSpenserEntity", - }, + }, -- cDropperEntity cDropSpenserEntity = { - Desc = [[This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. -]], + Desc = [[ + This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. + ]], Functions = { Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" }, @@ -687,9 +670,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, }, - Inherits = "cBlockEntityWithItems"; - }, + }, -- cDropSpenserEntity cEnchantments = { @@ -913,7 +895,6 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cFile:Delete("/usr/bin/virus.exe");

    ]], - Functions = { Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, @@ -925,8 +906,7 @@ cFile:Delete("/usr/bin/virus.exe"); IsFolder = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing folder." }, Rename = { Params = "OrigPath, NewPath", Return = "bool", Notes = "Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists." }, }, - - }, + }, -- cFile cFireChargeEntity = { @@ -938,11 +918,11 @@ cFile:Delete("/usr/bin/virus.exe"); cFurnaceEntity = { - Desc = [[This class represents a furnace block entity in the world. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks) -]], + Desc = [[ + This class represents a furnace block entity in the world. + ]], Functions = { - constructor = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "cFurnaceEntity", Notes = "Creates a new cFurnaceEntity at the specified coords and the specified block type / meta" }, GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" }, GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" }, GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" }, @@ -996,14 +976,10 @@ cFile:Delete("/usr/bin/virus.exe"); cHopperEntity = { Desc = [[ - This class represents a hopper block entity in the world.

    -

    - Plugins may use this class during chunk generation ({{OnChunkGenerated|HOOK_CHUNK_GENERATED}} and - {{OnChunkGenerating|HOOK_CHUNK_GENERATING}}) to add hoppers to the generated chunk. + This class represents a hopper block entity in the world. ]], Functions = { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cHopperEntity", Notes = "Creates and returns a new hopper at the specified coords." }, GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." }, }, Constants = @@ -1852,7 +1828,7 @@ a_Player:OpenWindow(Window);

     cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage);
     

    -]], + ]], Functions = { AddHook = @@ -1872,7 +1848,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." }, ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." }, - ExecuteConsoleCommand = { Params = "CommandStr", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature:
    function(Command, Permission, HelpString)
    . If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, @@ -2000,7 +1975,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); GetVirtualRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of virtual RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." }, GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." }, - QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' }, + QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread. The command's output will be sent to console." }, SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds." }, SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol number." } }, @@ -2048,18 +2023,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Inherits = "cBlockEntity"; }, - cStringMap = - { - Desc = [[cStringMap is an object that maps strings with strings, it's also known as a dictionary -]], - Functions = - { - }, - Constants = - { - }, - }, - cThrownEggEntity = { Desc = "", @@ -2238,7 +2201,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta", Notes = "Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, - GetClassStatic = { Params = "", Return = "string", Notes = "Returns the name of the class, \"cWorld\"." }, GetDimension = { Params = "", Return = "eDimension", Notes = "Returns the dimension of the world - dimOverworld, dimNether or dimEnd." }, GetGameMode = { Params = "", Return = "eGameMode", Notes = "Returns the gamemode of the world - gmSurvival, gmCreative or gmAdventure." }, GetGeneratorQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks that are queued in the chunk generator." }, -- cgit v1.2.3 From 90fc51c4d03a941035b07d9d303ec542ff257b8b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 10:13:32 +0100 Subject: cRoot::SaveAllChunks() doesn't wait for the save (deadlocks). Rather, it only queues the save task onto each world's tick thread. --- MCServer/Plugins/APIDump/APIDesc.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index cd3fe366a..9f95ce5e3 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1976,7 +1976,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." }, GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." }, QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread. The command's output will be sent to console." }, - SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds." }, + SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds. Note that the saving is queued on each world's tick thread and this functions returns before the chunks are actually saved." }, SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol number." } }, Constants = -- cgit v1.2.3 From 5eb67dbdfcaeb52be11a5dde75338bf24e2e5969 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 11:28:11 +0100 Subject: Debuggers: Removed the old OnChunkGenerated code testing the cBlockArea writing. --- MCServer/Plugins/Debuggers/Debuggers.lua | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 248433ddd..a13820eff 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -500,21 +500,6 @@ end -function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc) - -- Test ChunkDesc / BlockArea interaction - local BlockArea = cBlockArea(); - ChunkDesc:ReadBlockArea(BlockArea, 0, 15, 50, 70, 0, 15); - - -- BlockArea:SaveToSchematicFile("ChunkBlocks_" .. ChunkX .. "_" .. ChunkZ .. ".schematic"); - - ChunkDesc:WriteBlockArea(BlockArea, 5, 115, 5); - return false; -end - - - - - function OnChat(a_Player, a_Message) return false, "blabla " .. a_Message; end -- cgit v1.2.3 From 4f2645d0e56bef4db9e72ce0b9f5d6c28ab98a75 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 11:34:43 +0100 Subject: APIDump: Documented cChunkDesc:GetBlockEntity(). --- MCServer/Plugins/APIDump/APIDesc.lua | 38 +++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 9f95ce5e3..0604032b0 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -458,6 +458,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta", Return = "", Notes = "Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, }, GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" }, + GetBlockEntity = { Params = "RelX, RelY, RelZ", Return = "{{cBlockEntity}} descendant", Notes = "Returns the block entity for the block at the specified coords. Creates it if it doesn't exist. Returns nil if the block has no block entity capability." }, GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, @@ -496,7 +497,42 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), Constants = { }, - }, + AdditionalInfo = + { + { + Header = "Manipulating block entities", + Contents = [[ + To manipulate block entities while the chunk is generated, first use SetBlockTypeMeta() to set + the correct block type and meta at the position. Then use the GetBlockEntity() to create and + return the correct block entity instance. Finally, use tolua.cast() to cast to the proper + type.

    + Note that you don't need to check if a block entity has previously existed at the place, because + GetBlockEntity() will automatically re-create the correct type for you.

    +

    + The following code is taken from the Debuggers plugin, it creates a sign at each chunk's [0, 0] + coords, with the text being the chunk coords: +

    +function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
    +	-- Get the topmost block coord:
    +	local Height = a_ChunkDesc:GetHeight(0, 0);
    +	
    +	-- Create a sign there:
    +	a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0);
    +	local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0);
    +	if (BlockEntity ~= nil) then
    +		LOG("Setting sign lines...");
    +		local SignEntity = tolua.cast(BlockEntity, "cSignEntity");
    +		SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)");
    +	end
    +
    +	-- Update the heightmap:
    +	a_ChunkDesc:SetHeight(0, 0, Height + 1);
    +end
    +
    + ]], + }, + }, -- AdditionalInfo + }, -- cChunkDesc cClientHandle = { -- cgit v1.2.3 From 1b2e6e74736f975386879aa5eb064df5b2f88dac Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Fri, 15 Nov 2013 22:42:09 +1100 Subject: added cProtocol function to pass xp to client --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 119e1525e..cd7da359b 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -841,7 +841,7 @@ end function HandleAddExperience(a_Split, a_Player) - a_Player->AddExperience(200); + a_Player:AddExperience(200); return true; end \ No newline at end of file -- cgit v1.2.3 From 194aa1decb532859439f4f554069883e96a0ce48 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 12:42:35 +0100 Subject: APIDump: Documented the cJukeboxEntity. --- MCServer/Plugins/APIDump/APIDesc.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 0604032b0..993c2a40b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1464,6 +1464,22 @@ end }, }, -- cItems + cJukeboxEntity = + { + Desc = [[ + This class represents a jukebox in the world. It can play the records, either when the + {{cPlayer|player}} uses the record on the jukebox, or when a plugin instructs it to play. + ]], + Inherits = "cBlockEntity", + Functions = + { + EjectRecord = { Params = "", Return = "", Notes = "Ejects the current record as a {{cPickup|pickup}}. No action if there's no current record. To remove record without generating the pickup, use SetRecord(0)" }, + GetRecord = { Params = "", Return = "number", Notes = "Returns the record currently present. Zero for no record, E_ITEM_*_DISC for records." }, + PlayRecord = { Params = "", Return = "", Notes = "Plays the currently present record. No action if there's no current record." }, + SetRecord = { Params = "number", Return = "", Notes = "Sets the currently present record. Use zero for no record, or E_ITEM_*_DISC for records." }, + }, + }, -- cJukeboxEntity + cLineBlockTracer = { Desc = [[Objects of this class provide an easy-to-use interface to tracing lines through individual -- cgit v1.2.3 From 7586e832bf74d6ca9f6fcfe75f55378b6ea3ac20 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 13:10:36 +0100 Subject: APIDump: Documented cNoteEntity. --- MCServer/Plugins/APIDump/APIDesc.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 993c2a40b..54bd86c77 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1711,7 +1711,26 @@ a_Player:OpenWindow(Window); mtZombiePigman = { Notes = "" }, }, Inherits = "cPawn", - }, + }, -- cMonster + + cNoteEntity = + { + Desc = [[ + This class represents a note block entity in the world. It takes care of the note block's pitch, + and also can play the sound, either when the {{cPlayer|player}} right-clicks it, redstone activates + it, or upon a plugin's request.

    +

    + The pitch is stored as an integer between 0 and 24. + ]], + Functions = + { + GetPitch = { Params = "", Return = "number", Notes = "Returns the current pitch set for the block" }, + IncrementPitch = { Params = "", Return = "", Notes = "Adds 1 to the current pitch. Wraps around to 0 when the pitch cannot go any higher." }, + MakeSound = { Params = "", Return = "", Notes = "Plays the sound for all {{cClientHandle|clients}} near this block." }, + SetPitch = { Params = "Pitch", Return = "", Notes = "Sets a new pitch for the block." }, + }, + Inherits = "cBlockEntity", + }, -- cNoteEntity cPawn = { -- cgit v1.2.3 From 26d3dd3466266c971edd43986e5aad9580ebbca9 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 13:34:20 +0100 Subject: APIDump: Documented cSignEntity. --- MCServer/Plugins/APIDump/APIDesc.lua | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 54bd86c77..fe5d7bed1 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2076,23 +2076,22 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Constants = { }, - }, + }, -- cServer cSignEntity = { Desc = [[ A sign entity represents a sign in the world. This class is only used when generating chunks, so - that the plugins may generate signs within new chunks. + that the plugins may generate signs within new chunks. See the code example in {{cChunkDesc}}. ]], Functions = { + GetLine = { Params = "LineIndex", Return = "string", Notes = "Returns the specified line. LineIndex is expected between 0 and 3. Returns empty string and logs to server console when LineIndex is invalid." }, + SetLine = { Params = "LineIndex, LineText", Return = "", Notes = "Sets the specified line. LineIndex is expected between 0 and 3. Logs to server console when LineIndex is invalid." }, + SetLines = { Params = "Line1, Line2, Line3, Line4", Return = "", Notes = "Sets all the sign's lines at once." }, }, - Constants = - { - }, - Inherits = "cBlockEntity"; - }, + }, -- cSignEntity cThrownEggEntity = { -- cgit v1.2.3 From 2ed8e384192154daf8af94cda390980de88bb6aa Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 13:44:07 +0100 Subject: APIDump: Small fixes and additions. --- MCServer/Plugins/APIDump/APIDesc.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index fe5d7bed1..741b912a6 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -504,7 +504,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), Contents = [[ To manipulate block entities while the chunk is generated, first use SetBlockTypeMeta() to set the correct block type and meta at the position. Then use the GetBlockEntity() to create and - return the correct block entity instance. Finally, use tolua.cast() to cast to the proper + return the correct block entity instance. Finally, use {{tolua}}.cast() to cast to the proper type.

    Note that you don't need to check if a block entity has previously existed at the place, because GetBlockEntity() will automatically re-create the correct type for you.

    @@ -756,6 +756,8 @@ end enchInfinity = { Notes = "" }, enchKnockback = { Notes = "" }, enchLooting = { Notes = "" }, + enchLuckOfTheSea = { Notes = "" }, + enchLure = { Notes = "" }, enchPower = { Notes = "" }, enchProjectileProtection = { Notes = "" }, enchProtection = { Notes = "" }, @@ -1267,6 +1269,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" }, Empty = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, GetMaxDamage = { Params = "", Return = "number", Notes = "Returns the maximum value for damage that this item can get before breaking; zero if damage is not accounted for for this item type" }, + GetMaxStackSize = { Params = "", Return = "number", Notes = "Returns the maximum stack size for this item." }, IsDamageable = { Params = "", Return = "bool", Notes = "Returns true if this item does account for its damage" }, IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if this object represents an empty item (zero count or invalid ID)" }, IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" }, -- cgit v1.2.3 From 04dff4882a3d75f3a0d432fb3377cc3f59fdf251 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 02:23:50 +1100 Subject: finished #143 I believe --- MCServer/Plugins/Debuggers/Debuggers.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 7b1217b95..badce8508 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -46,6 +46,7 @@ function Initialize(Plugin) PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); + PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -852,3 +853,13 @@ function HandleAddExperience(a_Split, a_Player) return true; end + + + + + +function HandleRemoveXp(a_Split, a_Player) + a_Player:SetExperience(0); + + return true; +end -- cgit v1.2.3 From 905cd0e73ec9b54e9d4b9a7954c57161be40d491 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 22:39:02 +0100 Subject: APIDump: Functions that are documented are never ignored. This simplifies exclude-filters for functions such as lxp.new() that need inclusion. --- MCServer/Plugins/APIDump/main.lua | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index d84926b53..ab154dc45 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -373,13 +373,18 @@ function ReadDescriptions(a_API) return false; end - -- Returns true if the function (specified by its fully qualified name) is to be ignored - local function IsFunctionIgnored(a_FnName) + -- Returns true if the function is to be ignored + local function IsFunctionIgnored(a_ClassName, a_FnName) if (g_APIDesc.IgnoreFunctions == nil) then return false; end + if (((g_APIDesc.Classes[a_ClassName] or {}).Functions or {})[a_FnName] ~= nil) then + -- The function is documented, don't ignore + return false; + end + local FnName = a_ClassName .. "." .. a_FnName; for i, name in ipairs(g_APIDesc.IgnoreFunctions) do - if (a_FnName:match(name)) then + if (FnName:match(name)) then return true; end end @@ -482,7 +487,7 @@ function ReadDescriptions(a_API) if (FnDesc == nil) then -- No description for this API function AddFunction(func.Name); - if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + if not(IsFunctionIgnored(cls.Name, FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end else @@ -505,7 +510,7 @@ function ReadDescriptions(a_API) else -- if (APIDesc.Functions ~= nil) for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; - if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + if not(IsFunctionIgnored(cls.Name, FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end end @@ -567,7 +572,7 @@ function ReadDescriptions(a_API) g_Stats.NumUndocumentedClasses = g_Stats.NumUndocumentedClasses + 1; for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; - if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + if not(IsFunctionIgnored(cls.Name, FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end end -- for j, func - cls.Functions[] @@ -586,7 +591,7 @@ function ReadDescriptions(a_API) -- Remove ignored functions: local NewFunctions = {}; for j, fn in ipairs(cls.Functions) do - if (not(IsFunctionIgnored(cls.Name .. "." .. fn.Name))) then + if (not(IsFunctionIgnored(cls.Name, fn.Name))) then table.insert(NewFunctions, fn); end end -- for j, fn -- cgit v1.2.3 From d96f6224371a0c6aaf561f16d31381e5b11e5a55 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 15 Nov 2013 22:39:27 +0100 Subject: APIDump: Documented lxp, the XML parser class. --- MCServer/Plugins/APIDump/APIDesc.lua | 106 +++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 741b912a6..cccc05ce2 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2478,6 +2478,112 @@ end }, }, -- ItemCategory + lxp = + { + Desc = [[ + This class provides an interface to the XML parser, + {{http://matthewwild.co.uk/projects/luaexpat/|LuaExpat}}. It provides a SAX interface with an + incremental XML parser.

    +

    + With an event-based API like SAX the XML document can be fed to the parser in chunks, and the + parsing begins as soon as the parser receives the first document chunk. LuaExpat reports parsing + events (such as the start and end of elements) directly to the application through callbacks. The + parsing of huge documents can benefit from this piecemeal operation.

    +

    + See the online + {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}} for details + on how to work with this parser. The code examples below should provide some basic help, too. + ]], + Functions = + { + new = {Params = "CallbacksTable, [SeparatorChar]", Return = "XMLParser object", Notes = "Creates a new XML parser object, with the specified callbacks table and optional separator character."}, + }, + Constants = + { + _COPYRIGHT = { Notes = "" }, + _DESCRIPTION = { Notes = "" }, + _VERSION = { Notes = "" }, + }, + AdditionalInfo = + { + { + Header = "Parser callbacks", + Contents = [[ + The callbacks table passed to the new() function specifies the Lua functions that the parser + calls upon various events. The following table lists the most common functions used, for a + complete list see the online + {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}}.

    + + + + + +
    Function nameParametersNotes
    CharacterDataParser, stringCalled when the parser recognizes a raw string inside the element
    EndElementParser, ElementNameCalled when the parser detects the ending of an XML element
    StartElementParser, ElementName, AttributesTableCalled when the parser detects the start of an XML element. The AttributesTable is a Lua table containing all the element's attributes, both in the array section (in the order received) and in the dictionary section.
    + ]], + }, + { + Header = "XMLParser object", + Contents = [[ + The XMLParser object returned by lxp.new provides the functions needed to parse the XML. The + following list provides the most commonly used ones, for a complete list see the online + {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}}. +
      +
    • close() - closes the parser, freeing all memory used by it.
    • +
    • getCallbacks() - returns the callbacks table for this parser.
    • +
    • parse(string) - parses more document data. the string contains the next part (or possibly all) of the document. Returns non-nil for success or nil, msg, line, col, pos for error.
    • +
    • stop() - aborts parsing (can be called from within the parser callbacks).
    • +
    + ]], + }, + { + Header = "Code example", + Contents = [[ + The following code reads an entire XML file and outputs its logical structure into the console: +
    +local Depth = 0;
    +
    +-- Define the callbacks:
    +local Callbacks = {
    +	CharacterData = function(a_Parser, a_String)
    +		LOG(string.rep(" ", Depth) .. "* " .. a_String);
    +	end
    +	
    +	EndElement = function(a_Parser, a_ElementName)
    +		Depth = Depth - 1;
    +		LOG(string.rep(" ", Depth) .. "- " .. a_ElementName);
    +	end
    +
    +	StartElement = function(a_Parser, a_ElementName, a_Attribs)
    +		LOG(string.rep(" ", Depth) .. "+ " .. a_ElementName);
    +		Depth = Depth + 1;
    +	end
    +}
    +
    +-- Create the parser:
    +local Parser = lxp.new(Callbacks);
    +
    +-- Parse the XML file:
    +local f = io.open("file.xml", "rb");
    +while (true) do
    +	local block = f:read(128 * 1024);  -- Use a 128KiB buffer for reading
    +	if (block == nil) then
    +		-- End of file
    +		break;
    +	end
    +	Parser:parse(block);
    +end
    +
    +-- Signalize to the parser that no more data is coming
    +Parser:parse();
    +
    +-- Close the parser:
    +Parser:close();
    +
    + ]], + }, + }, -- AdditionalInfo + }, -- lxp + TakeDamageInfo = { Desc = [[ -- cgit v1.2.3 From b72ced31649f8a851ffe60778e8a603bda941dc9 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:00:45 +1100 Subject: removed SpendExperience and changed AddExperience to handle removing Xp --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index badce8508..69e724b30 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -849,7 +849,7 @@ end function HandleAddExperience(a_Split, a_Player) - a_Player:AddExperience(200); + a_Player:DelatExperience(200); return true; end -- cgit v1.2.3 From 25ccc33252b1c105c6c13ae23200b5aa49b7ed39 Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:05:34 +1100 Subject: updated plugin --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 69e724b30..491d294e2 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -849,7 +849,7 @@ end function HandleAddExperience(a_Split, a_Player) - a_Player:DelatExperience(200); + a_Player:DeltaExperience(200); return true; end -- cgit v1.2.3 From b3bb34974fddfae6cea9ca59d71f95e32621793d Mon Sep 17 00:00:00 2001 From: Daniel O'Brien Date: Sat, 16 Nov 2013 22:17:46 +1100 Subject: updated plugin again... --- MCServer/Plugins/Debuggers/Debuggers.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 491d294e2..9350606cc 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -859,7 +859,7 @@ end function HandleRemoveXp(a_Split, a_Player) - a_Player:SetExperience(0); + a_Player:SetCurrentExperience(0); return true; end -- cgit v1.2.3 From 9bc79722c7b8665f18a5be70c751f8383e9b0815 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 17 Nov 2013 23:01:23 +0100 Subject: APIDump: Documented Vector3f. --- MCServer/Plugins/APIDump/APIDesc.lua | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index cccc05ce2..210ddc1ae 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2707,13 +2707,43 @@ end Vector3f = { - Desc = [[A Vector3f object uses floating point values to describe a point in space. Vector3f is part of the {{vector3|vector3}} family. -]], + Desc = [[ + A Vector3f object uses floating point values to describe a point in space.

    +

    + See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3i}} for integer + point 3D coords. + ]], Functions = { + constructor = + { + { Params = "", Return = "Vector3f", Notes = "Creates a new Vector3f object with zero coords" }, + { Params = "x, y, z", Return = "Vector3f", Notes = "Creates a new Vector3f object with the specified coords" }, + { Params = "Vector3f", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified vector" }, + { Params = "{{Vector3d}}", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified {{Vector3d}}" }, + { Params = "{{Vector3i}}", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified {{Vector3i}}" }, + }, + operator_mul = + { + { Params = "number", Return = "Vector3f", Notes = "Returns a new Vector3f object that has each of its coords multiplied by the specified number" }, + { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that has each of its coords multiplied by the respective coord of the specified vector." }, + }, + operator_plus = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the vector sum of this vector and the specified vector." }, + operator_sub = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the vector differrence between this vector and the specified vector." }, + Cross = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the cross product of this vector and the specified vector." }, + Dot = { Params = "Vector3f", Return = "number", Notes = "Returns the dot product of this vector and the specified vector." }, + Equals = { Params = "Vector3f", Return = "bool", Notes = "Returns true if the specified vector is exactly equal to this vector." }, + Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector" }, + Normalize = { Params = "", Return = "", Notes = "Normalizes this vector (makes it 1 unit long while keeping the direction). FIXME: Fails for zero vectors." }, + NormalizeCopy = { Params = "", Return = "Vector3f", Notes = "Returns a copy of this vector that is normalized (1 unit long while keeping the same direction). FIXME: Fails for zero vectors." }, + Set = { Params = "x, y, z", Return = "", Notes = "Sets all the coords of the vector at once." }, + SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison." }, }, - Constants = + Variables = { + x = { Type = "number", Notes = "The X coord of the vector." }, + y = { Type = "number", Notes = "The Y coord of the vector." }, + z = { Type = "number", Notes = "The Z coord of the vector." }, }, }, -- Vector3f -- cgit v1.2.3 From 4844422e06da2c2982d96e2f0df2824f5c732845 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 19 Nov 2013 06:49:21 +0100 Subject: APIDump: Documented Vector3i. --- MCServer/Plugins/APIDump/APIDesc.lua | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 210ddc1ae..450bc9f28 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2666,7 +2666,10 @@ end Vector3d = { Desc = [[ - A Vector3d object uses double precision floating point values to describe a point in 3D space. + A Vector3d object uses double precision floating point values to describe a point in 3D space.

    +

    + See also {{Vector3f}} for single-precision floating point 3D coords and {{Vector3i}} for integer + 3D coords. ]], Functions = { @@ -2711,7 +2714,7 @@ end A Vector3f object uses floating point values to describe a point in space.

    See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3i}} for integer - point 3D coords. + 3D coords. ]], Functions = { @@ -2749,13 +2752,30 @@ end Vector3i = { - Desc = [[A Vector3i object uses integer values to describe a point in space. Vector3i is part of the {{vector3|vector3}} family. -]], + Desc = [[ + A Vector3i object uses integer values to describe a point in space.

    +

    + See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3f}} for + single-precision floating point 3D coords. + ]], Functions = { + constructor = + { + { Params = "", Return = "Vector3i", Notes = "Creates a new Vector3i object with zero coords." }, + { Params = "x, y, z", Return = "Vector3i", Notes = "Creates a new Vector3i object with the specified coords." }, + { Params = "{{Vector3d}}", Return = "Vector3i", Notes = "Creates a new Vector3i object with coords copied and floor()-ed from the specified {{Vector3d}}." }, + }, + Equals = { Params = "Vector3i", Return = "bool", Notes = "Returns true if this vector is exactly the same as the specified vector." }, + Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector." }, + Set = { Params = "x, y, z", Return = "", Notes = "Sets all the coords of the vector at once" }, + SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison." }, }, - Constants = + Variables = { + x = { Type = "number", Notes = "The X coord of the vector." }, + y = { Type = "number", Notes = "The Y coord of the vector." }, + z = { Type = "number", Notes = "The Z coord of the vector." }, }, }, -- Vector3i -- cgit v1.2.3 From e2ea6b59f52d4b513b5537c33dae543f67c729a8 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 19 Nov 2013 09:56:36 +0100 Subject: APIDump: Slight performance improvement. Strings don't need concatenation when using write(). --- MCServer/Plugins/APIDump/main.lua | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index ab154dc45..fa9d29423 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -740,14 +740,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("

    Functions inherited from " .. a_InheritedName .. "

    \n"); + cf:write("

    Functions inherited from ", a_InheritedName, "

    \n"); end cf:write(" \n \n \n \n \n \n \n"); for i, func in ipairs(a_Functions) do cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n"); - cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n"); + cf:write(" \n \n"); end cf:write("
    NameParametersReturn valueNotes
    " .. func.Name .. "" .. LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)).. "" .. LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)).. "" .. LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)) .. "
    ", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), "
    \n\n"); end @@ -758,14 +758,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("

    Constants inherited from " .. a_InheritedName .. "

    \n"); + cf:write("

    Constants inherited from ", a_InheritedName, "

    \n"); end cf:write(" \n \n \n \n \n \n"); for i, cons in ipairs(a_Constants) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); end cf:write("
    NameValueNotes
    " .. cons.Name .. "" .. cons.Value .. "" .. LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "
    ", cons.Name, "", cons.Value, "", LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name), "
    \n\n"); end @@ -776,14 +776,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("

    Member variables inherited from " .. a_InheritedName .. "

    \n"); + cf:write("

    Member variables inherited from ", a_InheritedName, "

    \n"); end cf:write(" \n \n \n \n \n \n"); for i, var in ipairs(a_Variables) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); end cf:write("
    NameTypeNotes
    " .. var.Name .. "" .. LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name) .. "" .. LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "
    ", var.Name, "", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), "", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "
    \n\n"); end @@ -794,7 +794,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end cf:write("
      "); for i, desc in ipairs(a_Descendants) do - cf:write("
    • " .. desc.Name .. ""); + cf:write("
    • ", desc.Name, ""); WriteDescendants(desc.Descendants); cf:write("
    • \n"); end @@ -814,7 +814,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write([[ - MCServer API - ]] .. a_ClassAPI.Name .. [[ Class + MCServer API - ]], a_ClassAPI.Name, [[ Class @@ -823,7 +823,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI)
      -

      ]] .. a_ClassAPI.Name .. [[

      +

      ]], a_ClassAPI.Name, [[


      Contents

      @@ -857,7 +857,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("
    • " .. (additional.Header or "(No header)").. "
    • \n"); + cf:write("
    • ", (additional.Header or "(No header)"), "
    • \n"); end end cf:write("
    \n\n"); @@ -920,7 +920,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the additional infos: if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("

    " .. additional.Header .. "

    \n"); + cf:write("

    ", additional.Header, "

    \n"); cf:write(LinkifyString(additional.Contents, ClassName)); end end -- cgit v1.2.3 From fed37bca4d12579741be97e7994f1d4b8df4bbfd Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 20 Nov 2013 21:54:37 +0100 Subject: Debuggers: Test harness for cWorld:ForEachBlockEntityInChunk(). The fill command will fill all empty slots in block entities with containment with gold nuggets, one per slot. --- MCServer/Plugins/Debuggers/Debuggers.lua | 78 ++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 19 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 9350606cc..c4811b91a 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -28,25 +28,26 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); - PluginManager = cRoot:Get():GetPluginManager(); - PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); - PluginManager:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities"); - PluginManager:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool"); - PluginManager:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "- Opens up a window using plugin API"); - PluginManager:BindCommand("/gc", "debuggers", HandleGCCmd, "- Activates the Lua garbage collector"); - PluginManager:BindCommand("/fast", "debuggers", HandleFastCmd, "- Switches between fast and normal movement speed"); - PluginManager:BindCommand("/dash", "debuggers", HandleDashCmd, "- Switches between fast and normal sprinting speed"); - PluginManager:BindCommand("/hunger", "debuggers", HandleHungerCmd, "- Lists the current hunger-related variables"); - PluginManager:BindCommand("/poison", "debuggers", HandlePoisonCmd, "- Sets food-poisoning for 15 seconds"); - PluginManager:BindCommand("/starve", "debuggers", HandleStarveCmd, "- Sets the food level to zero"); - PluginManager:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value"); - PluginManager:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air"); - PluginManager:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window"); - PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); - PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); - PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); - PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); - PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); + PM = cRoot:Get():GetPluginManager(); + PM:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); + PM:BindCommand("/ke", "debuggers", HandleKillEntitiesCmd, "- Kills all the loaded entities"); + PM:BindCommand("/wool", "debuggers", HandleWoolCmd, "- Sets all your armor to blue wool"); + PM:BindCommand("/testwnd", "debuggers", HandleTestWndCmd, "- Opens up a window using plugin API"); + PM:BindCommand("/gc", "debuggers", HandleGCCmd, "- Activates the Lua garbage collector"); + PM:BindCommand("/fast", "debuggers", HandleFastCmd, "- Switches between fast and normal movement speed"); + PM:BindCommand("/dash", "debuggers", HandleDashCmd, "- Switches between fast and normal sprinting speed"); + PM:BindCommand("/hunger", "debuggers", HandleHungerCmd, "- Lists the current hunger-related variables"); + PM:BindCommand("/poison", "debuggers", HandlePoisonCmd, "- Sets food-poisoning for 15 seconds"); + PM:BindCommand("/starve", "debuggers", HandleStarveCmd, "- Sets the food level to zero"); + PM:BindCommand("/fl", "debuggers", HandleFoodLevelCmd, "- Sets the food level to the given value"); + PM:BindCommand("/spidey", "debuggers", HandleSpideyCmd, "- Shoots a line of web blocks until it hits non-air"); + PM:BindCommand("/ench", "debuggers", HandleEnchCmd, "- Provides an instant dummy enchantment window"); + PM:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); + PM:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); + PM:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); + PM:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); + PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); + PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -863,3 +864,42 @@ function HandleRemoveXp(a_Split, a_Player) return true; end + + + + + +function HandleFill(a_Split, a_Player) + local World = a_Player:GetWorld(); + local ChunkX = a_Player:GetChunkX(); + local ChunkZ = a_Player:GetChunkZ(); + World:ForEachBlockEntityInChunk(ChunkX, ChunkZ, + function(a_BlockEntity) + local BlockType = a_BlockEntity:GetBlockType(); + if ( + (BlockType == E_BLOCK_CHEST) or + (BlockType == E_BLOCK_DISPENSER) or + (BlockType == E_BLOCK_DROPPER) or + (BlockType == E_BLOCK_FURNACE) or + (BlockType == E_BLOCK_HOPPER) + ) then + -- This block entity has items (inherits from cBlockEntityWithItems), fill it: + -- Note that we're not touching lit furnaces, don't wanna mess them up + local EntityWithItems = tolua.cast(a_BlockEntity, "cBlockEntityWithItems"); + local ItemGrid = EntityWithItems:GetContents(); + local NumSlots = ItemGrid:GetNumSlots(); + local ItemToSet = cItem(E_ITEM_GOLD_NUGGET); + for i = 0, NumSlots - 1 do + if (ItemGrid:GetSlot(i):IsEmpty()) then + ItemGrid:SetSlot(i, ItemToSet); + end + end + end + end + ); + return true; +end + + + + -- cgit v1.2.3 From e9a8b964795af23e2dc9681444d7c9944b12ef6f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 20 Nov 2013 22:04:16 +0100 Subject: APIDump: Documented cWorld:ForEachBlockEntityInChunk() and cWorld:DoWithBlockEntityAt(). --- MCServer/Plugins/APIDump/APIDesc.lua | 2 ++ 1 file changed, 2 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 450bc9f28..f263d83f4 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2240,6 +2240,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); CreateProjectile = { Params = "X, Y, Z, {{cProjectileEntity|ProjectileKind}}, {{cEntity|Creator}}, [{{Vector3d|Speed}}]", Return = "", Notes = "Creates a new projectile of the specified kind at the specified coords. The projectile's creator is set to Creator (may be nil). Optional speed indicates the initial speed for the projectile." }, DigBlock = { Params = "X, Y, Z", Return = "", Notes = "Replaces the specified block with air, without dropping the usual pickups for the block. Wakes up the simulators for the block and its neighbors." }, DoExplosionAt = { Params = "Force, X, Y, Z, CanCauseFire, Source, SourceData", Return = "", Notes = "Creates an explosion of the specified relative force in the specified position. If CanCauseFire is set, the explosion will set blocks on fire, too. The Source parameter specifies the source of the explosion, one of the esXXX constants. The SourceData parameter is specific to each source type, usually it provides more info about the source." }, + DoWithBlockEntityAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a block entity at the specified coords, calls the CallbackFunction with the {{cBlockEntity}} parameter representing the block entity. The CallbackFunction has the following signature:
    function Callback({{cBlockEntity|BlockEntity}}, [CallbackData])
    The function returns false if there is no block entity, or if there is, it returns the bool value that the callback has returned. Use {{tolua}}.cast() to cast the Callback's BlockEntity parameter to the correct {{cBlockEntity}} descendant." }, DoWithChestAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a chest at the specified coords, calls the CallbackFunction with the {{cChestEntity}} parameter representing the chest. The CallbackFunction has the following signature:
    function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
    The function returns false if there is no chest, or if there is, it returns the bool value that the callback has returned." }, DoWithDispenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dispenser at the specified coords, calls the CallbackFunction with the {{cDispenserEntity}} parameter representing the dispenser. The CallbackFunction has the following signature:
    function Callback({{cDispenserEntity|DispenserEntity}}, [CallbackData])
    The function returns false if there is no dispenser, or if there is, it returns the bool value that the callback has returned." }, DoWithDropSpenserAt = { Params = "X, Y, Z, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a dropper or a dispenser at the specified coords, calls the CallbackFunction with the {{cDropSpenserEntity}} parameter representing the dropper or dispenser. The CallbackFunction has the following signature:
    function Callback({{cDropSpenserEntity|DropSpenserEntity}}, [CallbackData])
    Note that this can be used to access both dispensers and droppers in a similar way. The function returns false if there is neither dispenser nor dropper, or if there is, it returns the bool value that the callback has returned." }, @@ -2253,6 +2254,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); { Params = "{{Vector3i|BlockCoords}}, BlockType, BlockMeta", Return = "", Notes = "Sets the block at the specified coords, without waking up the simulators or replacing the block entities for the previous block type. Do not use if the block being replaced has a block entity tied to it!" }, }, FindAndDoWithPlayer = { Params = "PlayerNameHint, CallbackFunction, [CallbackData]", Return = "bool", Notes = "If there is a player of a name similar to the specified name (weighted-match), calls the CallbackFunction with the {{cPlayer}} parameter representing the player. The CallbackFunction has the following signature:
    function Callback({{cPlayer|Player}}, [CallbackData])
    The function returns false if the player was not found, or whatever bool value the callback returned if the player was found. Note that the name matching is very loose, so it is a good idea to check the player name in the callback function." }, + ForEachBlockEntityInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each block entity in the chunk. Returns true if all block entities in the chunk have been processed (including when there are zero block entities), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
    function Callback({{cBlockEntity|BlockEntity}}, [CallbackData])
    The callback should return false or no value to continue with the next block entity, or true to abort the enumeration. Use {{tolua}}.cast() to cast the Callback's BlockEntity parameter to the correct {{cBlockEntity}} descendant." }, ForEachChestInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each chest in the chunk. Returns true if all chests in the chunk have been processed (including when there are zero chests), or false if the callback has aborted the enumeration by returning true. The CallbackFunction has the following signature:
    function Callback({{cChestEntity|ChestEntity}}, [CallbackData])
    The callback should return false or no value to continue with the next chest, or true to abort the enumeration." }, ForEachEntity = { Params = "CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the loaded world. Returns true if all the entities have been processed (including when there are zero entities), or false if the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, ForEachEntityInChunk = { Params = "ChunkX, ChunkZ, CallbackFunction, [CallbackData]", Return = "bool", Notes = "Calls the specified callback for each entity in the specified chunk. Returns true if all the entities have been processed (including when there are zero entities), or false if the chunk is not loaded or the callback function has aborted the enumeration by returning true. The callback function has the following signature:
    function Callback({{cEntity|Entity}}, [CallbackData])
    The callback should return false or no value to continue with the next entity, or true to abort the enumeration." }, -- cgit v1.2.3 From 98be3ca0e4e93eae5deafff86a27827a3ce79e6f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 21 Nov 2013 22:12:52 +0100 Subject: APIDump: Documented cPlayer XP-related functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f263d83f4..f8fab9afc 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1784,14 +1784,17 @@ a_Player:OpenWindow(Window); { AddFoodExhaustion = { Params = "Exhaustion", Return = "", Notes = "Adds the specified number to the food exhaustion. Only positive numbers expected." }, AddToGroup = { Params = "GroupName", Return = "", Notes = "Temporarily adds the player to the specified group. The assignment is lost when the player disconnects." }, + CalcLevelFromXp = { Params = "XPAmount", Return = "number", Notes = "Returns the level which is reached with the specified amount of XP. Inverse of XpForLevel()." }, CanUseCommand = { Params = "Command", Return = "bool", Notes = "Returns true if the player is allowed to use the specified command." }, CloseWindow = { Params = "[CanRefuse]", Return = "", Notes = "Closes the currently open UI window. If CanRefuse is true (default), the window may refuse the closing." }, CloseWindowIfID = { Params = "WindowID, [CanRefuse]", Return = "", Notes = "Closes the currently open UI window if its ID matches the given ID. If CanRefuse is true (default), the window may refuse the closing." }, + DeltaExperience = { Params = "DeltaXP", Return = "", Notes = "Adds or removes XP from the current XP amount. Won't allow XP to go negative. Returns the new experience, -1 on error (XP overflow)." }, Feed = { Params = "AddFood, AddSaturation", Return = "bool", Notes = "Tries to add the specified amounts to food level and food saturation level (only positive amounts expected). Returns true if player was hungry and the food was consumed, false if too satiated." }, FoodPoison = { Params = "NumTicks", Return = "", Notes = "Starts the food poisoning for the specified amount of ticks; if already foodpoisoned, sets FoodPoisonedTicksRemaining to the larger of the two" }, GetAirLevel = { Params = "", Return = "number", Notes = "Returns the air level (number of ticks of air left)." }, GetClientHandle = { Params = "", Return = "{{cClientHandle}}", Notes = "Returns the client handle representing the player's connection. May be nil (AI players)." }, GetColor = { Return = "string", Notes = "Returns the full color code to be used for this player (based on the first group). Prefix player messages with this code." }, + GetCurrentXp = { Params = "", Return = "number", Notes = "Returns the current amount of XP" }, GetEffectiveGameMode = { Params = "", Return = "{{eGameMode|GameMode}}", Notes = "Returns the current resolved game mode of the player. If the player is set to inherit the world's gamemode, returns that instead. See also GetGameMode() and IsGameModeXXX() functions." }, GetEquippedItem = { Params = "", Return = "{{cItem}}", Notes = "Returns the item that the player is currently holding; empty item if holding nothing." }, GetEyeHeight = { Return = "number", Notes = "Returns the height of the player's eyes, in absolute coords" }, @@ -1814,6 +1817,9 @@ a_Player:OpenWindow(Window); GetThrowSpeed = { Params = "SpeedCoeff", Return = "{{Vector3d}}", Notes = "Returns the speed vector for an object thrown with the specified speed coeff. Basically returns the normalized look vector multiplied by the coeff, with a slight random variation." }, GetThrowStartPos = { Params = "", Return = "{{Vector3d}}", Notes = "Returns the position where the projectiles should start when thrown by this player." }, GetWindow = { Params = "", Return = "{{cWindow}}", Notes = "Returns the currently open UI window. If the player doesn't have any UI window open, returns the inventory window." }, + GetXpLevel = { Params = "", Return = "number", Notes = "Returns the current XP level (based on current XP amount)." }, + GetXpLifetimeTotal = { Params = "", Return = "number", Notes = "Returns the amount of XP that has been accumulated throughout the player's lifetime." }, + GetXpPercentage = { Params = "", Return = "number", Notes = "Returns the percentage of the experience bar - the amount of XP towards the next XP level. Between 0 and 1." }, HasPermission = { Params = "PermissionString", Return = "bool", Notes = "Returns true if the player has the specified permission" }, Heal = { Params = "HitPoints", Return = "", Notes = "Heals the player by the specified amount of HPs. Only positive amounts are expected. Sends a health update to the client." }, IsEating = { Params = "", Return = "bool", Notes = "Returns true if the player is currently eating the item in their hand." }, @@ -1834,6 +1840,7 @@ a_Player:OpenWindow(Window); Respawn = { Params = "", Return = "", Notes = "Restores the health, extinguishes fire, makes visible and sends the Respawn packet." }, SendMessage = { Params = "MessageString", Return = "", Notes = "Sends the specified message to the player." }, SetCrouch = { Params = "IsCrouched", Return = "", Notes = "Sets the crouch state, broadcasts the change to other players." }, + SetCurrentExperience = { Params = "XPAmount", Return = "", Notes = "Sets the current amount of experience (and indirectly, the XP level)." }, SetFoodExhaustionLevel = { Params = "ExhaustionLevel", Return = "", Notes = "Sets the food exhaustion to the specified level." }, SetFoodLevel = { Params = "FoodLevel", Return = "", Notes = "Sets the food level (number of half-drumsticks on-screen)" }, SetFoodPoisonedTicksRemaining = { Params = "FoodPoisonedTicksRemaining", Return = "", Notes = "Sets the number of ticks remaining for food poisoning. Doesn't send foodpoisoning effect to the client, use FoodPoison() for that." }, @@ -1846,6 +1853,7 @@ a_Player:OpenWindow(Window); SetSprintingMaxSpeed = { Params = "SprintingMaxSpeed", Return = "", Notes = "Sets the sprinting maximum speed (as reported by the 1.6.1+ protocols)" }, SetVisible = { Params = "IsVisible", Return = "", Notes = "Sets the player visibility to other players" }, TossItem = { Params = "DraggedItem, [Amount], [CreateType], [CreateDamage]", Return = "", Notes = "FIXME: This function will be rewritten, avoid it. It tosses an item, either from the inventory, dragged in hand (while in UI window) or a newly created one." }, + XpForLevel = { Params = "XPLevel", Return = "number", Notes = "Returns the total amount of XP needed for the specified XP level. Inverse of CalcLevelFromXp()." }, }, Constants = { -- cgit v1.2.3 From 07a1de8ebb58f61f2cd37db0e3382f0df9a784f0 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 12:26:39 +0100 Subject: Debuggers: Added a test harness for cRoot:GetFurnaceRecipe(). The "/fr" command lists the furnace recipe for the currently held item. --- MCServer/Plugins/Debuggers/Debuggers.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index c4811b91a..e4c601da3 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -48,6 +48,7 @@ function Initialize(Plugin) PM:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); + PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -903,3 +904,23 @@ end + +function HandleFurnaceRecipe(a_Split, a_Player) + local HeldItem = a_Player:GetEquippedItem(); + local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem); + if (Out ~= nil) then + a_Player:SendMessage( + "Furnace turns " .. ItemToFullString(In) .. + " to " .. ItemToFullString(Out) .. + " in " .. NumTicks .. " ticks (" .. + tostring(NumTicks / 20) .. " seconds)." + ); + else + a_Player:SendMessage("There is no furnace recipe that would smelt " .. ItemToString(HeldItem)); + end + return true; +end + + + + -- cgit v1.2.3 From 7fd3fda5d3c0274e47c20ed5f05346e30f1d11e2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 12:37:55 +0100 Subject: APIDump: Documented new cRoot:GetFurnaceRecipe(). --- MCServer/Plugins/APIDump/APIDesc.lua | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f8fab9afc..f91d46f52 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2046,7 +2046,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature:
    function Callback({{cWorld|cWorld}})
    " }, GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" }, GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." }, - GetFurnaceRecipe = { Params = "", Return = "{{cFurnaceRecipe|cFurnaceRecipe}}", Notes = "Returns the cFurnaceRecipes object." }, + GetFurnaceRecipe = { Params = "{{cItem|InItem}}", Return = "{{cItem|OutItem}}, NumTicks, {{cItem|InItem}}", Notes = "(STATIC) Returns the furnace recipe for smelting the specified input. If a recipe is found, returns the smelted result, the number of ticks required for the smelting operation, and the input consumed (note that MCServer supports smelting M items into N items and different smelting rates). If no recipe is found, returns no value." }, GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object." }, GetPhysicalRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of physical RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetPluginManager = { Params = "", Return = "{{cPluginManager|cPluginManager}}", Notes = "Returns the cPluginManager object." }, @@ -2064,7 +2064,32 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Constants = { }, - }, + AdditionalInfo = + { + { + Header = "Querying a furnace recipe", + Contents = [[ + To find the furnace recipe for an item, use the following code (adapted from the Debuggers plugin's /fr command): +
    +local HeldItem = a_Player:GetEquippedItem();
    +local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem);  -- Note STATIC call - using the dot operator instead of a colon
    +if (Out ~= nil) then
    +	-- There is a recipe, list it:
    +	a_Player:SendMessage(
    +		"Furnace turns " .. ItemToFullString(In) ..
    +		" to " .. ItemToFullString(Out) ..
    +		" in " .. NumTicks .. " ticks (" ..
    +		tostring(NumTicks / 20) .. " seconds)."
    +	);
    +else
    +	-- No recipe found
    +	a_Player:SendMessage("There is no furnace recipe that would smelt " .. ItemToString(HeldItem));
    +end
    +
    + ]], + }, + }, + }, -- cRoot cServer = { -- cgit v1.2.3 From 281bf8f90bbd295bb81ec09889bcaeefa689e6b2 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 16:50:03 +0100 Subject: Added cRoot:GetFurnaceFuelBurnTime() to Lua API. --- MCServer/Plugins/Debuggers/Debuggers.lua | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index e4c601da3..682a54676 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -49,6 +49,7 @@ function Initialize(Plugin) PM:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); PM:BindCommand("/fill", "debuggers", HandleFill, "- Fills all block entities in current chunk with junk"); PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); + PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -907,7 +908,7 @@ end function HandleFurnaceRecipe(a_Split, a_Player) local HeldItem = a_Player:GetEquippedItem(); - local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem); + local Out, NumTicks, In = cRoot:GetFurnaceRecipe(HeldItem); if (Out ~= nil) then a_Player:SendMessage( "Furnace turns " .. ItemToFullString(In) .. @@ -924,3 +925,21 @@ end + +function HandleFurnaceFuel(a_Split, a_Player) + local HeldItem = a_Player:GetEquippedItem(); + local NumTicks = cRoot:GetFurnaceFuelBurnTime(HeldItem); + if (NumTicks > 0) then + a_Player:SendMessage( + ItemToFullString(HeldItem) .. " would power a furnace for " .. NumTicks .. + " ticks (" .. tostring(NumTicks / 20) .. " seconds)." + ); + else + a_Player:SendMessage(ItemToString(HeldItem) .. " will not power furnaces."); + end + return true; +end + + + + -- cgit v1.2.3 From 4fbfe59ea01d7e622531b7cb3009cd36e595708f Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 16:52:09 +0100 Subject: APIDump: Fixed cRoot's furnace query API. --- MCServer/Plugins/APIDump/APIDesc.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index f91d46f52..11b0aeff7 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2046,6 +2046,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); ForEachWorld = { Params = "CallbackFunction", Return = "", Notes = "Calls the given callback function for each world. The callback function has the following signature:
    function Callback({{cWorld|cWorld}})
    " }, GetCraftingRecipes = { Params = "", Return = "{{cCraftingRecipe|cCraftingRecipe}}", Notes = "Returns the CraftingRecipes object" }, GetDefaultWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world object from the default world." }, + GetFurnaceFuelBurnTime = { Params = "{{cItem|Fuel}}", Return = "number", Notes = "(STATIC) Returns the number of ticks for how long the item would fuel a furnace. Returns zero if not a fuel." }, GetFurnaceRecipe = { Params = "{{cItem|InItem}}", Return = "{{cItem|OutItem}}, NumTicks, {{cItem|InItem}}", Notes = "(STATIC) Returns the furnace recipe for smelting the specified input. If a recipe is found, returns the smelted result, the number of ticks required for the smelting operation, and the input consumed (note that MCServer supports smelting M items into N items and different smelting rates). If no recipe is found, returns no value." }, GetGroupManager = { Params = "", Return = "{{cGroupManager|cGroupManager}}", Notes = "Returns the cGroupManager object." }, GetPhysicalRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of physical RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, @@ -2072,7 +2073,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); To find the furnace recipe for an item, use the following code (adapted from the Debuggers plugin's /fr command):
     local HeldItem = a_Player:GetEquippedItem();
    -local Out, NumTicks, In = cRoot.GetFurnaceRecipe(HeldItem);  -- Note STATIC call - using the dot operator instead of a colon
    +local Out, NumTicks, In = cRoot:GetFurnaceRecipe(HeldItem);  -- Note STATIC call - no need for a Get()
     if (Out ~= nil) then
     	-- There is a recipe, list it:
     	a_Player:SendMessage(
    @@ -4317,6 +4318,7 @@ end
     		"Globals.assert",
     		"Globals.collectgarbage",
     		"Globals.xpcall",
    +		"Globals.decoda_output",  -- When running under Decoda, this function gets added to the global namespace
     		"%a+\.__%a+",        -- AnyClass.__Anything
     		"%a+\.\.collector",  -- AnyClass..collector
     		"%a+\.new",          -- AnyClass.new
    -- 
    cgit v1.2.3
    
    
    From 63753c5e8405837931510b8da648dc75d4970fe1 Mon Sep 17 00:00:00 2001
    From: madmaxoft 
    Date: Fri, 22 Nov 2013 20:11:24 +0100
    Subject: Added cFile:GetFolderContents().
    
    Fix 162.
    ---
     MCServer/Plugins/APIDump/APIDesc.lua     | 21 +++++++++++----------
     MCServer/Plugins/Debuggers/Debuggers.lua | 11 +++++++++++
     2 files changed, 22 insertions(+), 10 deletions(-)
    
    (limited to 'MCServer/Plugins')
    
    diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
    index 11b0aeff7..8591d9aa4 100644
    --- a/MCServer/Plugins/APIDump/APIDesc.lua
    +++ b/MCServer/Plugins/APIDump/APIDesc.lua
    @@ -927,22 +927,23 @@ end
     		cFile =
     		{
     			Desc = [[
    -				Provides helper functions for manipulating and querying the filesystem. Most functions are called
    -				directly on the cFile class itself:
    +				Provides helper functions for manipulating and querying the filesystem. Most functions are static,
    +				so they should be called directly on the cFile class itself:
     
     cFile:Delete("/usr/bin/virus.exe");
     

    ]], Functions = { - Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, - CreateFolder = { Params = "FolderName", Return = "bool", Notes = "Creates a new folder. Returns true if successful." }, - Delete = { Params = "FileName", Return = "bool", Notes = "Deletes the specified file. Returns true if successful." }, - Exists = { Params = "FileName", Return = "bool", Notes = "Returns true if the specified file exists." }, - GetSize = { Params = "FileName", Return = "number", Notes = "Returns the size of the file, or -1 on failure." }, - IsFile = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing file." }, - IsFolder = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing folder." }, - Rename = { Params = "OrigPath, NewPath", Return = "bool", Notes = "Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists." }, + Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "(STATIC) Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, + CreateFolder = { Params = "FolderName", Return = "bool", Notes = "(STATIC) Creates a new folder. Returns true if successful." }, + Delete = { Params = "FileName", Return = "bool", Notes = "(STATIC) Deletes the specified file. Returns true if successful." }, + Exists = { Params = "FileName", Return = "bool", Notes = "(STATIC) Returns true if the specified file exists." }, + GetFolderContents = { Params = "FolderName", Return = "array table of strings", Notes = "(STATIC) Returns the contents of the specified folder, as an array table of strings. Each filesystem object is listed. Use the IsFile() and IsFolder() functions to determine the object type." }, + GetSize = { Params = "FileName", Return = "number", Notes = "(STATIC) Returns the size of the file, or -1 on failure." }, + IsFile = { Params = "Path", Return = "bool", Notes = "(STATIC) Returns true if the specified path points to an existing file." }, + IsFolder = { Params = "Path", Return = "bool", Notes = "(STATIC) Returns true if the specified path points to an existing folder." }, + Rename = { Params = "OrigPath, NewPath", Return = "bool", Notes = "(STATIC) Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists." }, }, }, -- cFile diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 682a54676..c9a610f71 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -51,6 +51,8 @@ function Initialize(Plugin) PM:BindCommand("/fr", "debuggers", HandleFurnaceRecipe, "- Shows the furnace recipe for the currently held item"); PM:BindCommand("/ff", "debuggers", HandleFurnaceFuel, "- Shows how long the currently held item would burn in a furnace"); + Plugin:AddWebTab("Debuggers", HandleRequest_Debuggers); + -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -943,3 +945,12 @@ end + +function HandleRequest_Debuggers(a_Request) + local FolderContents = cFile:GetFolderContents("./"); + return "

    The following objects have been returned by cFile:GetFolderContents():

    • " .. table.concat(FolderContents, "
    • ") .. "

    "; +end + + + + -- cgit v1.2.3 From 7a2170f6b323c4ff1a974699ae3d2e43601d94ad Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 21:46:06 +0100 Subject: APIDump: Implemented constant groups. Fix #289. --- MCServer/Plugins/APIDump/APIDesc.lua | 62 +- MCServer/Plugins/APIDump/main.lua | 1247 --------------------------- MCServer/Plugins/APIDump/main_APIDump.lua | 1315 +++++++++++++++++++++++++++++ 3 files changed, 1375 insertions(+), 1249 deletions(-) delete mode 100644 MCServer/Plugins/APIDump/main.lua create mode 100644 MCServer/Plugins/APIDump/main_APIDump.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8591d9aa4..5489650ad 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -30,6 +30,17 @@ g_APIDesc = { ConstantName = { Notes = "Notes about the constant" }, } , + + ConstantGroups = + { + GroupName1 = -- GroupName1 is used as the HTML anchor name + { + Include = {"constant1", "constant2", "const_.*"}, -- Constants to include in this group, array of identifiers, accepts wildcards + TextBefore = "This text will be written in front of the constant list", + TextAfter = "This text will be written after the constant list", + ShowInDescendants = false, -- If false, descendant classes won't list these constants + } + }, Variables = { @@ -75,6 +86,18 @@ g_APIDesc = psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" }, psNoPickup = { Notes = "The arrow cannot be picked up at all" }, }, + + ConstantGroups = + { + PickupState = + { + Include = "ps.*", + TextBefore = [[ + The following constants are used to signalize whether the arrow, once it lands, can be picked by + players: + ]], + }, + }, Inherits = "cProjectileEntity", }, @@ -182,7 +205,25 @@ g_APIDesc = msImprint = { Notes = "Src overwrites Dst anywhere where Dst has non-air blocks" }, msLake = { Notes = "Special mode for merging lake images" }, }, - + ConstantGroups = + { + BATypes = + { + Include = "ba.*", + TextBefore = [[ + The following constants are used to signalize the datatype to read or write: + ]], + }, + MergeStrategies = + { + Include = "ms.*", + TextBefore = [[ + The Merge() function can use different strategies to combine the source and destination blocks. + The following constants are used: + ]], + TextAfter = "See below for a detailed explanation of the individual merge strategies.", + }, + }, AdditionalInfo = { { @@ -817,7 +858,7 @@ end GetChunkZ = { Params = "", Return = "number", Notes = "Returns the Z-coord of the chunk in which the entity is placed" }, GetClass = { Params = "", Return = "string", Notes = "Returns the classname of the entity, such as \"cSpider\" or \"cPickup\"" }, GetClassStatic = { Params = "", Return = "string", Notes = "Returns the entity classname that this class implements. Each descendant overrides this function. Is static" }, - GetEntityType = { Params = "", Return = "eEntityType", Notes = "Returns the type of the entity, one of the etXXX constants. Note that to check specific entity type, you should use one of the IsXXX functions instead of comparing the value returned by this call." }, + GetEntityType = { Params = "", Return = "{{cEntity#EntityType|EntityType}}", Notes = "Returns the type of the entity, one of the {{cEntity#EntityType|etXXX}} constants. Note that to check specific entity type, you should use one of the IsXXX functions instead of comparing the value returned by this call." }, GetEquippedBoots = { Params = "", Return = "{{cItem}}", Notes = "Returns the boots that the entity has equipped. Returns an empty cItem if no boots equipped or not applicable." }, GetEquippedChestplate = { Params = "", Return = "{{cItem}}", Notes = "Returns the chestplate that the entity has equipped. Returns an empty cItem if no chestplate equipped or not applicable." }, GetEquippedHelmet = { Params = "", Return = "{{cItem}}", Notes = "Returns the helmet that the entity has equipped. Returns an empty cItem if no helmet equipped or not applicable." }, @@ -922,6 +963,14 @@ end etProjectile = { Notes = "The entity is a {{cProjectileEntity}} descendant" }, etTNT = { Notes = "The entity is a {{cTNTEntity}}" }, }, + ConstantGroups = + { + EntityType = + { + Include = "et.*", + TextBefore = "The following constants are used to distinguish between different entity types:", + }, + }, }, cFile = @@ -2018,12 +2067,21 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" }, pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" }, pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" }, + pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" }, pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" }, pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" }, pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" }, pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" }, pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" }, }, + ConstantGroups = + { + ProjectileKind = + { + Include = "pk.*", + TextBefore = "The following constants are used to distinguish between the different projectile kinds:", + }, + }, Inherits = "cEntity", }, diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua deleted file mode 100644 index fa9d29423..000000000 --- a/MCServer/Plugins/APIDump/main.lua +++ /dev/null @@ -1,1247 +0,0 @@ - --- main.lua - --- Implements the plugin entrypoint (in this case the entire plugin) - - - - - --- Global variables: -g_Plugin = nil; -g_PluginFolder = ""; -g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames. -g_Stats = -- Statistics about the documentation -{ - NumTotalClasses = 0, - NumUndocumentedClasses = 0, - NumTotalFunctions = 0, - NumUndocumentedFunctions = 0, - NumTotalConstants = 0, - NumUndocumentedConstants = 0, - NumTotalVariables = 0, - NumUndocumentedVariables = 0, - NumTotalHooks = 0, - NumUndocumentedHooks = 0, - NumTrackedLinks = 0, - NumInvalidLinks = 0, -} - - - - - - -function Initialize(Plugin) - g_Plugin = Plugin; - - Plugin:SetName("APIDump"); - Plugin:SetVersion(1); - - LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) - - g_PluginFolder = Plugin:GetLocalFolder(); - - -- dump all available API functions and objects: - -- DumpAPITxt(); - - -- Dump all available API object in HTML format into a subfolder: - DumpAPIHtml(); - - return true -end - - - - - -function DumpAPITxt() - LOG("Dumping all available functions to API.txt..."); - function dump (prefix, a, Output) - for i, v in pairs (a) do - if (type(v) == "table") then - if (GetChar(i, 1) ~= ".") then - if (v == _G) then - -- LOG(prefix .. i .. " == _G, CYCLE, ignoring"); - elseif (v == _G.package) then - -- LOG(prefix .. i .. " == _G.package, ignoring"); - else - dump(prefix .. i .. ".", v, Output) - end - end - elseif (type(v) == "function") then - if (string.sub(i, 1, 2) ~= "__") then - table.insert(Output, prefix .. i .. "()"); - end - end - end - end - - local Output = {}; - dump("", _G, Output); - - table.sort(Output); - local f = io.open("API.txt", "w"); - for i, n in ipairs(Output) do - f:write(n, "\n"); - end - f:close(); - LOG("API.txt written."); -end - - - - - -function CreateAPITables() - --[[ - We want an API table of the following shape: - local API = { - { - Name = "cCuboid", - Functions = { - {Name = "Sort"}, - {Name = "IsInside"} - }, - Constants = { - }, - Variables = { - }, - Descendants = {}, -- Will be filled by ReadDescriptions(), array of class APIs (references to other member in the tree) - }}, - { - Name = "cBlockArea", - Functions = { - {Name = "Clear"}, - {Name = "CopyFrom"}, - ... - }, - Constants = { - {Name = "baTypes", Value = 0}, - {Name = "baMetas", Value = 1}, - ... - }, - Variables = { - }, - ... - }} - }; - local Globals = { - Functions = { - ... - }, - Constants = { - ... - } - }; - --]] - - local Globals = {Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; - local API = {}; - - local function Add(a_APIContainer, a_ObjName, a_ObjValue) - if (type(a_ObjValue) == "function") then - table.insert(a_APIContainer.Functions, {Name = a_ObjName}); - elseif ( - (type(a_ObjValue) == "number") or - (type(a_ObjValue) == "string") - ) then - table.insert(a_APIContainer.Constants, {Name = a_ObjName, Value = a_ObjValue}); - end - end - - local function ParseClass(a_ClassName, a_ClassObj) - local res = {Name = a_ClassName, Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; - -- Add functions and constants: - for i, v in pairs(a_ClassObj) do - Add(res, i, v); - end - - -- Member variables: - local SetField = a_ClassObj[".set"] or {}; - if ((a_ClassObj[".get"] ~= nil) and (type(a_ClassObj[".get"]) == "table")) then - for k, v in pairs(a_ClassObj[".get"]) do - if (SetField[k] == nil) then - -- It is a read-only variable, add it as a constant: - table.insert(res.Constants, {Name = k, Value = ""}); - else - -- It is a read-write variable, add it as a variable: - table.insert(res.Variables, { Name = k }); - end - end - end - return res; - end - - for i, v in pairs(_G) do - if ( - (v ~= _G) and -- don't want the global namespace - (v ~= _G.packages) and -- don't want any packages - (v ~= _G[".get"]) and - (v ~= g_APIDesc) - ) then - if (type(v) == "table") then - table.insert(API, ParseClass(i, v)); - else - Add(Globals, i, v); - end - end - end - - return API, Globals; -end - - - - - -function DumpAPIHtml() - LOG("Dumping all available functions and constants to API subfolder..."); - - LOG("Creating API tables..."); - local API, Globals = CreateAPITables(); - local Hooks = {}; - local UndocumentedHooks = {}; - - -- Sort the classes by name: - LOG("Sorting..."); - table.sort(API, - function (c1, c2) - return (string.lower(c1.Name) < string.lower(c2.Name)); - end - ); - - g_Stats.NumTotalClasses = #API; - - -- Add Globals into the API: - Globals.Name = "Globals"; - table.insert(API, Globals); - - -- Extract hook constants: - for name, obj in pairs(cPluginManager) do - if ( - (type(obj) == "number") and - name:match("HOOK_.*") and - (name ~= "HOOK_MAX") and - (name ~= "HOOK_NUM_HOOKS") - ) then - table.insert(Hooks, { Name = name }); - end - end - table.sort(Hooks, - function(Hook1, Hook2) - return (Hook1.Name < Hook2.Name); - end - ); - - -- Read in the descriptions: - LOG("Reading descriptions..."); - ReadDescriptions(API); - ReadHooks(Hooks); - - -- Create the output folder - if not(cFile:IsFolder("API")) then - cFile:CreateFolder("API"); - end - - -- Create a "class index" file, write each class as a link to that file, - -- then dump class contents into class-specific file - LOG("Writing HTML files..."); - local f = io.open("API/index.html", "w"); - if (f == nil) then - LOGINFO("Cannot output HTML API: " .. err); - return; - end - - f:write([[ - - - MCServer API - Index - - - -
    -
    -

    MCServer API - Index

    -
    -
    -

    The API reference is divided into the following sections:

    - - - -
    -

    Class index

    -

    The following classes are available in the MCServer Lua scripting language:

    - -
      -]]); - for i, cls in ipairs(API) do - f:write("
    • " .. cls.Name .. "
    • \n"); - WriteHtmlClass(cls, API); - end - f:write([[
    - -
    -

    Hooks

    - -

    A plugin can register to be called whenever an "interesting event" occurs. It does so by calling cPluginManager's AddHook() function and implementing a callback function to handle the event.

    -

    A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it from them. This is determined by the return value from the hook callback function. If the function returns false or no value, the event is propagated further. If the function returns true, the processing is stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior for the event). See each hook's details to see the exact behavior.

    - - - - - - -]]); - for i, hook in ipairs(Hooks) do - if (hook.DefaultFnName == nil) then - -- The hook is not documented yet - f:write(" \n \n \n \n"); - table.insert(UndocumentedHooks, hook.Name); - else - f:write(" \n \n \n \n"); - WriteHtmlHook(hook); - end - end - f:write([[
    Hook nameCalled when
    " .. hook.Name .. "(No documentation yet)
    " .. hook.Name .. "" .. LinkifyString(hook.CalledWhen, hook.Name) .. "
    - -
    -

    Extra pages

    - -

    The following pages provide various extra information

    - -
      -]]); - for i, extra in ipairs(g_APIDesc.ExtraPages) do - local SrcFileName = g_PluginFolder .. "/" .. extra.FileName; - if (cFile:Exists(SrcFileName)) then - local DstFileName = "API/" .. extra.FileName; - if (cFile:Exists(DstFileName)) then - cFile:Delete(DstFileName); - end - cFile:Copy(SrcFileName, DstFileName); - f:write("
    • " .. extra.Title .. "
    • \n"); - else - f:write("
    • " .. extra.Title .. " (file is missing)
    • \n"); - end - end - f:write("
    "); - - -- Copy the static files to the output folder (overwrite any existing): - cFile:Copy(g_Plugin:GetLocalFolder() .. "/main.css", "API/main.css"); - cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.js", "API/prettify.js"); - cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.css", "API/prettify.css"); - cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); - - -- List the documentation problems: - LOG("Listing leftovers..."); - ListUndocumentedObjects(API, UndocumentedHooks); - ListUnexportedObjects(); - ListMissingPages(); - - WriteStats(f); - - f:write([[ -
    - -]]); - f:close(); - - LOG("API subfolder written"); -end - - - - - -function ReadDescriptions(a_API) - -- Returns true if the class of the specified name is to be ignored - local function IsClassIgnored(a_ClsName) - if (g_APIDesc.IgnoreClasses == nil) then - return false; - end - for i, name in ipairs(g_APIDesc.IgnoreClasses) do - if (a_ClsName:match(name)) then - return true; - end - end - return false; - end - - -- Returns true if the function is to be ignored - local function IsFunctionIgnored(a_ClassName, a_FnName) - if (g_APIDesc.IgnoreFunctions == nil) then - return false; - end - if (((g_APIDesc.Classes[a_ClassName] or {}).Functions or {})[a_FnName] ~= nil) then - -- The function is documented, don't ignore - return false; - end - local FnName = a_ClassName .. "." .. a_FnName; - for i, name in ipairs(g_APIDesc.IgnoreFunctions) do - if (FnName:match(name)) then - return true; - end - end - return false; - end - - -- Returns true if the constant (specified by its fully qualified name) is to be ignored - local function IsConstantIgnored(a_CnName) - if (g_APIDesc.IgnoreConstants == nil) then - return false; - end; - for i, name in ipairs(g_APIDesc.IgnoreConstants) do - if (a_CnName:match(name)) then - return true; - end - end - return false; - end - - -- Returns true if the member variable (specified by its fully qualified name) is to be ignored - local function IsVariableIgnored(a_VarName) - if (g_APIDesc.IgnoreVariables == nil) then - return false; - end; - for i, name in ipairs(g_APIDesc.IgnoreVariables) do - if (a_VarName:match(name)) then - return true; - end - end - return false; - end - - -- Remove ignored classes from a_API: - local APICopy = {}; - for i, cls in ipairs(a_API) do - if not(IsClassIgnored(cls.Name)) then - table.insert(APICopy, cls); - end - end - for i = 1, #a_API do - a_API[i] = APICopy[i]; - end; - - -- Process the documentation for each class: - for i, cls in ipairs(a_API) do - -- Rename special functions: - for j, fn in ipairs(cls.Functions) do - if (fn.Name == ".call") then - fn.DocID = "constructor"; - fn.Name = "() (constructor)"; - elseif (fn.Name == ".add") then - fn.DocID = "operator_plus"; - fn.Name = "operator +"; - elseif (fn.Name == ".div") then - fn.DocID = "operator_div"; - fn.Name = "operator /"; - elseif (fn.Name == ".mul") then - fn.DocID = "operator_mul"; - fn.Name = "operator *"; - elseif (fn.Name == ".sub") then - fn.DocID = "operator_sub"; - fn.Name = "operator -"; - elseif (fn.Name == ".eq") then - fn.DocID = "operator_eq"; - fn.Name = "operator =="; - end - end - - local APIDesc = g_APIDesc.Classes[cls.Name]; - if (APIDesc ~= nil) then - APIDesc.IsExported = true; - cls.Desc = APIDesc.Desc; - cls.AdditionalInfo = APIDesc.AdditionalInfo; - - -- Process inheritance: - if (APIDesc.Inherits ~= nil) then - for j, icls in ipairs(a_API) do - if (icls.Name == APIDesc.Inherits) then - table.insert(icls.Descendants, cls); - cls.Inherits = icls; - end - end - end - - cls.UndocumentedFunctions = {}; -- This will contain names of all the functions that are not documented - cls.UndocumentedConstants = {}; -- This will contain names of all the constants that are not documented - cls.UndocumentedVariables = {}; -- This will contain names of all the variables that are not documented - - local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation - - local function AddFunction(a_Name, a_Params, a_Return, a_Notes) - table.insert(DoxyFunctions, {Name = a_Name, Params = a_Params, Return = a_Return, Notes = a_Notes}); - end - - if (APIDesc.Functions ~= nil) then - -- Assign function descriptions: - for j, func in ipairs(cls.Functions) do - local FnName = func.DocID or func.Name; - local FnDesc = APIDesc.Functions[FnName]; - if (FnDesc == nil) then - -- No description for this API function - AddFunction(func.Name); - if not(IsFunctionIgnored(cls.Name, FnName)) then - table.insert(cls.UndocumentedFunctions, FnName); - end - else - -- Description is available - if (FnDesc[1] == nil) then - -- Single function definition - AddFunction(func.Name, FnDesc.Params, FnDesc.Return, FnDesc.Notes); - else - -- Multiple function overloads - for k, desc in ipairs(FnDesc) do - AddFunction(func.Name, desc.Params, desc.Return, desc.Notes); - end -- for k, desc - FnDesc[] - end - FnDesc.IsExported = true; - end - end -- for j, func - - -- Replace functions with their described and overload-expanded versions: - cls.Functions = DoxyFunctions; - else -- if (APIDesc.Functions ~= nil) - for j, func in ipairs(cls.Functions) do - local FnName = func.DocID or func.Name; - if not(IsFunctionIgnored(cls.Name, FnName)) then - table.insert(cls.UndocumentedFunctions, FnName); - end - end - end -- if (APIDesc.Functions ~= nil) - - if (APIDesc.Constants ~= nil) then - -- Assign constant descriptions: - for j, cons in ipairs(cls.Constants) do - local CnDesc = APIDesc.Constants[cons.Name]; - if (CnDesc == nil) then - -- Not documented - if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then - table.insert(cls.UndocumentedConstants, cons.Name); - end - else - cons.Notes = CnDesc.Notes; - CnDesc.IsExported = true; - end - end -- for j, cons - else -- if (APIDesc.Constants ~= nil) - for j, cons in ipairs(cls.Constants) do - if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then - table.insert(cls.UndocumentedConstants, cons.Name); - end - end - end -- else if (APIDesc.Constants ~= nil) - - -- Assign member variables' descriptions: - if (APIDesc.Variables ~= nil) then - for j, var in ipairs(cls.Variables) do - local VarDesc = APIDesc.Variables[var.Name]; - if (VarDesc == nil) then - -- Not documented - if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then - table.insert(cls.UndocumentedVariables, var.Name); - end - else - -- Copy all documentation: - for k, v in pairs(VarDesc) do - var[k] = v - end - end - end -- for j, var - else -- if (APIDesc.Variables ~= nil) - for j, var in ipairs(cls.Variables) do - if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then - table.insert(cls.UndocumentedVariables, var.Name); - end - end - end -- else if (APIDesc.Variables ~= nil) - - else -- if (APIDesc ~= nil) - - -- Class is not documented at all, add all its members to Undocumented lists: - cls.UndocumentedFunctions = {}; - cls.UndocumentedConstants = {}; - cls.UndocumentedVariables = {}; - cls.Variables = cls.Variables or {}; - g_Stats.NumUndocumentedClasses = g_Stats.NumUndocumentedClasses + 1; - for j, func in ipairs(cls.Functions) do - local FnName = func.DocID or func.Name; - if not(IsFunctionIgnored(cls.Name, FnName)) then - table.insert(cls.UndocumentedFunctions, FnName); - end - end -- for j, func - cls.Functions[] - for j, cons in ipairs(cls.Constants) do - if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then - table.insert(cls.UndocumentedConstants, cons.Name); - end - end -- for j, cons - cls.Constants[] - for j, var in ipairs(cls.Variables) do - if not(IsConstantIgnored(cls.Name .. "." .. var.Name)) then - table.insert(cls.UndocumentedVariables, var.Name); - end - end -- for j, var - cls.Variables[] - end -- else if (APIDesc ~= nil) - - -- Remove ignored functions: - local NewFunctions = {}; - for j, fn in ipairs(cls.Functions) do - if (not(IsFunctionIgnored(cls.Name, fn.Name))) then - table.insert(NewFunctions, fn); - end - end -- for j, fn - cls.Functions = NewFunctions; - - -- Sort the functions (they may have been renamed): - table.sort(cls.Functions, - function(f1, f2) - if (f1.Name == f2.Name) then - -- Same name, either comparing the same function to itself, or two overloads, in which case compare the params - if ((f1.Params == nil) or (f2.Params == nil)) then - return 0; - end - return (f1.Params < f2.Params); - end - return (f1.Name < f2.Name); - end - ); - - -- Sort the constants: - table.sort(cls.Constants, - function(c1, c2) - return (c1.Name < c2.Name); - end - ); - - -- Remove ignored functions: - local NewVariables = {}; - for j, var in ipairs(cls.Variables) do - if (not(IsVariableIgnored(cls.Name .. "." .. var.Name))) then - table.insert(NewVariables, var); - end - end -- for j, var - cls.Variables = NewVariables; - - -- Sort the member variables: - table.sort(cls.Variables, - function(v1, v2) - return (v1.Name < v2.Name); - end - ); - end -- for i, cls - - -- Sort the descendants lists: - for i, cls in ipairs(a_API) do - table.sort(cls.Descendants, - function(c1, c2) - return (c1.Name < c2.Name); - end - ); - end -- for i, cls -end - - - - - -function ReadHooks(a_Hooks) - --[[ - a_Hooks = { - { Name = "HOOK_1"}, - { Name = "HOOK_2"}, - ... - }; - We want to add hook descriptions to each hook in this array - --]] - for i, hook in ipairs(a_Hooks) do - local HookDesc = g_APIDesc.Hooks[hook.Name]; - if (HookDesc ~= nil) then - for key, val in pairs(HookDesc) do - hook[key] = val; - end - end - end -- for i, hook - a_Hooks[] - g_Stats.NumTotalHooks = #a_Hooks; -end - - - - - --- Make a link out of anything with the special linkifying syntax {{link|title}} -function LinkifyString(a_String, a_Referrer) - assert(a_Referrer ~= nil); - assert(a_Referrer ~= ""); - - --- Adds a page to the list of tracked pages (to be checked for existence at the end) - local function AddTrackedPage(a_PageName) - local Pg = (g_TrackedPages[a_PageName] or {}); - table.insert(Pg, a_Referrer); - g_TrackedPages[a_PageName] = Pg; - end - - --- Creates the HTML for the specified link and title - local function CreateLink(Link, Title) - if (Link:sub(1, 7) == "http://") then - -- The link is a full absolute URL, do not modify, do not track: - return "" .. Title .. ""; - end - local idxHash = Link:find("#"); - if (idxHash ~= nil) then - -- The link contains an anchor: - if (idxHash == 1) then - -- Anchor in the current page, no need to track: - return "" .. Title .. ""; - end - -- Anchor in another page: - local PageName = Link:sub(1, idxHash - 1); - AddTrackedPage(PageName); - return "" .. Title .. ""; - end - -- Link without anchor: - AddTrackedPage(Link); - return "" .. Title .. ""; - end - - -- Linkify the strings using the CreateLink() function: - local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", CreateLink) -- {{link|title}} - txt = txt:gsub("{{([^|}]*)}}", -- {{LinkAndTitle}} - function(LinkAndTitle) - local idxHash = LinkAndTitle:find("#"); - if (idxHash ~= nil) then - -- The LinkAndTitle contains a hash, remove the hashed part from the title: - return CreateLink(LinkAndTitle, LinkAndTitle:sub(1, idxHash - 1)); - end - return CreateLink(LinkAndTitle, LinkAndTitle); - end - ); - return txt; -end - - - - - -function WriteHtmlClass(a_ClassAPI, a_AllAPI) - local cf, err = io.open("API/" .. a_ClassAPI.Name .. ".html", "w"); - if (cf == nil) then - return; - end - - -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid - local function WriteFunctions(a_Functions, a_InheritedName) - if (#a_Functions == 0) then - return; - end - - if (a_InheritedName ~= nil) then - cf:write("

    Functions inherited from ", a_InheritedName, "

    \n"); - end - cf:write(" \n \n \n \n \n \n \n"); - for i, func in ipairs(a_Functions) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n"); - cf:write(" \n \n"); - end - cf:write("
    NameParametersReturn valueNotes
    " .. func.Name .. "", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), "
    \n\n"); - end - - local function WriteConstants(a_Constants, a_InheritedName) - if (#a_Constants == 0) then - return; - end - - if (a_InheritedName ~= nil) then - cf:write("

    Constants inherited from ", a_InheritedName, "

    \n"); - end - - cf:write(" \n \n \n \n \n \n"); - for i, cons in ipairs(a_Constants) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); - end - cf:write("
    NameValueNotes
    ", cons.Name, "", cons.Value, "", LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name), "
    \n\n"); - end - - local function WriteVariables(a_Variables, a_InheritedName) - if (#a_Variables == 0) then - return; - end - - if (a_InheritedName ~= nil) then - cf:write("

    Member variables inherited from ", a_InheritedName, "

    \n"); - end - - cf:write(" \n \n \n \n \n \n"); - for i, var in ipairs(a_Variables) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); - end - cf:write("
    NameTypeNotes
    ", var.Name, "", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), "", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "
    \n\n"); - end - - local function WriteDescendants(a_Descendants) - if (#a_Descendants == 0) then - return; - end - cf:write("
      "); - for i, desc in ipairs(a_Descendants) do - cf:write("
    • ", desc.Name, ""); - WriteDescendants(desc.Descendants); - cf:write("
    • \n"); - end - cf:write("
    \n"); - end - - local ClassName = a_ClassAPI.Name; - - -- Build an array of inherited classes chain: - local InheritanceChain = {}; - local CurrInheritance = a_ClassAPI.Inherits; - while (CurrInheritance ~= nil) do - table.insert(InheritanceChain, CurrInheritance); - CurrInheritance = CurrInheritance.Inherits; - end - - cf:write([[ - - - MCServer API - ]], a_ClassAPI.Name, [[ Class - - - - - - -
    -
    -

    ]], a_ClassAPI.Name, [[

    -
    -
    -

    Contents

    - -
      -]]); - - local HasInheritance = ((#a_ClassAPI.Descendants > 0) or (a_ClassAPI.Inherits ~= nil)); - - local HasConstants = (#a_ClassAPI.Constants > 0); - local HasFunctions = (#a_ClassAPI.Functions > 0); - local HasVariables = (#a_ClassAPI.Variables > 0); - for idx, cls in ipairs(InheritanceChain) do - HasConstants = HasConstants or (#cls.Constants > 0); - HasFunctions = HasFunctions or (#cls.Functions > 0); - HasVariables = HasVariables or (#cls.Variables > 0); - end - - -- Write the table of contents: - if (HasInheritance) then - cf:write("
    • Inheritance
    • \n"); - end - if (HasConstants) then - cf:write("
    • Constants
    • \n"); - end - if (HasVariables) then - cf:write("
    • Member variables
    • \n"); - end - if (HasFunctions) then - cf:write("
    • Functions
    • \n"); - end - if (a_ClassAPI.AdditionalInfo ~= nil) then - for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("
    • ", (additional.Header or "(No header)"), "
    • \n"); - end - end - cf:write("
    \n\n"); - - -- Write the class description: - cf:write("

    " .. ClassName .. " class

    \n"); - if (a_ClassAPI.Desc ~= nil) then - cf:write("

    "); - cf:write(LinkifyString(a_ClassAPI.Desc, ClassName)); - cf:write("

    \n\n"); - end; - - -- Write the inheritance, if available: - if (HasInheritance) then - cf:write(" \n

    Inheritance

    \n"); - if (#InheritanceChain > 0) then - cf:write("

    This class inherits from the following parent classes:

    \n\n
      \n"); - for i, cls in ipairs(InheritanceChain) do - cf:write("
    • " .. cls.Name .. "
    • \n"); - end - cf:write("
    \n\n"); - end - if (#a_ClassAPI.Descendants > 0) then - cf:write("

    This class has the following descendants:\n"); - WriteDescendants(a_ClassAPI.Descendants); - cf:write("

    \n\n"); - end - end - - -- Write the constants: - if (HasConstants) then - cf:write("

    Constants

    \n"); - WriteConstants(a_ClassAPI.Constants, nil); - g_Stats.NumTotalConstants = g_Stats.NumTotalConstants + #a_ClassAPI.Constants; - for i, cls in ipairs(InheritanceChain) do - WriteConstants(cls.Constants, cls.Name); - end; - end; - - -- Write the member variables: - if (HasVariables) then - cf:write("

    Member variables

    \n"); - WriteVariables(a_ClassAPI.Variables, nil); - g_Stats.NumTotalVariables = g_Stats.NumTotalVariables + #a_ClassAPI.Variables; - for i, cls in ipairs(InheritanceChain) do - WriteVariables(cls.Variables, cls.Name); - end; - end - - -- Write the functions, including the inherited ones: - if (HasFunctions) then - cf:write("

    Functions

    \n"); - WriteFunctions(a_ClassAPI.Functions, nil); - g_Stats.NumTotalFunctions = g_Stats.NumTotalFunctions + #a_ClassAPI.Functions; - for i, cls in ipairs(InheritanceChain) do - WriteFunctions(cls.Functions, cls.Name); - end - end - - -- Write the additional infos: - if (a_ClassAPI.AdditionalInfo ~= nil) then - for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("

    ", additional.Header, "

    \n"); - cf:write(LinkifyString(additional.Contents, ClassName)); - end - end - - cf:write([[ -
    - - - - ]]); - cf:close(); -end - - - - - -function WriteHtmlHook(a_Hook) - local fnam = "API/" .. a_Hook.DefaultFnName .. ".html"; - local f, error = io.open(fnam, "w"); - if (f == nil) then - LOG("Cannot write \"" .. fnam .. "\": \"" .. error .. "\"."); - return; - end - local HookName = a_Hook.DefaultFnName; - - f:write([[ - - - MCServer API - ]] .. HookName .. [[ Hook - - - - - - -
    -
    -

    ]] .. a_Hook.Name .. [[

    -
    -
    -

    -]]); - f:write(LinkifyString(a_Hook.Desc, HookName)); - f:write("

    \n

    Callback function

    \n

    The default name for the callback function is "); - f:write(a_Hook.DefaultFnName .. ". It has the following signature:\n\n"); - f:write("

    function " .. HookName .. "(");
    -	if (a_Hook.Params == nil) then
    -		a_Hook.Params = {};
    -	end
    -	for i, param in ipairs(a_Hook.Params) do
    -		if (i > 1) then
    -			f:write(", ");
    -		end
    -		f:write(param.Name);
    -	end
    -	f:write(")
    \n\n

    Parameters:

    \n\n \n \n \n \n \n \n"); - for i, param in ipairs(a_Hook.Params) do - f:write(" \n \n \n \n \n"); - end - f:write("
    NameTypeNotes
    " .. param.Name .. "" .. LinkifyString(param.Type, HookName) .. "" .. LinkifyString(param.Notes, HookName) .. "
    \n\n

    " .. (a_Hook.Returns or "") .. "

    \n\n"); - f:write([[

    Code examples

    -

    Registering the callback

    - -]]); - f:write("
    \n");
    -	f:write([[cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);]]);
    -	f:write("
    \n\n"); - local Examples = a_Hook.CodeExamples or {}; - for i, example in ipairs(Examples) do - f:write("

    " .. (example.Title or "missing Title") .. "

    \n"); - f:write("

    " .. (example.Desc or "missing Desc") .. "

    \n\n"); - f:write("
    " .. (example.Code or "missing Code") .. "\n			
    \n\n"); - end - f:write([[
    - - -]]); - f:close(); -end - - - - - ---- Writes a list of undocumented objects into a file -function ListUndocumentedObjects(API, UndocumentedHooks) - f = io.open("API/_undocumented.lua", "w"); - if (f ~= nil) then - f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); - f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); - for i, cls in ipairs(API) do - local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); - local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); - local HasVariables = ((cls.UndocumentedVariables ~= nil) and (#cls.UndocumentedVariables > 0)); - g_Stats.NumUndocumentedFunctions = g_Stats.NumUndocumentedFunctions + #cls.UndocumentedFunctions; - g_Stats.NumUndocumentedConstants = g_Stats.NumUndocumentedConstants + #cls.UndocumentedConstants; - g_Stats.NumUndocumentedVariables = g_Stats.NumUndocumentedVariables + #cls.UndocumentedVariables; - if (HasFunctions or HasConstants or HasVariables) then - f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); - if ((cls.Desc == nil) or (cls.Desc == "")) then - f:write("\t\t\tDesc = \"\"\n"); - end - end - - if (HasFunctions) then - f:write("\t\t\tFunctions =\n\t\t\t{\n"); - table.sort(cls.UndocumentedFunctions); - for j, fn in ipairs(cls.UndocumentedFunctions) do - f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); - end -- for j, fn - cls.UndocumentedFunctions[] - f:write("\t\t\t},\n\n"); - end - - if (HasConstants) then - f:write("\t\t\tConstants =\n\t\t\t{\n"); - table.sort(cls.UndocumentedConstants); - for j, cn in ipairs(cls.UndocumentedConstants) do - f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); - end -- for j, fn - cls.UndocumentedConstants[] - f:write("\t\t\t},\n\n"); - end - - if (HasVariables) then - f:write("\t\t\tVariables =\n\t\t\t{\n"); - table.sort(cls.UndocumentedVariables); - for j, vn in ipairs(cls.UndocumentedVariables) do - f:write("\t\t\t\t" .. vn .. " = { Type = \"\", Notes = \"\" },\n"); - end -- for j, fn - cls.UndocumentedVariables[] - f:write("\t\t\t},\n\n"); - end - - if (HasFunctions or HasConstants or HasVariables) then - f:write("\t\t},\n\n"); - end - end -- for i, cls - API[] - f:write("\t},\n"); - - if (#UndocumentedHooks > 0) then - f:write("\n\tHooks =\n\t{\n"); - for i, hook in ipairs(UndocumentedHooks) do - if (i > 1) then - f:write("\n"); - end - f:write("\t\t" .. hook .. " =\n\t\t{\n"); - f:write("\t\t\tCalledWhen = \"\",\n"); - f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); - f:write("\t\t\tDesc = [[\n\t\t\t\t\n\t\t\t]],\n"); - f:write("\t\t\tParams =\n\t\t\t{\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); - f:write("\t\t\t},\n"); - f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); - f:write("\t\t}, -- " .. hook .. "\n"); - end - f:write("\t},\n"); - end - f:write("}\n\n\n\n"); - f:close(); - end - g_Stats.NumUndocumentedHooks = #UndocumentedHooks; -end - - - - - ---- Lists the API objects that are documented but not available in the API: -function ListUnexportedObjects() - f = io.open("API/_unexported-documented.txt", "w"); - if (f ~= nil) then - for clsname, cls in pairs(g_APIDesc.Classes) do - if not(cls.IsExported) then - -- The whole class is not exported - f:write("class\t" .. clsname .. "\n"); - else - if (cls.Functions ~= nil) then - for fnname, fnapi in pairs(cls.Functions) do - if not(fnapi.IsExported) then - f:write("func\t" .. clsname .. "." .. fnname .. "\n"); - end - end -- for j, fn - cls.Functions[] - end - if (cls.Constants ~= nil) then - for cnname, cnapi in pairs(cls.Constants) do - if not(cnapi.IsExported) then - f:write("const\t" .. clsname .. "." .. cnname .. "\n"); - end - end -- for j, fn - cls.Functions[] - end - end - end -- for i, cls - g_APIDesc.Classes[] - f:close(); - end -end - - - - - -function ListMissingPages() - local MissingPages = {}; - local NumLinks = 0; - for PageName, Referrers in pairs(g_TrackedPages) do - NumLinks = NumLinks + 1; - if not(cFile:Exists("API/" .. PageName .. ".html")) then - table.insert(MissingPages, {Name = PageName, Refs = Referrers} ); - end - end; - g_Stats.NumTrackedLinks = NumLinks; - g_TrackedPages = {}; - - if (#MissingPages == 0) then - -- No missing pages, congratulations! - return; - end - - -- Sort the pages by name: - table.sort(MissingPages, - function (Page1, Page2) - return (Page1.Name < Page2.Name); - end - ); - - -- Output the pages: - local f, err = io.open("API/_missingPages.txt", "w"); - if (f == nil) then - LOGWARNING("Cannot open _missingPages.txt for writing: '" .. err .. "'. There are " .. #MissingPages .. " pages missing."); - return; - end - for idx, pg in ipairs(MissingPages) do - f:write(pg.Name .. ":\n"); - -- Sort and output the referrers: - table.sort(pg.Refs); - f:write("\t" .. table.concat(pg.Refs, "\n\t")); - f:write("\n\n"); - end - f:close(); - g_Stats.NumInvalidLinks = #MissingPages; -end - - - - - ---- Writes the documentation statistics (in g_Stats) into the given HTML file -function WriteStats(f) - local function ExportMeter(a_Percent) - local Color; - if (a_Percent > 95) then - Color = "green"; - elseif (a_Percent > 50) then - Color = "orange"; - else - Color = "red"; - end - - local meter = { - "\n", - "
    \n", - "
    \n", - string.format("%.2f", a_Percent), - " %", - }; - return table.concat(meter, ""); - end - - f:write([[ -

    Documentation statistics

    - - ]]); - f:write("\n"); - - f:write("\n"); - - f:write("\n"); - - f:write("\n"); - - f:write("\n"); - - f:write([[ -
    ObjectTotalDocumentedUndocumentedDocumented %
    Classes", g_Stats.NumTotalClasses); - f:write("", g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses); - f:write("", g_Stats.NumUndocumentedClasses); - f:write("", ExportMeter(100 * (g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses) / g_Stats.NumTotalClasses)); - f:write("
    Functions", g_Stats.NumTotalFunctions); - f:write("", g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions); - f:write("", g_Stats.NumUndocumentedFunctions); - f:write("", ExportMeter(100 * (g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions) / g_Stats.NumTotalFunctions)); - f:write("
    Member variables", g_Stats.NumTotalVariables); - f:write("", g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables); - f:write("", g_Stats.NumUndocumentedVariables); - f:write("", ExportMeter(100 * (g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables) / g_Stats.NumTotalVariables)); - f:write("
    Constants", g_Stats.NumTotalConstants); - f:write("", g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants); - f:write("", g_Stats.NumUndocumentedConstants); - f:write("", ExportMeter(100 * (g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants) / g_Stats.NumTotalConstants)); - f:write("
    Hooks", g_Stats.NumTotalHooks); - f:write("", g_Stats.NumTotalHooks - g_Stats.NumUndocumentedHooks); - f:write("", g_Stats.NumUndocumentedHooks); - f:write("", ExportMeter(100 * (g_Stats.NumTotalHooks - g_Stats.NumUndocumentedHooks) / g_Stats.NumTotalHooks)); - f:write("
    -

    There are ]], g_Stats.NumTrackedLinks, " internal links, ", g_Stats.NumInvalidLinks, " of them are invalid.

    " - ); -end - - - - diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua new file mode 100644 index 000000000..4dcedc06e --- /dev/null +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -0,0 +1,1315 @@ + +-- main.lua + +-- Implements the plugin entrypoint (in this case the entire plugin) + + + + + +-- Global variables: +g_Plugin = nil; +g_PluginFolder = ""; +g_TrackedPages = {}; -- List of tracked pages, to be checked later whether they exist. Each item is an array of referring pagenames. +g_Stats = -- Statistics about the documentation +{ + NumTotalClasses = 0, + NumUndocumentedClasses = 0, + NumTotalFunctions = 0, + NumUndocumentedFunctions = 0, + NumTotalConstants = 0, + NumUndocumentedConstants = 0, + NumTotalVariables = 0, + NumUndocumentedVariables = 0, + NumTotalHooks = 0, + NumUndocumentedHooks = 0, + NumTrackedLinks = 0, + NumInvalidLinks = 0, +} + + + + + + +function Initialize(Plugin) + g_Plugin = Plugin; + + Plugin:SetName("APIDump"); + Plugin:SetVersion(1); + + LOG("Initialising " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) + + g_PluginFolder = Plugin:GetLocalFolder(); + + -- dump all available API functions and objects: + -- DumpAPITxt(); + + -- Dump all available API object in HTML format into a subfolder: + DumpAPIHtml(); + + LOG("APIDump finished"); + + return true +end + + + + + +function DumpAPITxt() + LOG("Dumping all available functions to API.txt..."); + function dump (prefix, a, Output) + for i, v in pairs (a) do + if (type(v) == "table") then + if (GetChar(i, 1) ~= ".") then + if (v == _G) then + -- LOG(prefix .. i .. " == _G, CYCLE, ignoring"); + elseif (v == _G.package) then + -- LOG(prefix .. i .. " == _G.package, ignoring"); + else + dump(prefix .. i .. ".", v, Output) + end + end + elseif (type(v) == "function") then + if (string.sub(i, 1, 2) ~= "__") then + table.insert(Output, prefix .. i .. "()"); + end + end + end + end + + local Output = {}; + dump("", _G, Output); + + table.sort(Output); + local f = io.open("API.txt", "w"); + for i, n in ipairs(Output) do + f:write(n, "\n"); + end + f:close(); + LOG("API.txt written."); +end + + + + + +function CreateAPITables() + --[[ + We want an API table of the following shape: + local API = { + { + Name = "cCuboid", + Functions = { + {Name = "Sort"}, + {Name = "IsInside"} + }, + Constants = { + }, + Variables = { + }, + Descendants = {}, -- Will be filled by ReadDescriptions(), array of class APIs (references to other member in the tree) + }}, + { + Name = "cBlockArea", + Functions = { + {Name = "Clear"}, + {Name = "CopyFrom"}, + ... + }, + Constants = { + {Name = "baTypes", Value = 0}, + {Name = "baMetas", Value = 1}, + ... + }, + Variables = { + }, + ... + }} + }; + local Globals = { + Functions = { + ... + }, + Constants = { + ... + } + }; + --]] + + local Globals = {Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; + local API = {}; + + local function Add(a_APIContainer, a_ObjName, a_ObjValue) + if (type(a_ObjValue) == "function") then + table.insert(a_APIContainer.Functions, {Name = a_ObjName}); + elseif ( + (type(a_ObjValue) == "number") or + (type(a_ObjValue) == "string") + ) then + table.insert(a_APIContainer.Constants, {Name = a_ObjName, Value = a_ObjValue}); + end + end + + local function ParseClass(a_ClassName, a_ClassObj) + local res = {Name = a_ClassName, Functions = {}, Constants = {}, Variables = {}, Descendants = {}}; + -- Add functions and constants: + for i, v in pairs(a_ClassObj) do + Add(res, i, v); + end + + -- Member variables: + local SetField = a_ClassObj[".set"] or {}; + if ((a_ClassObj[".get"] ~= nil) and (type(a_ClassObj[".get"]) == "table")) then + for k, v in pairs(a_ClassObj[".get"]) do + if (SetField[k] == nil) then + -- It is a read-only variable, add it as a constant: + table.insert(res.Constants, {Name = k, Value = ""}); + else + -- It is a read-write variable, add it as a variable: + table.insert(res.Variables, { Name = k }); + end + end + end + return res; + end + + for i, v in pairs(_G) do + if ( + (v ~= _G) and -- don't want the global namespace + (v ~= _G.packages) and -- don't want any packages + (v ~= _G[".get"]) and + (v ~= g_APIDesc) + ) then + if (type(v) == "table") then + table.insert(API, ParseClass(i, v)); + else + Add(Globals, i, v); + end + end + end + + return API, Globals; +end + + + + + +function DumpAPIHtml() + LOG("Dumping all available functions and constants to API subfolder..."); + + LOG("Creating API tables..."); + local API, Globals = CreateAPITables(); + local Hooks = {}; + local UndocumentedHooks = {}; + + -- Sort the classes by name: + LOG("Sorting..."); + table.sort(API, + function (c1, c2) + return (string.lower(c1.Name) < string.lower(c2.Name)); + end + ); + + g_Stats.NumTotalClasses = #API; + + -- Add Globals into the API: + Globals.Name = "Globals"; + table.insert(API, Globals); + + -- Extract hook constants: + for name, obj in pairs(cPluginManager) do + if ( + (type(obj) == "number") and + name:match("HOOK_.*") and + (name ~= "HOOK_MAX") and + (name ~= "HOOK_NUM_HOOKS") + ) then + table.insert(Hooks, { Name = name }); + end + end + table.sort(Hooks, + function(Hook1, Hook2) + return (Hook1.Name < Hook2.Name); + end + ); + + -- Read in the descriptions: + LOG("Reading descriptions..."); + ReadDescriptions(API); + ReadHooks(Hooks); + + -- Create the output folder + if not(cFile:IsFolder("API")) then + cFile:CreateFolder("API"); + end + + -- Create a "class index" file, write each class as a link to that file, + -- then dump class contents into class-specific file + LOG("Writing HTML files..."); + local f = io.open("API/index.html", "w"); + if (f == nil) then + LOGINFO("Cannot output HTML API: " .. err); + return; + end + + f:write([[ + + + MCServer API - Index + + + +
    +
    +

    MCServer API - Index

    +
    +
    +

    The API reference is divided into the following sections:

    + + + +
    +

    Class index

    +

    The following classes are available in the MCServer Lua scripting language:

    + +
      +]]); + for i, cls in ipairs(API) do + f:write("
    • " .. cls.Name .. "
    • \n"); + WriteHtmlClass(cls, API); + end + f:write([[
    + +
    +

    Hooks

    + +

    A plugin can register to be called whenever an "interesting event" occurs. It does so by calling cPluginManager's AddHook() function and implementing a callback function to handle the event.

    +

    A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it from them. This is determined by the return value from the hook callback function. If the function returns false or no value, the event is propagated further. If the function returns true, the processing is stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior for the event). See each hook's details to see the exact behavior.

    + + + + + + +]]); + for i, hook in ipairs(Hooks) do + if (hook.DefaultFnName == nil) then + -- The hook is not documented yet + f:write(" \n \n \n \n"); + table.insert(UndocumentedHooks, hook.Name); + else + f:write(" \n \n \n \n"); + WriteHtmlHook(hook); + end + end + f:write([[
    Hook nameCalled when
    " .. hook.Name .. "(No documentation yet)
    " .. hook.Name .. "" .. LinkifyString(hook.CalledWhen, hook.Name) .. "
    + +
    +

    Extra pages

    + +

    The following pages provide various extra information

    + +
      +]]); + for i, extra in ipairs(g_APIDesc.ExtraPages) do + local SrcFileName = g_PluginFolder .. "/" .. extra.FileName; + if (cFile:Exists(SrcFileName)) then + local DstFileName = "API/" .. extra.FileName; + if (cFile:Exists(DstFileName)) then + cFile:Delete(DstFileName); + end + cFile:Copy(SrcFileName, DstFileName); + f:write("
    • " .. extra.Title .. "
    • \n"); + else + f:write("
    • " .. extra.Title .. " (file is missing)
    • \n"); + end + end + f:write("
    "); + + -- Copy the static files to the output folder (overwrite any existing): + cFile:Copy(g_Plugin:GetLocalFolder() .. "/main.css", "API/main.css"); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.js", "API/prettify.js"); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/prettify.css", "API/prettify.css"); + cFile:Copy(g_Plugin:GetLocalFolder() .. "/lang-lua.js", "API/lang-lua.js"); + + -- List the documentation problems: + LOG("Listing leftovers..."); + ListUndocumentedObjects(API, UndocumentedHooks); + ListUnexportedObjects(); + ListMissingPages(); + + WriteStats(f); + + f:write([[ +
    + +]]); + f:close(); + + LOG("API subfolder written"); +end + + + + + +function ReadDescriptions(a_API) + -- Returns true if the class of the specified name is to be ignored + local function IsClassIgnored(a_ClsName) + if (g_APIDesc.IgnoreClasses == nil) then + return false; + end + for i, name in ipairs(g_APIDesc.IgnoreClasses) do + if (a_ClsName:match(name)) then + return true; + end + end + return false; + end + + -- Returns true if the function is to be ignored + local function IsFunctionIgnored(a_ClassName, a_FnName) + if (g_APIDesc.IgnoreFunctions == nil) then + return false; + end + if (((g_APIDesc.Classes[a_ClassName] or {}).Functions or {})[a_FnName] ~= nil) then + -- The function is documented, don't ignore + return false; + end + local FnName = a_ClassName .. "." .. a_FnName; + for i, name in ipairs(g_APIDesc.IgnoreFunctions) do + if (FnName:match(name)) then + return true; + end + end + return false; + end + + -- Returns true if the constant (specified by its fully qualified name) is to be ignored + local function IsConstantIgnored(a_CnName) + if (g_APIDesc.IgnoreConstants == nil) then + return false; + end; + for i, name in ipairs(g_APIDesc.IgnoreConstants) do + if (a_CnName:match(name)) then + return true; + end + end + return false; + end + + -- Returns true if the member variable (specified by its fully qualified name) is to be ignored + local function IsVariableIgnored(a_VarName) + if (g_APIDesc.IgnoreVariables == nil) then + return false; + end; + for i, name in ipairs(g_APIDesc.IgnoreVariables) do + if (a_VarName:match(name)) then + return true; + end + end + return false; + end + + -- Remove ignored classes from a_API: + local APICopy = {}; + for i, cls in ipairs(a_API) do + if not(IsClassIgnored(cls.Name)) then + table.insert(APICopy, cls); + end + end + for i = 1, #a_API do + a_API[i] = APICopy[i]; + end; + + -- Process the documentation for each class: + for i, cls in ipairs(a_API) do + -- Initialize default values for each class: + cls.ConstantGroups = {}; + cls.NumConstantsInGroups = 0; + cls.NumConstantsInGroupsForDescendants = 0; + + -- Rename special functions: + for j, fn in ipairs(cls.Functions) do + if (fn.Name == ".call") then + fn.DocID = "constructor"; + fn.Name = "() (constructor)"; + elseif (fn.Name == ".add") then + fn.DocID = "operator_plus"; + fn.Name = "operator +"; + elseif (fn.Name == ".div") then + fn.DocID = "operator_div"; + fn.Name = "operator /"; + elseif (fn.Name == ".mul") then + fn.DocID = "operator_mul"; + fn.Name = "operator *"; + elseif (fn.Name == ".sub") then + fn.DocID = "operator_sub"; + fn.Name = "operator -"; + elseif (fn.Name == ".eq") then + fn.DocID = "operator_eq"; + fn.Name = "operator =="; + end + end + + local APIDesc = g_APIDesc.Classes[cls.Name]; + if (APIDesc ~= nil) then + APIDesc.IsExported = true; + cls.Desc = APIDesc.Desc; + cls.AdditionalInfo = APIDesc.AdditionalInfo; + + -- Process inheritance: + if (APIDesc.Inherits ~= nil) then + for j, icls in ipairs(a_API) do + if (icls.Name == APIDesc.Inherits) then + table.insert(icls.Descendants, cls); + cls.Inherits = icls; + end + end + end + + cls.UndocumentedFunctions = {}; -- This will contain names of all the functions that are not documented + cls.UndocumentedConstants = {}; -- This will contain names of all the constants that are not documented + cls.UndocumentedVariables = {}; -- This will contain names of all the variables that are not documented + + local DoxyFunctions = {}; -- This will contain all the API functions together with their documentation + + local function AddFunction(a_Name, a_Params, a_Return, a_Notes) + table.insert(DoxyFunctions, {Name = a_Name, Params = a_Params, Return = a_Return, Notes = a_Notes}); + end + + if (APIDesc.Functions ~= nil) then + -- Assign function descriptions: + for j, func in ipairs(cls.Functions) do + local FnName = func.DocID or func.Name; + local FnDesc = APIDesc.Functions[FnName]; + if (FnDesc == nil) then + -- No description for this API function + AddFunction(func.Name); + if not(IsFunctionIgnored(cls.Name, FnName)) then + table.insert(cls.UndocumentedFunctions, FnName); + end + else + -- Description is available + if (FnDesc[1] == nil) then + -- Single function definition + AddFunction(func.Name, FnDesc.Params, FnDesc.Return, FnDesc.Notes); + else + -- Multiple function overloads + for k, desc in ipairs(FnDesc) do + AddFunction(func.Name, desc.Params, desc.Return, desc.Notes); + end -- for k, desc - FnDesc[] + end + FnDesc.IsExported = true; + end + end -- for j, func + + -- Replace functions with their described and overload-expanded versions: + cls.Functions = DoxyFunctions; + else -- if (APIDesc.Functions ~= nil) + for j, func in ipairs(cls.Functions) do + local FnName = func.DocID or func.Name; + if not(IsFunctionIgnored(cls.Name, FnName)) then + table.insert(cls.UndocumentedFunctions, FnName); + end + end + end -- if (APIDesc.Functions ~= nil) + + if (APIDesc.Constants ~= nil) then + -- Assign constant descriptions: + for j, cons in ipairs(cls.Constants) do + local CnDesc = APIDesc.Constants[cons.Name]; + if (CnDesc == nil) then + -- Not documented + if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then + table.insert(cls.UndocumentedConstants, cons.Name); + end + else + cons.Notes = CnDesc.Notes; + CnDesc.IsExported = true; + end + end -- for j, cons + else -- if (APIDesc.Constants ~= nil) + for j, cons in ipairs(cls.Constants) do + if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then + table.insert(cls.UndocumentedConstants, cons.Name); + end + end + end -- else if (APIDesc.Constants ~= nil) + + -- Assign member variables' descriptions: + if (APIDesc.Variables ~= nil) then + for j, var in ipairs(cls.Variables) do + local VarDesc = APIDesc.Variables[var.Name]; + if (VarDesc == nil) then + -- Not documented + if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + else + -- Copy all documentation: + for k, v in pairs(VarDesc) do + var[k] = v + end + end + end -- for j, var + else -- if (APIDesc.Variables ~= nil) + for j, var in ipairs(cls.Variables) do + if not(IsVariableIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + end + end -- else if (APIDesc.Variables ~= nil) + + if (APIDesc.ConstantGroups ~= nil) then + -- Create links between the constants and the groups: + local NumInGroups = 0; + local NumInDescendantGroups = 0; + for j, group in pairs(APIDesc.ConstantGroups) do + group.Name = j; + group.Constants = {}; + if (type(group.Include == "string")) then + group.Include = { group.Include }; + end + local NumInGroup = 0; + for idx, incl in ipairs(group.Include or {}) do + for cidx, cons in ipairs(cls.Constants) do + if ((cons.Group == nil) and cons.Name:match(incl)) then + cons.Group = group; + table.insert(group.Constants, cons); + NumInGroup = NumInGroup + 1; + end + end -- for cidx - cls.Constants[] + end -- for idx - group.Include[] + NumInGroups = NumInGroups + NumInGroup; + if (group.ShowInDescendants) then + NumInDescendantGroups = NumInDescendantGroups + NumInGroup; + end + + -- Sort the constants: + table.sort(group.Constants, + function(c1, c2) + return (c1.Name < c2.Name); + end + ); + end -- for j - APIDesc.ConstantGroups[] + cls.ConstantGroups = APIDesc.ConstantGroups; + cls.NumConstantsInGroups = NumInGroups; + cls.NumConstantsInGroupsForDescendants = NumInDescendantGroups; + + -- Remove grouped constants from the normal list: + local NewConstants = {}; + for idx, cons in ipairs(cls.Constants) do + if (cons.Group == nil) then + table.insert(NewConstants, cons); + end + end + cls.Constants = NewConstants; + end -- if (ConstantGroups ~= nil) + + else -- if (APIDesc ~= nil) + + -- Class is not documented at all, add all its members to Undocumented lists: + cls.UndocumentedFunctions = {}; + cls.UndocumentedConstants = {}; + cls.UndocumentedVariables = {}; + cls.Variables = cls.Variables or {}; + g_Stats.NumUndocumentedClasses = g_Stats.NumUndocumentedClasses + 1; + for j, func in ipairs(cls.Functions) do + local FnName = func.DocID or func.Name; + if not(IsFunctionIgnored(cls.Name, FnName)) then + table.insert(cls.UndocumentedFunctions, FnName); + end + end -- for j, func - cls.Functions[] + for j, cons in ipairs(cls.Constants) do + if not(IsConstantIgnored(cls.Name .. "." .. cons.Name)) then + table.insert(cls.UndocumentedConstants, cons.Name); + end + end -- for j, cons - cls.Constants[] + for j, var in ipairs(cls.Variables) do + if not(IsConstantIgnored(cls.Name .. "." .. var.Name)) then + table.insert(cls.UndocumentedVariables, var.Name); + end + end -- for j, var - cls.Variables[] + end -- else if (APIDesc ~= nil) + + -- Remove ignored functions: + local NewFunctions = {}; + for j, fn in ipairs(cls.Functions) do + if (not(IsFunctionIgnored(cls.Name, fn.Name))) then + table.insert(NewFunctions, fn); + end + end -- for j, fn + cls.Functions = NewFunctions; + + -- Sort the functions (they may have been renamed): + table.sort(cls.Functions, + function(f1, f2) + if (f1.Name == f2.Name) then + -- Same name, either comparing the same function to itself, or two overloads, in which case compare the params + if ((f1.Params == nil) or (f2.Params == nil)) then + return 0; + end + return (f1.Params < f2.Params); + end + return (f1.Name < f2.Name); + end + ); + + -- Sort the constants: + table.sort(cls.Constants, + function(c1, c2) + return (c1.Name < c2.Name); + end + ); + + -- Remove ignored functions: + local NewVariables = {}; + for j, var in ipairs(cls.Variables) do + if (not(IsVariableIgnored(cls.Name .. "." .. var.Name))) then + table.insert(NewVariables, var); + end + end -- for j, var + cls.Variables = NewVariables; + + -- Sort the member variables: + table.sort(cls.Variables, + function(v1, v2) + return (v1.Name < v2.Name); + end + ); + end -- for i, cls + + -- Sort the descendants lists: + for i, cls in ipairs(a_API) do + table.sort(cls.Descendants, + function(c1, c2) + return (c1.Name < c2.Name); + end + ); + end -- for i, cls +end + + + + + +function ReadHooks(a_Hooks) + --[[ + a_Hooks = { + { Name = "HOOK_1"}, + { Name = "HOOK_2"}, + ... + }; + We want to add hook descriptions to each hook in this array + --]] + for i, hook in ipairs(a_Hooks) do + local HookDesc = g_APIDesc.Hooks[hook.Name]; + if (HookDesc ~= nil) then + for key, val in pairs(HookDesc) do + hook[key] = val; + end + end + end -- for i, hook - a_Hooks[] + g_Stats.NumTotalHooks = #a_Hooks; +end + + + + + +-- Make a link out of anything with the special linkifying syntax {{link|title}} +function LinkifyString(a_String, a_Referrer) + assert(a_Referrer ~= nil); + assert(a_Referrer ~= ""); + + --- Adds a page to the list of tracked pages (to be checked for existence at the end) + local function AddTrackedPage(a_PageName) + local Pg = (g_TrackedPages[a_PageName] or {}); + table.insert(Pg, a_Referrer); + g_TrackedPages[a_PageName] = Pg; + end + + --- Creates the HTML for the specified link and title + local function CreateLink(Link, Title) + if (Link:sub(1, 7) == "http://") then + -- The link is a full absolute URL, do not modify, do not track: + return "" .. Title .. ""; + end + local idxHash = Link:find("#"); + if (idxHash ~= nil) then + -- The link contains an anchor: + if (idxHash == 1) then + -- Anchor in the current page, no need to track: + return "" .. Title .. ""; + end + -- Anchor in another page: + local PageName = Link:sub(1, idxHash - 1); + AddTrackedPage(PageName); + return "" .. Title .. ""; + end + -- Link without anchor: + AddTrackedPage(Link); + return "" .. Title .. ""; + end + + -- Linkify the strings using the CreateLink() function: + local txt = a_String:gsub("{{([^|}]*)|([^}]*)}}", CreateLink) -- {{link|title}} + txt = txt:gsub("{{([^|}]*)}}", -- {{LinkAndTitle}} + function(LinkAndTitle) + local idxHash = LinkAndTitle:find("#"); + if (idxHash ~= nil) then + -- The LinkAndTitle contains a hash, remove the hashed part from the title: + return CreateLink(LinkAndTitle, LinkAndTitle:sub(1, idxHash - 1)); + end + return CreateLink(LinkAndTitle, LinkAndTitle); + end + ); + return txt; +end + + + + + +function WriteHtmlClass(a_ClassAPI, a_AllAPI) + local cf, err = io.open("API/" .. a_ClassAPI.Name .. ".html", "w"); + if (cf == nil) then + return; + end + + -- Writes a table containing all functions in the specified list, with an optional "inherited from" header when a_InheritedName is valid + local function WriteFunctions(a_Functions, a_InheritedName) + if (#a_Functions == 0) then + return; + end + + if (a_InheritedName ~= nil) then + cf:write("

    Functions inherited from ", a_InheritedName, "

    \n"); + end + cf:write(" \n \n \n \n \n \n \n"); + for i, func in ipairs(a_Functions) do + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n"); + cf:write(" \n \n"); + end + cf:write("
    NameParametersReturn valueNotes
    " .. func.Name .. "", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), "
    \n\n"); + end + + local function WriteConstantTable(a_Constants, a_Source) + cf:write("\n\n"); + for i, cons in ipairs(a_Constants) do + cf:write("\n"); + cf:write("\n"); + cf:write("\n"); + end + cf:write("
    NameValueNotes
    ", cons.Name, "", cons.Value, "", LinkifyString(cons.Notes or "", a_Source), "
    \n\n"); + end + + local function WriteConstants(a_Constants, a_ConstantGroups, a_NumConstantGroups, a_InheritedName) + if ((#a_Constants == 0) and (a_NumConstantGroups == 0)) then + return; + end + + if (a_InheritedName ~= nil) then + cf:write("

    Constants inherited from ", a_InheritedName, "

    \n"); + end + + if (#a_Constants > 0) then + WriteConstantTable(a_Constants, a_InheritedName or a_ClassAPI.Name); + end + + for k, group in pairs(a_ConstantGroups) do + if ((a_InheritedName == nil) or group.ShowInDescendants) then + cf:write("

    "); + cf:write(group.TextBefore or ""); + WriteConstantTable(group.Constants, a_InheritedName or a_ClassAPI.Name); + cf:write(group.TextAfter or "", "

    "); + end + end + end + + local function WriteVariables(a_Variables, a_InheritedName) + if (#a_Variables == 0) then + return; + end + + if (a_InheritedName ~= nil) then + cf:write("

    Member variables inherited from ", a_InheritedName, "

    \n"); + end + + cf:write(" \n \n \n \n \n \n"); + for i, var in ipairs(a_Variables) do + cf:write(" \n \n"); + cf:write(" \n"); + cf:write(" \n \n"); + end + cf:write("
    NameTypeNotes
    ", var.Name, "", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), "", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "
    \n\n"); + end + + local function WriteDescendants(a_Descendants) + if (#a_Descendants == 0) then + return; + end + cf:write("
      "); + for i, desc in ipairs(a_Descendants) do + cf:write("
    • ", desc.Name, ""); + WriteDescendants(desc.Descendants); + cf:write("
    • \n"); + end + cf:write("
    \n"); + end + + local ClassName = a_ClassAPI.Name; + + -- Build an array of inherited classes chain: + local InheritanceChain = {}; + local CurrInheritance = a_ClassAPI.Inherits; + while (CurrInheritance ~= nil) do + table.insert(InheritanceChain, CurrInheritance); + CurrInheritance = CurrInheritance.Inherits; + end + + cf:write([[ + + + MCServer API - ]], a_ClassAPI.Name, [[ Class + + + + + + +
    +
    +

    ]], a_ClassAPI.Name, [[

    +
    +
    +

    Contents

    + +
      +]]); + + local HasInheritance = ((#a_ClassAPI.Descendants > 0) or (a_ClassAPI.Inherits ~= nil)); + + local HasConstants = (#a_ClassAPI.Constants > 0) or (a_ClassAPI.NumConstantsInGroups > 0); + local HasFunctions = (#a_ClassAPI.Functions > 0); + local HasVariables = (#a_ClassAPI.Variables > 0); + for idx, cls in ipairs(InheritanceChain) do + HasConstants = HasConstants or (#cls.Constants > 0) or (cls.NumConstantsInGroupsForDescendants > 0); + HasFunctions = HasFunctions or (#cls.Functions > 0); + HasVariables = HasVariables or (#cls.Variables > 0); + end + + -- Write the table of contents: + if (HasInheritance) then + cf:write("
    • Inheritance
    • \n"); + end + if (HasConstants) then + cf:write("
    • Constants
    • \n"); + end + if (HasVariables) then + cf:write("
    • Member variables
    • \n"); + end + if (HasFunctions) then + cf:write("
    • Functions
    • \n"); + end + if (a_ClassAPI.AdditionalInfo ~= nil) then + for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do + cf:write("
    • ", (additional.Header or "(No header)"), "
    • \n"); + end + end + cf:write("
    \n\n"); + + -- Write the class description: + cf:write("

    " .. ClassName .. " class

    \n"); + if (a_ClassAPI.Desc ~= nil) then + cf:write("

    "); + cf:write(LinkifyString(a_ClassAPI.Desc, ClassName)); + cf:write("

    \n\n"); + end; + + -- Write the inheritance, if available: + if (HasInheritance) then + cf:write(" \n

    Inheritance

    \n"); + if (#InheritanceChain > 0) then + cf:write("

    This class inherits from the following parent classes:

    \n\n
      \n"); + for i, cls in ipairs(InheritanceChain) do + cf:write("
    • " .. cls.Name .. "
    • \n"); + end + cf:write("
    \n\n"); + end + if (#a_ClassAPI.Descendants > 0) then + cf:write("

    This class has the following descendants:\n"); + WriteDescendants(a_ClassAPI.Descendants); + cf:write("

    \n\n"); + end + end + + -- Write the constants: + if (HasConstants) then + cf:write("

    Constants

    \n"); + WriteConstants(a_ClassAPI.Constants, a_ClassAPI.ConstantGroups, a_ClassAPI.NumConstantsInGroups, nil); + g_Stats.NumTotalConstants = g_Stats.NumTotalConstants + #a_ClassAPI.Constants + (a_ClassAPI.NumConstantsInGroups or 0); + for i, cls in ipairs(InheritanceChain) do + WriteConstants(cls.Constants, cls.ConstantGroups, cls.NumConstantsInGroupsForDescendants, cls.Name); + end; + end; + + -- Write the member variables: + if (HasVariables) then + cf:write("

    Member variables

    \n"); + WriteVariables(a_ClassAPI.Variables, nil); + g_Stats.NumTotalVariables = g_Stats.NumTotalVariables + #a_ClassAPI.Variables; + for i, cls in ipairs(InheritanceChain) do + WriteVariables(cls.Variables, cls.Name); + end; + end + + -- Write the functions, including the inherited ones: + if (HasFunctions) then + cf:write("

    Functions

    \n"); + WriteFunctions(a_ClassAPI.Functions, nil); + g_Stats.NumTotalFunctions = g_Stats.NumTotalFunctions + #a_ClassAPI.Functions; + for i, cls in ipairs(InheritanceChain) do + WriteFunctions(cls.Functions, cls.Name); + end + end + + -- Write the additional infos: + if (a_ClassAPI.AdditionalInfo ~= nil) then + for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do + cf:write("

    ", additional.Header, "

    \n"); + cf:write(LinkifyString(additional.Contents, ClassName)); + end + end + + cf:write([[ +
    + + + + ]]); + cf:close(); +end + + + + + +function WriteHtmlHook(a_Hook) + local fnam = "API/" .. a_Hook.DefaultFnName .. ".html"; + local f, error = io.open(fnam, "w"); + if (f == nil) then + LOG("Cannot write \"" .. fnam .. "\": \"" .. error .. "\"."); + return; + end + local HookName = a_Hook.DefaultFnName; + + f:write([[ + + + MCServer API - ]] .. HookName .. [[ Hook + + + + + + +
    +
    +

    ]] .. a_Hook.Name .. [[

    +
    +
    +

    +]]); + f:write(LinkifyString(a_Hook.Desc, HookName)); + f:write("

    \n

    Callback function

    \n

    The default name for the callback function is "); + f:write(a_Hook.DefaultFnName .. ". It has the following signature:\n\n"); + f:write("

    function " .. HookName .. "(");
    +	if (a_Hook.Params == nil) then
    +		a_Hook.Params = {};
    +	end
    +	for i, param in ipairs(a_Hook.Params) do
    +		if (i > 1) then
    +			f:write(", ");
    +		end
    +		f:write(param.Name);
    +	end
    +	f:write(")
    \n\n

    Parameters:

    \n\n \n \n \n \n \n \n"); + for i, param in ipairs(a_Hook.Params) do + f:write(" \n \n \n \n \n"); + end + f:write("
    NameTypeNotes
    " .. param.Name .. "" .. LinkifyString(param.Type, HookName) .. "" .. LinkifyString(param.Notes, HookName) .. "
    \n\n

    " .. (a_Hook.Returns or "") .. "

    \n\n"); + f:write([[

    Code examples

    +

    Registering the callback

    + +]]); + f:write("
    \n");
    +	f:write([[cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);]]);
    +	f:write("
    \n\n"); + local Examples = a_Hook.CodeExamples or {}; + for i, example in ipairs(Examples) do + f:write("

    " .. (example.Title or "missing Title") .. "

    \n"); + f:write("

    " .. (example.Desc or "missing Desc") .. "

    \n\n"); + f:write("
    " .. (example.Code or "missing Code") .. "\n			
    \n\n"); + end + f:write([[
    + + +]]); + f:close(); +end + + + + + +--- Writes a list of undocumented objects into a file +function ListUndocumentedObjects(API, UndocumentedHooks) + f = io.open("API/_undocumented.lua", "w"); + if (f ~= nil) then + f:write("\n-- This is the list of undocumented API objects, automatically generated by APIDump\n\n"); + f:write("g_APIDesc =\n{\n\tClasses =\n\t{\n"); + for i, cls in ipairs(API) do + local HasFunctions = ((cls.UndocumentedFunctions ~= nil) and (#cls.UndocumentedFunctions > 0)); + local HasConstants = ((cls.UndocumentedConstants ~= nil) and (#cls.UndocumentedConstants > 0)); + local HasVariables = ((cls.UndocumentedVariables ~= nil) and (#cls.UndocumentedVariables > 0)); + g_Stats.NumUndocumentedFunctions = g_Stats.NumUndocumentedFunctions + #cls.UndocumentedFunctions; + g_Stats.NumUndocumentedConstants = g_Stats.NumUndocumentedConstants + #cls.UndocumentedConstants; + g_Stats.NumUndocumentedVariables = g_Stats.NumUndocumentedVariables + #cls.UndocumentedVariables; + if (HasFunctions or HasConstants or HasVariables) then + f:write("\t\t" .. cls.Name .. " =\n\t\t{\n"); + if ((cls.Desc == nil) or (cls.Desc == "")) then + f:write("\t\t\tDesc = \"\"\n"); + end + end + + if (HasFunctions) then + f:write("\t\t\tFunctions =\n\t\t\t{\n"); + table.sort(cls.UndocumentedFunctions); + for j, fn in ipairs(cls.UndocumentedFunctions) do + f:write("\t\t\t\t" .. fn .. " = { Params = \"\", Return = \"\", Notes = \"\" },\n"); + end -- for j, fn - cls.UndocumentedFunctions[] + f:write("\t\t\t},\n\n"); + end + + if (HasConstants) then + f:write("\t\t\tConstants =\n\t\t\t{\n"); + table.sort(cls.UndocumentedConstants); + for j, cn in ipairs(cls.UndocumentedConstants) do + f:write("\t\t\t\t" .. cn .. " = { Notes = \"\" },\n"); + end -- for j, fn - cls.UndocumentedConstants[] + f:write("\t\t\t},\n\n"); + end + + if (HasVariables) then + f:write("\t\t\tVariables =\n\t\t\t{\n"); + table.sort(cls.UndocumentedVariables); + for j, vn in ipairs(cls.UndocumentedVariables) do + f:write("\t\t\t\t" .. vn .. " = { Type = \"\", Notes = \"\" },\n"); + end -- for j, fn - cls.UndocumentedVariables[] + f:write("\t\t\t},\n\n"); + end + + if (HasFunctions or HasConstants or HasVariables) then + f:write("\t\t},\n\n"); + end + end -- for i, cls - API[] + f:write("\t},\n"); + + if (#UndocumentedHooks > 0) then + f:write("\n\tHooks =\n\t{\n"); + for i, hook in ipairs(UndocumentedHooks) do + if (i > 1) then + f:write("\n"); + end + f:write("\t\t" .. hook .. " =\n\t\t{\n"); + f:write("\t\t\tCalledWhen = \"\",\n"); + f:write("\t\t\tDefaultFnName = \"On\", -- also used as pagename\n"); + f:write("\t\t\tDesc = [[\n\t\t\t\t\n\t\t\t]],\n"); + f:write("\t\t\tParams =\n\t\t\t{\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t\t{ Name = \"\", Type = \"\", Notes = \"\" },\n"); + f:write("\t\t\t},\n"); + f:write("\t\t\tReturns = [[\n\t\t\t\t\n\t\t\t]],\n"); + f:write("\t\t}, -- " .. hook .. "\n"); + end + f:write("\t},\n"); + end + f:write("}\n\n\n\n"); + f:close(); + end + g_Stats.NumUndocumentedHooks = #UndocumentedHooks; +end + + + + + +--- Lists the API objects that are documented but not available in the API: +function ListUnexportedObjects() + f = io.open("API/_unexported-documented.txt", "w"); + if (f ~= nil) then + for clsname, cls in pairs(g_APIDesc.Classes) do + if not(cls.IsExported) then + -- The whole class is not exported + f:write("class\t" .. clsname .. "\n"); + else + if (cls.Functions ~= nil) then + for fnname, fnapi in pairs(cls.Functions) do + if not(fnapi.IsExported) then + f:write("func\t" .. clsname .. "." .. fnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end + if (cls.Constants ~= nil) then + for cnname, cnapi in pairs(cls.Constants) do + if not(cnapi.IsExported) then + f:write("const\t" .. clsname .. "." .. cnname .. "\n"); + end + end -- for j, fn - cls.Functions[] + end + end + end -- for i, cls - g_APIDesc.Classes[] + f:close(); + end +end + + + + + +function ListMissingPages() + local MissingPages = {}; + local NumLinks = 0; + for PageName, Referrers in pairs(g_TrackedPages) do + NumLinks = NumLinks + 1; + if not(cFile:Exists("API/" .. PageName .. ".html")) then + table.insert(MissingPages, {Name = PageName, Refs = Referrers} ); + end + end; + g_Stats.NumTrackedLinks = NumLinks; + g_TrackedPages = {}; + + if (#MissingPages == 0) then + -- No missing pages, congratulations! + return; + end + + -- Sort the pages by name: + table.sort(MissingPages, + function (Page1, Page2) + return (Page1.Name < Page2.Name); + end + ); + + -- Output the pages: + local f, err = io.open("API/_missingPages.txt", "w"); + if (f == nil) then + LOGWARNING("Cannot open _missingPages.txt for writing: '" .. err .. "'. There are " .. #MissingPages .. " pages missing."); + return; + end + for idx, pg in ipairs(MissingPages) do + f:write(pg.Name .. ":\n"); + -- Sort and output the referrers: + table.sort(pg.Refs); + f:write("\t" .. table.concat(pg.Refs, "\n\t")); + f:write("\n\n"); + end + f:close(); + g_Stats.NumInvalidLinks = #MissingPages; +end + + + + + +--- Writes the documentation statistics (in g_Stats) into the given HTML file +function WriteStats(f) + local function ExportMeter(a_Percent) + local Color; + if (a_Percent > 99) then + Color = "green"; + elseif (a_Percent > 50) then + Color = "orange"; + else + Color = "red"; + end + + local meter = { + "\n", + "
    \n", + "
    \n", + string.format("%.2f", a_Percent), + " %", + }; + return table.concat(meter, ""); + end + + f:write([[ +

    Documentation statistics

    + + ]]); + f:write("\n"); + + f:write("\n"); + + f:write("\n"); + + f:write("\n"); + + f:write("\n"); + + f:write([[ +
    ObjectTotalDocumentedUndocumentedDocumented %
    Classes", g_Stats.NumTotalClasses); + f:write("", g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses); + f:write("", g_Stats.NumUndocumentedClasses); + f:write("", ExportMeter(100 * (g_Stats.NumTotalClasses - g_Stats.NumUndocumentedClasses) / g_Stats.NumTotalClasses)); + f:write("
    Functions", g_Stats.NumTotalFunctions); + f:write("", g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions); + f:write("", g_Stats.NumUndocumentedFunctions); + f:write("", ExportMeter(100 * (g_Stats.NumTotalFunctions - g_Stats.NumUndocumentedFunctions) / g_Stats.NumTotalFunctions)); + f:write("
    Member variables", g_Stats.NumTotalVariables); + f:write("", g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables); + f:write("", g_Stats.NumUndocumentedVariables); + f:write("", ExportMeter(100 * (g_Stats.NumTotalVariables - g_Stats.NumUndocumentedVariables) / g_Stats.NumTotalVariables)); + f:write("
    Constants", g_Stats.NumTotalConstants); + f:write("", g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants); + f:write("", g_Stats.NumUndocumentedConstants); + f:write("", ExportMeter(100 * (g_Stats.NumTotalConstants - g_Stats.NumUndocumentedConstants) / g_Stats.NumTotalConstants)); + f:write("
    Hooks", g_Stats.NumTotalHooks); + f:write("", g_Stats.NumTotalHooks - g_Stats.NumUndocumentedHooks); + f:write("", g_Stats.NumUndocumentedHooks); + f:write("", ExportMeter(100 * (g_Stats.NumTotalHooks - g_Stats.NumUndocumentedHooks) / g_Stats.NumTotalHooks)); + f:write("
    +

    There are ]], g_Stats.NumTrackedLinks, " internal links, ", g_Stats.NumInvalidLinks, " of them are invalid.

    " + ); +end + + + + -- cgit v1.2.3 From b8aaf13a1270a1ffb998a63888c457f53178653d Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Fri, 22 Nov 2013 22:12:46 +0100 Subject: APIDump: Added a few constant groups to the descriptions. --- MCServer/Plugins/APIDump/APIDesc.lua | 170 ++++++++++++++++------------------- 1 file changed, 78 insertions(+), 92 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 5489650ad..28ed9b9d4 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -322,9 +322,6 @@ g_APIDesc = GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" }, GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" }, }, - Constants = - { - }, }, cBlockEntityWithItems = @@ -353,9 +350,6 @@ g_APIDesc = { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, }, }, - Constants = - { - }, }, cBoundingBox = @@ -395,7 +389,6 @@ g_APIDesc = }, Union = { Params = "OtherBoundingBox", Return = "cBoundingBox", Notes = "Returns the smallest bounding box that contains both OtherBoundingBox and this bounding box. Note that unlike the strict geometrical meaning of \"union\", this operation actually returns a cBoundingBox." }, }, - Constants = {}, }, cChatColor = @@ -535,9 +528,6 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), SetUseDefaultStructures = { Params = "bool", Return = "", Notes = "Sets the chunk to use default structures or not" }, WriteBlockArea = { Params = "{{cBlockArea|BlockArea}}, MinRelX, MinRelY, MinRelZ", Return = "", Notes = "Writes data from the block area into the chunk" }, }, - Constants = - { - }, AdditionalInfo = { { @@ -600,7 +590,7 @@ end MAX_VIEW_DISTANCE = { Notes = "The maximum value of the view distance" }, MIN_VIEW_DISTANCE = { Notes = "The minimum value of the view distance" }, }, - }, + }, -- cClientHandle cCraftingGrid = { @@ -630,10 +620,7 @@ end { Params = "x, y, ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the item at the specified coords" }, }, }, - Constants = - { - }, - }, + }, -- cCraftingGrid cCraftingRecipe = { @@ -662,10 +649,7 @@ end { Params = "ItemType, ItemCount, ItemDamage", Return = "", Notes = "Sets the result item" }, }, }, - Constants = - { - }, - }, + }, -- cCraftingRecipe cCuboid = { @@ -707,7 +691,7 @@ end p1 = { Type = "{{Vector3i}}", Notes = "The first corner. Usually the lesser of the two coords in each set" }, p2 = { Type = "{{Vector3i}}", Notes = "The second corner. Usually the larger of the two coords in each set" }, }, - }, + }, -- cCuboid cDispenserEntity = { @@ -1000,14 +984,15 @@ cFile:Delete("/usr/bin/virus.exe"); { Desc = "", Functions = {}, - Constants = {}, Inherits = "cProjectileEntity", } , cFurnaceEntity = { Desc = [[ - This class represents a furnace block entity in the world. + This class represents a furnace block entity in the world.

    +

    + See also {{cRoot}}'s GetFurnaceRecipe() and GetFurnaceFuelBurnTime() functions ]], Functions = { @@ -1024,27 +1009,36 @@ cFile:Delete("/usr/bin/virus.exe"); }, Constants = { - fsInput = { Notes = "Index of the input slot, when using the GetSlot() / SetSlot() functions" }, - fsFuel = { Notes = "Index of the fuel slot, when using the GetSlot() / SetSlot() functions" }, - fsOutput = { Notes = "Index of the output slot, when using the GetSlot() / SetSlot() functions" }, + fsInput = { Notes = "Index of the input slot" }, + fsFuel = { Notes = "Index of the fuel slot" }, + fsOutput = { Notes = "Index of the output slot" }, ContentsWidth = { Notes = "Width (X) of the {{cItemGrid|cItemGrid}} representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid|cItemGrid}} representing the contents" }, }, + ConstantGroups = + { + SlotIndices = + { + Include = "fs.*", + TextBefore = "When using the GetSlot() or SetSlot() function, use these constants for slot index:", + }, + }, Inherits = "cBlockEntityWithItems" - }, + }, -- cFurnaceEntity cGhastFireballEntity = { Desc = "", Functions = {}, - Constants = {}, Inherits = "cProjectileEntity", - } , + }, -- cGhastFireballEntity cGroup = { - Desc = [[cGroup is a group {{cPlayer|cPlayer}}'s can be in. Groups define the permissions players have, and optionally the color of their name in the chat. -]], + Desc = [[ + This class represents a group {{cPlayer|players}} can be in. Groups define the permissions players + have, and optionally the color of their name in the chat. + ]], Functions = { SetName = { Return = "" }, @@ -1056,10 +1050,7 @@ cFile:Delete("/usr/bin/virus.exe"); AddPermission = { Return = "" }, InheritFrom = { Return = "" }, }, - Constants = - { - }, - }, + }, -- cGroup cHopperEntity = { @@ -1077,7 +1068,7 @@ cFile:Delete("/usr/bin/virus.exe"); TICKS_PER_TRANSFER = { Notes = "Number of ticks between when the hopper transfers items." }, }, Inherits = "cBlockEntityWithItems", - }, + }, -- cHopperEntity cIniFile = { @@ -1287,6 +1278,16 @@ These ItemGrids are available in the API and can be manipulated by the plugins, invHotbarOffset = { Notes = "Starting slot number of the Hotbar part" }, invNumSlots = { Notes = "Total number of slots in a cInventory" }, }, + ConstantGroups = + { + SlotIndices = + { + Include = "inv.*", + TextBefore = [[ + Rather than hardcoding numbers, use the following constants for slot indices and counts: + ]], + }, + }, }, -- cInventory cItem = @@ -1448,9 +1449,6 @@ local Item5 = cItem(E_ITEM_DIAMOND_CHESTPLATE, 1, 0, "thorns=1;unbreaking=3"); { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the specified slot to the specified item" }, }, }, - Constants = - { - }, AdditionalInfo = { { @@ -1512,9 +1510,6 @@ end }, Size = { Params = "", Return = "number", Notes = "Returns the number of items in the collection" }, }, - Constants = - { - }, }, -- cItems cJukeboxEntity = @@ -1641,9 +1636,6 @@ end SetOnClosing = { Params = "OnClosingCallback", Return = "", Notes = "Sets the function that the window will call when it is about to be closed by a player" }, SetOnSlotChanged = { Params = "OnSlotChangedCallback", Return = "", Notes = "Sets the function that the window will call when a slot is changed by a player" }, }, - Constants = - { - }, AdditionalInfo = { { @@ -1718,12 +1710,12 @@ a_Player:OpenWindow(Window); ]], Functions = { - FamilyFromType = { Params = "MobType", Return = "MobFamily", Notes = "(STATIC) Returns the mob family (mfXXX constants) based on the mob type (mtXXX constants)" }, - GetMobFamily = { Params = "", Return = "MobFamily", Notes = "Returns this mob's family (mfXXX constant)" }, - GetMobType = { Params = "", Return = "MobType", Notes = "Returns the type of this mob (mtXXX constant)" }, - GetSpawnDelay = { Params = "MobFamily", Return = "number", Notes = "(STATIC) Returns the spawn delay - the number of game ticks between spawn attempts - for the specified mob family." }, - MobTypeToString = { Params = "MobType", Return = "string", Notes = "(STATIC) Returns the string representing the given mob type (mtXXX constant), or empty string if unknown type." }, - StringToMobType = { Params = "string", Return = "MobType", Notes = "(STATIC) Returns the mob type (mtXXX constant) parsed from the string type (\"creeper\"), or mtInvalidType if unrecognized." }, + FamilyFromType = { Params = "{{cMonster#MobType|MobType}}", Return = "{{cMonster#MobFamily|MobFamily}}", Notes = "(STATIC) Returns the mob family ({{cMonster#MobFamily|mfXXX}} constants) based on the mob type ({{cMonster#MobType|mtXXX}} constants)" }, + GetMobFamily = { Params = "", Return = "{{cMonster#MobFamily|MobFamily}}", Notes = "Returns this mob's family ({{cMonster#MobFamily|mfXXX}} constant)" }, + GetMobType = { Params = "", Return = "{{cMonster#MobType|MobType}}", Notes = "Returns the type of this mob ({{cMonster#MobType|mtXXX}} constant)" }, + GetSpawnDelay = { Params = "{{cMonster#MobFamily|MobFamily}}", Return = "number", Notes = "(STATIC) Returns the spawn delay - the number of game ticks between spawn attempts - for the specified mob family." }, + MobTypeToString = { Params = "{{cMonster#MobType|MobType}}", Return = "string", Notes = "(STATIC) Returns the string representing the given mob type ({{cMonster#MobType|mtXXX}} constant), or empty string if unknown type." }, + StringToMobType = { Params = "string", Return = "{{cMonster#MobType|MobType}}", Notes = "(STATIC) Returns the mob type ({{cMonster#MobType|mtXXX}} constant) parsed from the string type (\"creeper\"), or mtInvalidType if unrecognized." }, }, Constants = { @@ -1763,6 +1755,23 @@ a_Player:OpenWindow(Window); mtZombie = { Notes = "" }, mtZombiePigman = { Notes = "" }, }, + ConstantGroups = + { + MobFamily = + { + Include = "mf.*", + TextBefore = [[ + Mobs are divided into families. The following constants are used for individual family types: + ]], + }, + MobType = + { + Include = "mt.*", + TextBefore = [[ + The following constants are used for distinguishing between the individual mob types: + ]], + }, + }, Inherits = "cPawn", }, -- cMonster @@ -1798,11 +1807,8 @@ a_Player:OpenWindow(Window); KilledBy = { Return = "" }, GetHealth = { Return = "number" }, }, - Constants = - { - }, Inherits = "cEntity", - }, + }, -- cPawn cPickup = { @@ -1914,7 +1920,7 @@ a_Player:OpenWindow(Window); MAX_HEALTH = { Notes = "The maximum health value" }, }, Inherits = "cPawn", - }, + }, -- cPlayer cPlugin = { @@ -1933,18 +1939,14 @@ a_Player:OpenWindow(Window); GetFileName = { Return = "string" }, CreateWebPlugin = { Notes = "{{cWebPlugin|cWebPlugin}}" }, }, - Constants = - { - }, - }, + }, -- cPlugin cPluginLua = { Desc = "", Functions = {}, - Constants = {}, Inherits = "cPlugin", - }, + }, -- cPluginLua cPluginManager = { @@ -2121,9 +2123,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds. Note that the saving is queued on each world's tick thread and this functions returns before the chunks are actually saved." }, SetPrimaryServerVersion = { Params = "Protocol Version", Return = "", Notes = "Sets the servers PrimaryServerVersion to the given protocol number." } }, - Constants = - { - }, AdditionalInfo = { { @@ -2169,9 +2168,6 @@ end GetServerID = { Return = "string", Notes = "Returns the ID of the server?" }, IsHardcore = { Params = "", Return = "bool", Notes = "Returns true if the server is hardcore (players get banned on death)." }, }, - Constants = - { - }, }, -- cServer cSignEntity = @@ -2193,39 +2189,37 @@ end { Desc = "", Functions = {}, - Constants = {}, Inherits = "cProjectileEntity", - }, + }, -- cThrownEggEntity cThrownEnderPearlEntity = { Desc = "", Functions = {}, - Constants = {}, Inherits = "cProjectileEntity", - }, + }, -- cThrownEnderPearlEntity cThrownSnowballEntity = { Desc = "", Functions = {}, - Constants = {}, Inherits = "cProjectileEntity", - }, + }, -- cThrownSnowballEntity cTracer = { - Desc = [[A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is tracing what block a player is looking at, but you can do more with it if you want. -

    -

    The cTracer is still a work in progress -]], + Desc = [[ + A cTracer object is used to trace lines in the world. One thing you can use the cTracer for, is + tracing what block a player is looking at, but you can do more with it if you want.

    +

    + The cTracer is still a work in progress.

    +

    + See also the {{cLineBlockTracer}} class for an alternative approach using callbacks. + ]], Functions = { }, - Constants = - { - }, - }, + }, -- cTracer cWebAdmin = { @@ -2234,15 +2228,13 @@ end { GetHTMLEscapedString = { Params = "string", Return = "string", Notes = "Gets the HTML escaped representation of a requested string. This is useful for user input and game data that is not guaranteed to be escaped already." }, }, - Constants = {}, - }, + }, -- cWebAdmin cWebPlugin = { Desc = "", Functions = {}, - Constants = {}, - }, + }, -- cWebPlugin cWindow = { @@ -2437,9 +2429,6 @@ end WakeUpSimulators = { Params = "BlockX, BlockY, BlockZ", Return = "", Notes = "Wakes up the simulators for the specified block." }, WakeUpSimulatorsInArea = { Params = "MinBlockX, MaxBlockX, MinBlockY, MaxBlockY, MinBlockZ, MaxBlockZ", Return = "", Notes = "Wakes up the simulators for all the blocks in the specified area (edges inclusive)." }, }, - Constants = - { - }, AdditionalInfo = { { @@ -2908,10 +2897,7 @@ end TrimString = {Params = "string", Return = "string", Notes = "Trime whitespace at both ends of the string"}, md5 = {Params = "string", Return = "string", Notes = "converts a string to an md5 hash"}, }, - Constants = - { - }, - }, + }, -- Globals }, -- cgit v1.2.3 From 520088fc7c71818bb0988063a19e45b3577541d5 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 23 Nov 2013 19:40:35 +0100 Subject: APIDump: Added more constant groups. Also fixed the parsing of the Include data in the constant groups, and added linkification to group texts. --- MCServer/Plugins/APIDump/APIDesc.lua | 131 ++++++++++++++++++++++++++---- MCServer/Plugins/APIDump/main_APIDump.lua | 10 ++- 2 files changed, 121 insertions(+), 20 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 28ed9b9d4..bdbea2351 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2865,38 +2865,137 @@ end Globals = { - Desc = [[These functions are available directly, without a class instance. Any plugin cal call them at any time.]], + Desc = [[ + These functions are available directly, without a class instance. Any plugin cal call them at any + time. + ]], Functions = { - AddFaceDirection = {Params = "BlockX, BlockY, BlockZ, BlockFace, Inverse", Return = "BlockX, BlockY, BlockZ", Notes = "Returns the coords of a block adjacent to the specified block through the specified face"}, + AddFaceDirection = {Params = "BlockX, BlockY, BlockZ, BlockFace, [IsInverse]", Return = "BlockX, BlockY, BlockZ", Notes = "Returns the coords of a block adjacent to the specified block through the specified {{Globals#BlockFace|face}}"}, BlockStringToType = {Params = "BlockTypeString", Return = "BLOCKTYPE", Notes = "Returns the block type parsed from the given string"}, - ClickActionToString = {Params = "ClickAction", Return = "string", Notes = "Returns a string description of the ClickAction enumerated value"}, - DamageTypeToString = {Params = "{{TakeDamageInfo|eDamageType}}", Return = "string", Notes = "Converts a damage type enumerated value to a string representation "}, + ClickActionToString = {Params = "{{Globals#ClickAction|ClickAction}}", Return = "string", Notes = "Returns a string description of the ClickAction enumerated value"}, + DamageTypeToString = {Params = "{{Globals#DamageType|DamageType}}", Return = "string", Notes = "Converts the {{Globals#DamageType|DamageType}} enumerated value to a string representation "}, EscapeString = {Params = "string", Return = "string", Notes = "Returns a copy of the string with all quotes and backslashes escaped by a backslash"}, GetChar = {Params = "String, Pos", Return = "string", Notes = "Returns one character from the string, specified by position "}, GetTime = {Return = "number", Notes = "Returns the current OS time, as a unix time stamp (number of seconds since Jan 1, 1970)"}, IsValidBlock = {Params = "BlockType", Return = "bool", Notes = "Returns true if BlockType is a known block type"}, IsValidItem = {Params = "ItemType", Return = "bool", Notes = "Returns true if ItemType is a known item type"}, - ItemToFullString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item, in the format “ItemTypeText:ItemDamage * Countâ€"}, + ItemToFullString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item, in the format 'ItemTypeText:ItemDamage * Count'"}, ItemToString = {Params = "{{cItem|cItem}}", Return = "string", Notes = "Returns the string representation of the item type"}, ItemTypeToString = {Params = "ItemType", Return = "string", Notes = "Returns the string representation of ItemType "}, - LOG = {Params = "string", Notes = "Logs a text into the server console using “normal†severity (gray text) "}, - LOGERROR = {Params = "string", Notes = "Logs a text into the server console using “error†severity (black text on red background)"}, - LOGINFO = {Params = "string", Notes = "Logs a text into the server console using “info†severity (yellow text)"}, - LOGWARN = {Params = "string", Notes = "Logs a text into the server console using “warning†severity (red text); OBSOLETE"}, - LOGWARNING = {Params = "string", Notes = "Logs a text into the server console using “warning†severity (red text)"}, + LOG = {Params = "string", Notes = "Logs a text into the server console using 'normal' severity (gray text) "}, + LOGERROR = {Params = "string", Notes = "Logs a text into the server console using 'error' severity (black text on red background)"}, + LOGINFO = {Params = "string", Notes = "Logs a text into the server console using 'info' severity (yellow text)"}, + LOGWARN = {Params = "string", Notes = "Logs a text into the server console using 'warning' severity (red text); OBSOLETE, use LOGWARNING() instead"}, + LOGWARNING = {Params = "string", Notes = "Logs a text into the server console using 'warning' severity (red text)"}, NoCaseCompare = {Params = "string, string", Return = "number", Notes = "Case-insensitive string comparison; returns 0 if the strings are the same"}, ReplaceString = {Params = "full-string, to-be-replaced-string, to-replace-string", Notes = "Replaces *each* occurence of to-be-replaced-string in full-string with to-replace-string"}, - StringSplit = {Params = "string, Seperator", Return = "list", Notes = "Seperates string into multiple by splitting every time Seperator is encountered."}, - StringToBiome = {Params = "string", Return = "EMCSBiome", Notes = "Converts a string representation to a biome enumerated value"}, - StringToDamageType = {Params = "string", Return = "{{TakeDamageInfo|eDamageType}}", Notes = "Converts a string representation to an {{TakeDamageInfo|eDamageType}} enumerated value "}, - StringToDimension = {Params = "string", Return = "eDimension", Notes = "Converts a string representation to an eDimension enumerated value"}, + StringSplit = {Params = "string, SeperatorsString", Return = "array table of strings", Notes = "Seperates string into multiple by splitting every time any of the characters in SeperatorsString is encountered."}, + StringSplitAndTrim = {Params = "string, SeperatorsString", Return = "array table of strings", Notes = "Seperates string into multiple by splitting every time any of the characters in SeperatorsString is encountered. Each of the separate strings is trimmed (whitespace removed from the beginning and end of the string)"}, + StringToBiome = {Params = "string", Return = "{{Globals#BiomeTypes|BiomeType}}", Notes = "Converts a string representation to a {{Globals#BiomeTypes|BiomeType}} enumerated value"}, + StringToDamageType = {Params = "string", Return = "{{Globals#DamageType|DamageType}}", Notes = "Converts a string representation to a {{Globals#DamageType|DamageType}} enumerated value."}, + StringToDimension = {Params = "string", Return = "{{Globals#WorldDimension|Dimension}}", Notes = "Converts a string representation to a {{Globals#WorldDimension|Dimension}} enumerated value"}, StringToItem = {Params = "string, {{cItem|cItem}}", Return = "bool", Notes = "Parses the given string and sets the item; returns true if successful"}, - StringToMobType = {Params = "string", Return = "number", Notes = "Converts a string representation to a mob enumerated value"}, + StringToMobType = {Params = "string", Return = "{{cMonster#MobType|MobType}}", Notes = "Converts a string representation to a {{cMonster#MobType|MobType}} enumerated value"}, StripColorCodes = {Params = "string", Return = "string", Notes = "Removes all control codes used by MC for colors and styles"}, - TrimString = {Params = "string", Return = "string", Notes = "Trime whitespace at both ends of the string"}, + TrimString = {Params = "string", Return = "string", Notes = "Trims whitespace at both ends of the string"}, md5 = {Params = "string", Return = "string", Notes = "converts a string to an md5 hash"}, }, + ConstantGroups = + { + BlockTypes = + { + Include = "^E_BLOCK_.*", + TextBefore = [[ + These constants are used for block types. They correspond directly with MineCraft's data values + for blocks. + ]], + }, + ItemTypes = + { + Include = "^E_ITEM_.*", + TextBefore = [[ + These constants are used for item types. They correspond directly with MineCraft's data values + for items. + ]], + }, + MetaValues = + { + Include = "^E_META_.*", + }, + BiomeTypes = + { + Include = "^bi.*", + TextBefore = [[ + These constants represent the biomes that the server understands. Note that there is a global + StringToBiome() function that can convert a string into one of these constants. + ]], + }, + BlockFaces = + { + Include = "^BLOCK_FACE_.*", + TextBefore = [[ + These constants are used to describe individual faces of the block. They are used when the + client is interacting with a block, or when the {{cLineBlockTracer}} hits a block, etc. + ]], + }, + ClickAction = + { + Include = "^ca.*", + TextBefore = [[ + These constants are used to signalize various interactions that the user can do with the + {{cWindow|UI windows}}. The server translates the protocol events into these constants. Note + that there is a global ClickActionToString() function that can translate these constants into + their textual representation. + ]], + }, + WorldDimension = + { + Include = "^dim.*", + TextBefore = [[ + These constants represent dimension of a world. In MCServer, the dimension is only reflected in + the world's overall tint - overworld gets sky-like colors and dark shades, the nether gets + reddish haze and the end gets dark haze. World generator is not directly affected by the + dimension, same as fluid simulators; those only default to the expected values if not set + specifically otherwise in the world.ini file. + ]], + }, + DamageType = + { + Include = "^dt.*", + TextBefore = [[ + These constants are used for specifying the cause of damage to entities. They are used in the + {{TakeDamageInfo}} structure, as well as in {{cEntity}}'s damage-related API functions. + ]], + }, + GameMode = + { + Include = { "^gm.*", "^eGameMode_.*" }, + TextBefore = [[ + The following constants are used for the gamemode - survival, creative or adventure. Use the + gmXXX constants, the eGameMode_ constants are deprecated and will be removed from the API. + ]], + }, + Weather = + { + Include = { "^eWeather_.*", "wSunny", "wRain", "wStorm", "wThunderstorm" }, + TextBefore = [[ + These constants represent the weather in the world. Note that unlike vanilla, MCServer allows + different weathers even in non-overworld {{Globals#WorldDimension|dimensions}}. + ]], + }, + ExplosionSource = + { + Include = "^es.*", + TextBefore = [[ + These constants are used to differentiate the various sources of explosions. They are used in + the {{OnExploded|HOOK_EXPLODED}} hook, {{OnExploding|HOOK_EXPLODING}} hook and in the + {{cWorld}}:DoExplosionAt() function. These constants also dictate the type of the additional + data provided with the explosions, such as the exploding {{cCreeper|creeper}} entity or the + {{Vector3i|coords}} of the exploding bed. + ]], + } + }, }, -- Globals }, diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index 4dcedc06e..9c4fb17f8 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -576,7 +576,7 @@ function ReadDescriptions(a_API) for j, group in pairs(APIDesc.ConstantGroups) do group.Name = j; group.Constants = {}; - if (type(group.Include == "string")) then + if (type(group.Include) == "string") then group.Include = { group.Include }; end local NumInGroup = 0; @@ -820,20 +820,22 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) return; end + local Source = a_ClassAPI.Name if (a_InheritedName ~= nil) then cf:write("

    Constants inherited from ", a_InheritedName, "

    \n"); + Source = a_InheritedName; end if (#a_Constants > 0) then - WriteConstantTable(a_Constants, a_InheritedName or a_ClassAPI.Name); + WriteConstantTable(a_Constants, Source); end for k, group in pairs(a_ConstantGroups) do if ((a_InheritedName == nil) or group.ShowInDescendants) then cf:write("

    "); - cf:write(group.TextBefore or ""); + cf:write(LinkifyString(group.TextBefore or "", Source)); WriteConstantTable(group.Constants, a_InheritedName or a_ClassAPI.Name); - cf:write(group.TextAfter or "", "

    "); + cf:write(LinkifyString(group.TextAfter or "", Source), "

    "); end end end -- cgit v1.2.3 From cc77ffd0698ed9a533d8e06de53bab9380b45b80 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 23 Nov 2013 21:13:55 +0100 Subject: Documented sqlite functions. Used: http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki#sqlite3_functions --- MCServer/Plugins/APIDump/APIDesc.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index bdbea2351..82ba5ba45 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2668,6 +2668,24 @@ Parser:close(); }, -- AdditionalInfo }, -- lxp + sqlite3 = + { + Desc = [[ + ]], + + Functions = + { + complete = { Params = "string", Return = "bool", Notes = "Returns true if the string sql comprises one or more complete SQL statements and false otherwise." }, + open = { Params = "string", Return = "Userdata", Notes = [[Opens (or creates if it does not exist) an SQLite database with name filename and returns its handle as userdata (the returned object should be used for all further method calls in connection with this specific database, see {{http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki#database_methods|Database methods}}). Example:
    myDB=sqlite3.open('MyDatabase.sqlite3')  -- open
    +-- do some database calls...
    +myDB:close()  -- close
    +TakeDamageInfo =
    ]], }, + open_memory = { Return = "userdata", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, + temp_directory = { Params = "string", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, + version = { Return = "string", Notes = "Returns a string with SQLite version information, in the form 'x.y[.z]'." }, + }, + }, + TakeDamageInfo = { Desc = [[ -- cgit v1.2.3 From d9dc241e6fe669585d7c0b13d55818a22e1c76bc Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 23 Nov 2013 21:26:24 +0100 Subject: APIDump: The descriptions are read from multiple files. All the files in the Classes subfolder are read for class descriptions, and in the Hooks subfolder for the hook descriptions. --- MCServer/Plugins/APIDump/APIDesc.lua | 1729 +------------------- MCServer/Plugins/APIDump/Classes/BlockEntities.lua | 243 +++ .../Plugins/APIDump/Hooks/OnBlockToPickups.lua | 62 + MCServer/Plugins/APIDump/Hooks/OnChat.lua | 29 + .../Plugins/APIDump/Hooks/OnChunkAvailable.lua | 27 + .../Plugins/APIDump/Hooks/OnChunkGenerated.lua | 67 + .../Plugins/APIDump/Hooks/OnChunkGenerating.lua | 35 + MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua | 28 + .../Plugins/APIDump/Hooks/OnChunkUnloading.lua | 30 + .../Plugins/APIDump/Hooks/OnCollectingPickup.lua | 32 + .../Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua | 32 + MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua | 32 + .../Plugins/APIDump/Hooks/OnExecuteCommand.lua | 31 + MCServer/Plugins/APIDump/Hooks/OnExploded.lua | 49 + MCServer/Plugins/APIDump/Hooks/OnExploding.lua | 50 + MCServer/Plugins/APIDump/Hooks/OnHandshake.lua | 29 + .../Plugins/APIDump/Hooks/OnHopperPullingItem.lua | 30 + .../Plugins/APIDump/Hooks/OnHopperPushingItem.lua | 30 + MCServer/Plugins/APIDump/Hooks/OnKilling.lua | 33 + MCServer/Plugins/APIDump/Hooks/OnLogin.lua | 31 + .../Plugins/APIDump/Hooks/OnPlayerAnimation.lua | 28 + .../APIDump/Hooks/OnPlayerBreakingBlock.lua | 36 + .../Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua | 36 + MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua | 27 + MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua | 29 + .../Plugins/APIDump/Hooks/OnPlayerLeftClick.lua | 47 + MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua | 27 + .../Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua | 40 + .../Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua | 45 + .../Plugins/APIDump/Hooks/OnPlayerRightClick.lua | 37 + .../APIDump/Hooks/OnPlayerRightClickingEntity.lua | 27 + .../Plugins/APIDump/Hooks/OnPlayerShooting.lua | 32 + MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua | 32 + .../Plugins/APIDump/Hooks/OnPlayerTossingItem.lua | 30 + .../Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua | 46 + .../Plugins/APIDump/Hooks/OnPlayerUsedItem.lua | 46 + .../Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua | 46 + .../Plugins/APIDump/Hooks/OnPlayerUsingItem.lua | 47 + MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua | 36 + MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua | 37 + MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua | 31 + .../Plugins/APIDump/Hooks/OnSpawnedMonster.lua | 30 + .../Plugins/APIDump/Hooks/OnSpawningEntity.lua | 32 + .../Plugins/APIDump/Hooks/OnSpawningMonster.lua | 33 + MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua | 31 + MCServer/Plugins/APIDump/Hooks/OnTick.lua | 29 + MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua | 38 + MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua | 58 + .../Plugins/APIDump/Hooks/OnWeatherChanged.lua | 28 + .../Plugins/APIDump/Hooks/OnWeatherChanging.lua | 32 + MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua | 29 + MCServer/Plugins/APIDump/main_APIDump.lua | 33 + 52 files changed, 2059 insertions(+), 1705 deletions(-) create mode 100644 MCServer/Plugins/APIDump/Classes/BlockEntities.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnBlockToPickups.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnChat.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnChunkAvailable.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnChunkGenerated.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnChunkGenerating.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnCollectingPickup.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnExploded.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnExploding.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnHandshake.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnHopperPullingItem.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnHopperPushingItem.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnKilling.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnLogin.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerBreakingBlock.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerLeftClick.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerRightClickingEntity.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerShooting.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerTossingItem.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerUsedItem.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPlayerUsingItem.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnSpawnedMonster.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnSpawningMonster.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnTick.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnWeatherChanged.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua create mode 100644 MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 82ba5ba45..1ad5bf5e4 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -302,56 +302,6 @@ g_APIDesc = }, -- AdditionalInfo }, -- cBlockArea - cBlockEntity = - { - Desc = [[ - Block entities are simply blocks in the world that have persistent data, such as the text for a sign - or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. - The cBlockEntity class acts as a common ancestor for all the individual block entities. - ]], - - Functions = - { - GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" }, - GetChunkX = { Params = "", Return = "number", Notes = "Returns the chunk X-coord of the block entity's chunk" }, - GetChunkZ = { Params = "", Return = "number", Notes = "Returns the chunk Z-coord of the block entity's chunk" }, - GetPosX = { Params = "", Return = "number", Notes = "Returns the block X-coord of the block entity's block" }, - GetPosY = { Params = "", Return = "number", Notes = "Returns the block Y-coord of the block entity's block" }, - GetPosZ = { Params = "", Return = "number", Notes = "Returns the block Z-coord of the block entity's block" }, - GetRelX = { Params = "", Return = "number", Notes = "Returns the relative X coord of the block entity's block within the chunk" }, - GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" }, - GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" }, - }, - }, - - cBlockEntityWithItems = - { - Desc = [[ - This class is a common ancestor for all {{cBlockEntity|block entities}} that provide item storage. - Internally, the object has a {{cItemGrid|cItemGrid}} object for storing the items; this ItemGrid is - accessible through the API. The storage is a grid of items, items in it can be addressed either by a slot - number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage - is monitored for changes and the changes are immediately sent to clients of the UI window. - ]], - - Inherits = "cBlockEntity", - - Functions = - { - GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, - GetSlot = - { - { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, - { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, - }, - SetSlot = - { - { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, - { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, - }, - }, - }, - cBoundingBox = { Desc = [[ @@ -430,45 +380,6 @@ g_APIDesc = }, }, - cChestEntity = - { - Desc = [[ - A chest entity is a {{cBlockEntityWithItems|cBlockEntityWithItems}} descendant that represents a chest - in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate - in any way.

    -

    - To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with - either DoWithChestAt() or ForEachChestInChunk() function. See the code example below - ]], - - Inherits = "cBlockEntityWithItems", - - Constants = - { - ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, - ContentsWidth = { Notes = "Width of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, - }, - AdditionalInfo = - { - { - Header = "Code example", - Contents = [[ - The following example code sets the top-left item of each chest in the same chunk as Player to - 64 * diamond: -

    --- Player is a {{cPlayer}} object instance
    -local World = Player:GetWorld();
    -World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
    -	function (ChestEntity)
    -		ChestEntity:SetSlot(0, 0, cItem(E_ITEM_DIAMOND, 64));
    -	end
    -);
    -
    - ]], - }, - }, -- AdditionalInfo - }, - cChunkDesc = { Desc = [[ @@ -693,47 +604,6 @@ end }, }, -- cCuboid - cDispenserEntity = - { - Desc = [[ - This class represents a dispenser block entity in the world. Most of this block entity's - functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents - the behavior common with a {{cDropperEntity|dropper}} entity. - ]], - Inherits = "cDropSpenserEntity", - }, - - cDropperEntity = - { - Desc = [[ - This class represents a dropper block entity in the world. Most of this block entity's functionality - is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior - common with the {{cDispenserEntity|dispenser}} entity.

    -

    - An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). - ]], - Inherits = "cDropSpenserEntity", - }, -- cDropperEntity - - cDropSpenserEntity = - { - Desc = [[ - This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. - ]], - Functions = - { - Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" }, - AddDropSpenserDir = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "BlockX, BlockY, BlockZ", Notes = "Adjusts the block coords to where the dropspenser items materialize" }, - SetRedstonePower = { Params = "IsPowered", Return = "", Notes = "Sets the redstone status of the dropspenser. If the redstone power goes from off to on, the dropspenser will be activated" }, - }, - Constants = - { - ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, - ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, - }, - Inherits = "cBlockEntityWithItems"; - }, -- cDropSpenserEntity - cEnchantments = { Desc = [[ @@ -987,45 +857,6 @@ cFile:Delete("/usr/bin/virus.exe"); Inherits = "cProjectileEntity", } , - cFurnaceEntity = - { - Desc = [[ - This class represents a furnace block entity in the world.

    -

    - See also {{cRoot}}'s GetFurnaceRecipe() and GetFurnaceFuelBurnTime() functions - ]], - Functions = - { - GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" }, - GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" }, - GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" }, - GetInputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the input slot" }, - GetOutputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the output slot" }, - GetTimeCooked = { Params = "", Return = "number", Notes = "Returns the time that the current item has been cooking, in ticks" }, - HasFuelTimeLeft = { Params = "", Return = "bool", Notes = "Returns true if there's time before the current fuel is depleted" }, - SetFuelSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the fuel slot" }, - SetInputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the input slot" }, - SetOutputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the output slot" }, - }, - Constants = - { - fsInput = { Notes = "Index of the input slot" }, - fsFuel = { Notes = "Index of the fuel slot" }, - fsOutput = { Notes = "Index of the output slot" }, - ContentsWidth = { Notes = "Width (X) of the {{cItemGrid|cItemGrid}} representing the contents" }, - ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid|cItemGrid}} representing the contents" }, - }, - ConstantGroups = - { - SlotIndices = - { - Include = "fs.*", - TextBefore = "When using the GetSlot() or SetSlot() function, use these constants for slot index:", - }, - }, - Inherits = "cBlockEntityWithItems" - }, -- cFurnaceEntity - cGhastFireballEntity = { Desc = "", @@ -1052,24 +883,6 @@ cFile:Delete("/usr/bin/virus.exe"); }, }, -- cGroup - cHopperEntity = - { - Desc = [[ - This class represents a hopper block entity in the world. - ]], - Functions = - { - GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." }, - }, - Constants = - { - ContentsHeight = { Notes = "Height (Y) of the internal {{cItemGrid}} representing the hopper contents." }, - ContentsWidth = { Notes = "Width (X) of the internal {{cItemGrid}} representing the hopper contents." }, - TICKS_PER_TRANSFER = { Notes = "Number of ticks between when the hopper transfers items." }, - }, - Inherits = "cBlockEntityWithItems", - }, -- cHopperEntity - cIniFile = { Desc = [[ @@ -1512,22 +1325,6 @@ end }, }, -- cItems - cJukeboxEntity = - { - Desc = [[ - This class represents a jukebox in the world. It can play the records, either when the - {{cPlayer|player}} uses the record on the jukebox, or when a plugin instructs it to play. - ]], - Inherits = "cBlockEntity", - Functions = - { - EjectRecord = { Params = "", Return = "", Notes = "Ejects the current record as a {{cPickup|pickup}}. No action if there's no current record. To remove record without generating the pickup, use SetRecord(0)" }, - GetRecord = { Params = "", Return = "number", Notes = "Returns the record currently present. Zero for no record, E_ITEM_*_DISC for records." }, - PlayRecord = { Params = "", Return = "", Notes = "Plays the currently present record. No action if there's no current record." }, - SetRecord = { Params = "number", Return = "", Notes = "Sets the currently present record. Use zero for no record, or E_ITEM_*_DISC for records." }, - }, - }, -- cJukeboxEntity - cLineBlockTracer = { Desc = [[Objects of this class provide an easy-to-use interface to tracing lines through individual @@ -1775,25 +1572,6 @@ a_Player:OpenWindow(Window); Inherits = "cPawn", }, -- cMonster - cNoteEntity = - { - Desc = [[ - This class represents a note block entity in the world. It takes care of the note block's pitch, - and also can play the sound, either when the {{cPlayer|player}} right-clicks it, redstone activates - it, or upon a plugin's request.

    -

    - The pitch is stored as an integer between 0 and 24. - ]], - Functions = - { - GetPitch = { Params = "", Return = "number", Notes = "Returns the current pitch set for the block" }, - IncrementPitch = { Params = "", Return = "", Notes = "Adds 1 to the current pitch. Wraps around to 0 when the pitch cannot go any higher." }, - MakeSound = { Params = "", Return = "", Notes = "Plays the sound for all {{cClientHandle|clients}} near this block." }, - SetPitch = { Params = "Pitch", Return = "", Notes = "Sets a new pitch for the block." }, - }, - Inherits = "cBlockEntity", - }, -- cNoteEntity - cPawn = { Desc = [[cPawn is a controllable pawn object, controlled by either AI or a player. cPawn inherits all functions and members of {{cEntity}} @@ -2170,21 +1948,6 @@ end }, }, -- cServer - cSignEntity = - { - Desc = [[ - A sign entity represents a sign in the world. This class is only used when generating chunks, so - that the plugins may generate signs within new chunks. See the code example in {{cChunkDesc}}. - ]], - Functions = - { - GetLine = { Params = "LineIndex", Return = "string", Notes = "Returns the specified line. LineIndex is expected between 0 and 3. Returns empty string and logs to server console when LineIndex is invalid." }, - SetLine = { Params = "LineIndex, LineText", Return = "", Notes = "Sets the specified line. LineIndex is expected between 0 and 3. Logs to server console when LineIndex is invalid." }, - SetLines = { Params = "Line1, Line2, Line3, Line4", Return = "", Notes = "Sets all the sign's lines at once." }, - }, - Inherits = "cBlockEntity"; - }, -- cSignEntity - cThrownEggEntity = { Desc = "", @@ -2708,7 +2471,7 @@ TakeDamageInfo =

    ]], }, The TDI is passed as the second parameter in the HOOK_TAKE_DAMAGE hook, and can be used to modify the damage before it is applied to the receiver:
    -function Plugin:OnTakeDamage(Receiver, TDI)
    +function OnTakeDamage(Receiver, TDI)
     	LOG("Damage: Raw ".. TDI.RawDamage .. ", Final:" .. TDI.FinalDamage);
     
     	-- If the attacker is a spider, make it deal 999 points of damage (insta-death spiders):
    @@ -3018,1474 +2781,31 @@ end
     	},
     
     
    -	Hooks =
    +	IgnoreClasses =
     	{
    -		HOOK_BLOCK_TO_PICKUPS =
    -		{
    -			CalledWhen = "A block is about to be dug ({{cPlayer|player}}, {{cEntity|entity}} or natural reason), plugins may override what pickups that will produce.",
    -			DefaultFnName = "OnBlockToPickups",  -- also used as pagename
    -			Desc = [[
    -				This callback gets called whenever a block is about to be dug. This includes {{cPlayer|players}}
    -				digging blocks, entities causing blocks to disappear ({{cTNTEntity|TNT}}, Endermen) and natural
    -				causes (water washing away a block). Plugins may override the amount and kinds of pickups this
    -				action produces.
    -			]],
    -			Params =
    -			{
    -				{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
    -				{ Name = "Digger", Type = "{{cEntity}} descendant", Notes = "The entitycausing the digging. May be a {{cPlayer}}, {{cTNTEntity}} or even nil (natural causes)" },
    -				{ Name = "BlockX", Type = "number", Notes = "X-coord of the block" },
    -				{ Name = "BlockY", Type = "number", Notes = "Y-coord of the block" },
    -				{ Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" },
    -				{ Name = "BlockType", Type = "BLOCKTYPE", Notes = "Block type of the block" },
    -				{ Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "Block meta of the block" },
    -				{ Name = "Pickups", Type = "{{cItems}}", Notes = "Items that will be spawned as pickups" },
    -			},
    -			Returns = [[
    -				If the function returns false or no value, the next callback in the hook chain will be called. If
    -				the function returns true, no other callbacks in the chain will be called.

    -

    - Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable - pickups, you need to Clear the object first, then return true. - ]], - CodeExamples = - { - { - Title = "Modify pickups", - Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).", - Code = [[ -function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups) - if (a_Digger ~= nil) then - -- Not a natural cause - return false; - end - if (a_BlockType ~= E_BLOCK_TALL_GRASS) then - -- Not a tall grass being washed away - return false; - end - - -- Remove all pickups suggested by MCServer: - a_Pickups:Clear(); - - -- Drop a diamond: - a_Pickups:Add(cItem(E_ITEM_DIAMOND)); - return true; -end; - ]], - }, - } , -- CodeExamples - }, -- HOOK_BLOCK_TO_PICKUPS - - HOOK_CHAT = - { - CalledWhen = "Player sends a chat message", - DefaultFnName = "OnChat", -- also used as pagename - Desc = [[ - A plugin may implement an OnChat() function and register it as a Hook to process chat messages from - the players. The function is then called for every in-game message sent from any player. Note that - commands are handled separately using a command framework API. - ]], - Params = { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who sent the message" }, - { Name = "Message", Type = "string", Notes = "The message" }, - }, - Returns = [[ - The plugin may return 2 values. The first is a boolean specifying whether the hook handling is to be - stopped or not. If it is false, the message is broadcast to all players in the world. If it is true, - no message is broadcast and no further action is taken.

    -

    - The second value is specifies the message to broadcast. This way, plugins may modify the message. If - the second value is not provided, the original message is used. - ]], - }, -- HOOK_CHAT - - HOOK_CHUNK_AVAILABLE = - { - CalledWhen = "A chunk has just been added to world, either generated or loaded. ", - DefaultFnName = "OnChunkAvailable", -- also used as pagename - Desc = [[ - This hook is called after a chunk is either generated or loaded from the disk. The chunk is - already available for manipulation using the {{cWorld}} API. This is a notification-only callback, - there is no behavior that plugins could override. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk belongs" }, - { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, - { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. - ]], - }, -- HOOK_CHUNK_AVAILABLE - - HOOK_CHUNK_GENERATED = - { - CalledWhen = "After a chunk was generated. Notification only.", - DefaultFnName = "OnChunkGenerated", -- also used as pagename - Desc = [[ - This hook is called when world generator finished its work on a chunk. The chunk data has already - been generated and is about to be stored in the {{cWorld|world}}. A plugin may provide some - last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the - world, so regular {{cWorld}} block API will not work! Instead, use the {{cChunkDesc}} object - received as the parameter.

    -

    - See also the {{OnChunkGenerating|HOOK_CHUNK_GENERATING}} hook. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" }, - { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, - { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, - { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data. Plugins may still modify the chunk data contained." }, - }, - Returns = [[ - If the plugin returns false or no value, MCServer will call other plugins' callbacks for this event. - If a plugin returns true, no other callback is called for this event.

    -

    - In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world. - ]], - CodeExamples = - { - { - Title = "Generate emerald ore", - Desc = "This example callback function generates one block of emerald ore in each chunk, under the condition that the randomly chosen location is in an ExtremeHills biome.", - Code = [[ -function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) - -- Generate a psaudorandom value that is always the same for the same X/Z pair, but is otherwise random enough: - -- This is actually similar to how MCServer does its noise functions - local PseudoRandom = (a_ChunkX * 57 + a_ChunkZ) * 57 + 19785486 - PseudoRandom = PseudoRandom * 8192 + PseudoRandom; - PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff; - PseudoRandom = PseudoRandom / 7; - - -- Based on the PseudoRandom value, choose a location for the ore: - local OreX = PseudoRandom % 16; - local OreY = 2 + ((PseudoRandom / 16) % 20); - local OreZ = (PseudoRandom / 320) % 16; - - -- Check if the location is in ExtremeHills: - if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then - return false; - end - - -- Only replace allowed blocks with the ore: - local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ); - if ( - (CurrBlock == E_BLOCK_STONE) or - (CurrBlock == E_BLOCK_DIRT) or - (CurrBlock == E_BLOCK_GRAVEL) - ) then - a_ChunkDesc:SetBlockTypeMeta(OreX, OreY, OreZ, E_BLOCK_EMERALD_ORE, 0); - end -end; - ]], - }, - } , -- CodeExamples - }, -- HOOK_CHUNK_GENERATED - - HOOK_CHUNK_GENERATING = - { - CalledWhen = "A chunk is about to be generated. Plugin can override the built-in generator.", - DefaultFnName = "OnChunkGenerating", -- also used as pagename - Desc = [[ - This hook is called before the world generator starts generating a chunk. The plugin may provide - some or all parts of the generation, by-passing the built-in generator. The function is given access - to the {{cChunkDesc|ChunkDesc}} object representing the contents of the chunk. It may override parts - of the built-in generator by using the object's SetUseDefaultXXX(false) functions. After all - the callbacks for a chunk have been processed, the server will generate the chunk based on the - {{cChunkDesc|ChunkDesc}} description - those parts that are set for generating (by default - everything) are generated, the rest are read from the ChunkDesc object.

    -

    - See also the {{OnChunkGenerated|HOOK_CHUNK_GENERATED}} hook. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" }, - { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, - { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, - { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data." }, - }, - Returns = [[ - If this function returns true, the server will not call any other plugin with the same chunk. If - this function returns false, the server will call the rest of the plugins with the same chunk, - possibly overwriting the ChunkDesc's contents. - ]], - }, -- HOOK_CHUNK_GENERATING - - HOOK_CHUNK_UNLOADED = - { - CalledWhen = "A chunk has been unloaded from the memory.", - DefaultFnName = "OnChunkUnloaded", -- also used as pagename - Desc = [[ - This hook is called when a chunk is unloaded from the memory. Though technically still in memory, - the plugin should behave as if the chunk was already not present. In particular, {{cWorld}} block - API should not be used in the area of the specified chunk. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, - { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, - { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. There is no behavior that plugins could - override. - ]], - }, -- HOOK_CHUNK_UNLOADED - - HOOK_CHUNK_UNLOADING = - { - CalledWhen = " A chunk is about to be unloaded from the memory. Plugins may refuse the unload.", - DefaultFnName = "OnChunkUnloading", -- also used as pagename - Desc = [[ - MCServer calls this function when a chunk is about to be unloaded from the memory. A plugin may - force MCServer to keep the chunk in memory by returning true.

    -

    - FIXME: The return value should be used only for event propagation stopping, not for the actual - decision whether to unload. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, - { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, - { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called and finally MCServer - unloads the chunk. If the function returns true, no other callback is called for this event and the - chunk is left in the memory. - ]], - }, -- HOOK_CHUNK_UNLOADING - - HOOK_COLLECTING_PICKUP = - { - CalledWhen = "Player is about to collect a pickup. Plugin can refuse / override behavior. ", - DefaultFnName = "OnCollectingPickup", -- also used as pagename - Desc = [[ - This hook is called when a player is about to collect a pickup. Plugins may refuse the action.

    -

    - Pickup collection happens within the world tick, so if the collecting is refused, it will be tried - again in the next world tick, as long as the player is within reach of the pickup.

    -

    - FIXME: There is no OnCollectedPickup() callback.

    -

    - FIXME: This callback is called even if the pickup doesn't fit into the player's inventory.

    - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who's collecting the pickup" }, - { Name = "Pickup", Type = "{{cPickup}}", Notes = "The pickup being collected" }, - }, - Returns = [[ - If the function returns false or no value, MCServer calls other plugins' callbacks and finally the - pickup is collected. If the function returns true, no other plugins are called for this event and - the pickup is not collected. - ]], - }, -- HOOK_COLLECTING_PICKUP - - HOOK_CRAFTING_NO_RECIPE = - { - CalledWhen = " No built-in crafting recipe is found. Plugin may provide a recipe.", - DefaultFnName = "OnCraftingNoRecipe", -- also used as pagename - Desc = [[ - This callback is called when a player places items in their {{cCraftingGrid|crafting grid}} and - MCServer cannot find a built-in {{cCraftingRecipe|recipe}} for the combination. Plugins may provide - a recipe for the ingredients given. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose crafting is reported in this hook" }, - { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "Contents of the player's crafting grid" }, - { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that will be used (can be filled by plugins)" }, - }, - Returns = [[ - If the function returns false or no value, no recipe will be used. If the function returns true, no - other plugin will have their callback called for this event and MCServer will use the crafting - recipe in Recipe.

    -

    - FIXME: To allow plugins give suggestions and overwrite other plugins' suggestions, we should change - the behavior with returning false, so that the recipe will still be used, but fill the recipe with - empty values by default. - ]], - }, -- HOOK_CRAFTING_NO_RECIPE - - HOOK_DISCONNECT = - { - CalledWhen = "A player has explicitly disconnected.", - DefaultFnName = "OnDisconnect", -- also used as pagename - Desc = [[ - This hook is called when a client sends the disconnect packet and is about to be disconnected from - the server.

    -

    - Note that this callback is not called if the client drops the connection or is kicked by the - server.

    -

    - FIXME: There is no callback for "client destroying" that would be called in all circumstances.

    - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has disconnected" }, - { Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" }, - }, - Returns = [[ - If the function returns false or no value, MCServer calls other plugins' callbacks for this event - and finally broadcasts a disconnect message to the player's world. If the function returns true, no - other plugins are called for this event and the disconnect message is not broadcast. In either case, - the player is disconnected. - ]], - }, -- HOOK_DISCONNECT - - HOOK_EXECUTE_COMMAND = - { - CalledWhen = "A player executes an in-game command, or the admin issues a console command. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called.", - DefaultFnName = "OnExecuteCommand", -- also used as pagename - Desc = [[ - A plugin may implement a callback for this hook to intercept both in-game commands executed by the - players and console commands executed by the server admin. The function is called for every in-game - command sent from any player and for those server console commands that are not built in in the - server.

    -

    - If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's - executing the command. If the command comes from the server console, the first parameter is nil. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" }, - { Name = "Command", Type = "table of strings", Notes = "The command and its parameters, broken into a table by spaces" }, - }, - Returns = [[ - If the plugin returns true, the command will be blocked and none of the remaining hook handlers will - be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally - the command will be executed. - ]], - }, -- HOOK_EXECUTE_COMMAND + "coroutine", + "debug", + "io", + "math", + "package", + "os", + "string", + "table", + "g_TrackedPages", + "g_Stats", + }, - HOOK_EXPLODED = - { - CalledWhen = "An explosion has happened", - DefaultFnName = "OnExploded", -- also used as pagename - Desc = [[ - This hook is called after an explosion has been processed in a world.

    -

    - See also {{OnExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.

    -

    - The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, - etc. It also carries the identification of the actual source. The exact type of the identification - depends on the source kind: - - - - - - - - - - - - -
    SourceSourceData TypeNotes
    esPrimedTNT{{cTNTEntity}}An exploding primed TNT entity
    esCreeper{{cCreeper}}An exploding creeper or charged creeper
    esBed{{Vector3i}}A bed exploding in the Nether or in the End. The bed coords are given.
    esEnderCrystal{{Vector3i}}An ender crystal exploding upon hit. The block coords are given.
    esGhastFireball{{cGhastFireballEntity}}A ghast fireball hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlackTBDA black wither skull hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlueTBDA blue wither skull hitting ground or an {{cEntity|entity}}.
    esWitherBirthTBDA wither boss being created
    esOtherTBDAny other previously unspecified type.
    esPluginobjectAn explosion created by a plugin. The plugin may specify any kind of data.

    - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happened" }, - { Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" }, - { Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion has turned random air blocks to fire (such as a ghast fireball)" }, - { Name = "X", Type = "number", Notes = "X-coord of the explosion center" }, - { Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" }, - { Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" }, - { Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." }, - { Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. There is no overridable behaviour. - ]], - }, -- HOOK_EXPLODED - - HOOK_EXPLODING = - { - CalledWhen = "An explosion is about to be processed", - DefaultFnName = "OnExploding", -- also used as pagename - Desc = [[ - This hook is called before an explosion has been processed in a world.

    -

    - See also {{OnExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.

    -

    - The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, - etc. It also carries the identification of the actual source. The exact type of the identification - depends on the source kind: - - - - - - - - - - - - -
    SourceSourceData TypeNotes
    esPrimedTNT{{cTNTEntity}}An exploding primed TNT entity
    esCreeper{{cCreeper}}An exploding creeper or charged creeper
    esBed{{Vector3i}}A bed exploding in the Nether or in the End. The bed coords are given.
    esEnderCrystal{{Vector3i}}An ender crystal exploding upon hit. The block coords are given.
    esGhastFireball{{cGhastFireballEntity}}A ghast fireball hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlackTBDA black wither skull hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlueTBDA blue wither skull hitting ground or an {{cEntity|entity}}.
    esWitherBirthTBDA wither boss being created
    esOtherTBDAny other previously unspecified type.
    esPluginobjectAn explosion created by a plugin. The plugin may specify any kind of data.

    - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happens" }, - { Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" }, - { Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion will turn random air blocks to fire (such as a ghast fireball)" }, - { Name = "X", Type = "number", Notes = "X-coord of the explosion center" }, - { Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" }, - { Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" }, - { Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." }, - { Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called, and finally - MCServer will process the explosion - destroy blocks and push + hurt entities. If the function - returns true, no other callback is called for this event and the explosion will not occur. - ]], - }, -- HOOK_EXPLODING - - HOOK_HANDSHAKE = - { - CalledWhen = "A client is connecting.", - DefaultFnName = "OnHandshake", -- also used as pagename - Desc = [[ - This hook is called when a client sends the Handshake packet. At this stage, only the client IP and - (unverified) username are known. Plugins may refuse access to the server based on this - information.

    -

    - Note that the username is not authenticated - the authentication takes place only after this hook is - processed. - ]], - Params = - { - { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection. Note that there's no {{cPlayer}} object for this client yet." }, - { Name = "UserName", Type = "string", Notes = "The username presented in the packet. Note that this username is unverified." }, - }, - Returns = [[ - If the function returns false, the user is let in to the server. If the function returns true, no - other plugin's callback is called, the user is kicked and the connection is closed. - ]], - }, -- HOOK_HANDSHAKE - - HOOK_HOPPER_PULLING_ITEM = - { - CalledWhen = "A hopper is pulling an item from another block entity.", - DefaultFnName = "OnHopperPullingItem", -- also used as pagename - Desc = [[ - This callback is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from another - block entity into its own internal storage. A plugin may decide to disallow the move by returning - true. Note that in such a case, the hook may be called again for the same hopper, with different - slot numbers. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" }, - { Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pulling the item" }, - { Name = "DstSlot", Type = "number", Notes = "The destination slot in the hopper's {{cItemGrid|internal storage}}" }, - { Name = "SrcBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = "The block entity that is losing the item" }, - { Name = "SrcSlot", Type = "number", Notes = "Slot in SrcBlockEntity from which the item will be pulled" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event and the hopper will not pull the item. - ]], - }, -- HOOK_HOPPER_PULLING_ITEM - - HOOK_HOPPER_PUSHING_ITEM = - { - CalledWhen = "A hopper is pushing an item into another block entity. ", - DefaultFnName = "OnHopperPushingItem", -- also used as pagename - Desc = [[ - This hook is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from its own - internal storage into another block entity. A plugin may decide to disallow the move by returning - true. Note that in such a case, the hook may be called again for the same hopper and block, with - different slot numbers. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" }, - { Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pushing the item" }, - { Name = "SrcSlot", Type = "number", Notes = "Slot in the hopper that will lose the item" }, - { Name = "DstBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = " The block entity that will receive the item" }, - { Name = "DstSlot", Type = "number", Notes = " Slot in DstBlockEntity's internal storage where the item will be stored" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event and the hopper will not push the item. - ]], - }, -- HOOK_HOPPER_PUSHING_ITEM - - HOOK_KILLING = - { - CalledWhen = "A player or a mob is dying.", - DefaultFnName = "OnKilling", -- also used as pagename - Desc = [[ - This hook is called whenever a {{cPawn|pawn}}'s (a player's or a mob's) health reaches zero. This - means that the pawn is about to be killed, unless a plugin "revives" them by setting their health - back to a positive value.

    -

    - FIXME: There is no HOOK_KILLED notification hook yet; this is deliberate because HOOK_KILLED has - been recently renamed to HOOK_KILLING, and plugins need to be updated. Once updated, the HOOK_KILLED - notification will be implemented. - ]], - Params = - { - { Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" }, - { Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" }, - }, - Returns = [[ - If the function returns false or no value, MCServer calls other plugins with this event. If the - function returns true, no other plugin is called for this event.

    -

    - In either case, the victim's health is then re-checked and if it is greater than zero, the victim is - "revived" with that health amount. If the health is less or equal to zero, the victim is killed. - ]], - }, -- HOOK_KILLING - - HOOK_LOGIN = - { - CalledWhen = "Right before player authentication. If auth is disabled, right after the player sends their name.", - DefaultFnName = "OnLogin", -- also used as pagename - Desc = [[ - This hook is called whenever a client logs in. It is called right before the client's name is sent - to be authenticated. Plugins may refuse the client from accessing the server. Note that when this - callback is called, the {{cPlayer}} object for this client doesn't exist yet - the client has no - representation in any world. To process new players when their world is known, use a later callback, - such as {{OnPlayerJoined|HOOK_PLAYER_JOINED}} or {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}. - ]], - Params = - { - { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection" }, - { Name = "ProtocolVersion", Type = "number", Notes = "Versio of the protocol that the client is talking" }, - { Name = "UserName", Type = "string", Notes = "The name that the client has presented for authentication. This name will be given to the {{cPlayer}} object when it is created for this client." }, - }, - Returns = [[ - If the function returns true, no other plugins are called for this event and the client is kicked. - If the function returns false or no value, MCServer calls other plugins' callbacks and finally - sends an authentication request for the client's username to the auth server. If the auth server - is disabled in the server settings, the player object is immediately created. - ]], - }, -- HOOK_LOGIN - - HOOK_PLAYER_ANIMATION = - { - CalledWhen = "A client has sent an Animation packet (0x12)", - DefaultFnName = "OnPlayerAnimation", -- also used as pagename - Desc = [[ - This hook is called when the server receives an Animation packet (0x12) from the client.

    -

    - For the list of animations that are sent by the client, see the - Protocol wiki. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, - { Name = "Animation", Type = "number", Notes = "The kind of animation" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. Afterwards, the - server broadcasts the animation packet to all nearby clients. If the function returns true, no other - callback is called for this event and the packet is not broadcasted. - ]], - }, -- HOOK_PLAYER_ANIMATION - - HOOK_PLAYER_BREAKING_BLOCK = - { - CalledWhen = "Just before a player breaks a block. Plugin may override / refuse. ", - DefaultFnName = "OnPlayerBreakingBlock", -- also used as pagename - Desc = [[ - This hook is called when a {{cPlayer|player}} breaks a block, before the block is actually broken in - the {{cWorld|World}}. Plugins may refuse the breaking.

    -

    - See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after - the block is broken. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is digging the block" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player is acting. One of the BLOCK_FACE_ constants" }, - { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block being broken" }, - { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block being broken " }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called, and then the block - is broken. If the function returns true, no other plugin's callback is called and the block breaking - is cancelled. The server re-sends the block back to the player to replace it (the player's client - already thinks the block was broken). - ]], - }, -- HOOK_PLAYER_BREAKING_BLOCK - - HOOK_PLAYER_BROKEN_BLOCK = - { - CalledWhen = "After a player has broken a block. Notification only.", - DefaultFnName = "OnPlayerBrokenBlock", -- also used as pagename - Desc = [[ - This function is called after a {{cPlayer|player}} breaks a block. The block is already removed - from the {{cWorld|world}} and {{cPickup|pickups}} have been spawned. To get the world in which the - block has been dug, use the {{cPlayer}}:GetWorld() function.

    -

    - See also the {{OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK}} hook for a similar hook called - before the block is broken. To intercept the creation of pickups, see the - {{OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS}} hook. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who broke the block" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, - { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, - { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. - ]], - }, -- HOOK_PLAYER_BROKEN_BLOCK - - HOOK_PLAYER_EATING = - { - CalledWhen = "When the player starts eating", - DefaultFnName = "OnPlayerEating", -- also used as pagename - Desc = [[ - This hook gets called when the {{cPlayer|player}} starts eating, after the server checks that the - player can indeed eat (is not satiated and is holding food). Plugins may still refuse the eating by - returning true. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who started eating" }, - }, - Returns = [[ - If the function returns false or no value, the server calls the next plugin handler, and finally - lets the player eat. If the function returns true, the server doesn't call any more callbacks for - this event and aborts the eating. A "disallow" packet is sent to the client. - ]], - }, -- HOOK_PLAYER_EATING - - HOOK_PLAYER_JOINED = - { - CalledWhen = "After Login and before Spawned, before being added to world. ", - DefaultFnName = "OnPlayerJoined", -- also used as pagename - Desc = [[ - This hook is called whenever a {{cPlayer|player}} has completely logged in. If authentication is - enabled, this function is called after their name has been authenticated. It is called after - {{OnLogin|HOOK_LOGIN}} and before {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}, right after the player's - entity is created, but not added to the world yet. The player is not yet visible to other players. - This is a notification-only event, plugins wishing to refuse player's entry should kick the player - using the {{cPlayer}}:Kick() function. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has joined the game" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called for this event. Either way the player is let in. - ]], - }, -- HOOK_PLAYER_JOINED - - HOOK_PLAYER_LEFT_CLICK = - { - CalledWhen = "A left-click packet is received from the client. Plugin may override / refuse.", - DefaultFnName = "OnPlayerLeftClick", -- also used as pagename - Desc = [[ - This hook is called when MCServer receives a left-click packet from the {{cClientHandle|client}}. It - is called before any processing whatsoever is performed on the packet, meaning that hacked / - malicious clients may be trigerring this event very often and with unchecked parameters. Therefore - plugin authors are advised to use extreme caution with this callback.

    -

    - Plugins may refuse the default processing for the packet, causing MCServer to behave as if the - packet has never arrived. This may, however, create inconsistencies in the client - the client may - think that they broke a block, while the server didn't process the breaking, etc. For this reason, - if a plugin refuses the processing, MCServer sends the block specified in the packet back to the - client (as if placed anew), if the status code specified a block-break action. For other actions, - plugins must rectify the situation on their own.

    -

    - The client sends the left-click packet for several other occasions, such as dropping the held item - (Q keypress) or shooting an arrow. This is reflected in the Status code. Consult the - protocol documentation for details on the actions. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, - { Name = "Action", Type = "number", Notes = "Action to be performed on the block (\"status\" in the protocol docs)" }, - }, - Returns = [[ - If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends - the packet for further processing.

    -

    - If the function returns true, no other plugins are called, processing is halted. If the action was a - block dig, MCServer sends the block specified in the coords back to the client. The packet is - dropped. - ]], - }, -- HOOK_PLAYER_LEFT_CLICK - - HOOK_PLAYER_MOVING = - { - CalledWhen = "Player tried to move in the tick being currently processed. Plugin may refuse movement.", - DefaultFnName = "OnPlayerMoving", -- also used as pagename - Desc = [[ - This function is called in each server tick for each {{cPlayer|player}} that has sent any of the - player-move packets. Plugins may refuse the movement. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has moved. The object already has the new position stored in it." }, - }, - Returns = [[ - If the function returns true, movement is prohibited. FIXME: The player's client is not informed.

    -

    - If the function returns false or no value, other plugins' callbacks are called and finally the new - position is permanently stored in the cPlayer object.

    - ]], - }, -- HOOK_PLAYER_MOVING - - HOOK_PLAYER_PLACED_BLOCK = - { - CalledWhen = "After a player has placed a block. Notification only.", - DefaultFnName = "OnPlayerPlacedBlock", -- also used as pagename - Desc = [[ - This hook is called after a {{cPlayer|player}} has placed a block in the {{cWorld|world}}. The block - is already added to the world and the corresponding item removed from player's - {{cInventory|inventory}}.

    -

    - Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.

    -

    - See also the {{OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK}} hook for a similar hook called - before the placement. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who placed the block" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player interacted. One of the BLOCK_FACE_ constants" }, - { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" }, - { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" }, - { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" }, - { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, - { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, - }, - Returns = [[ - If this function returns false or no value, MCServer calls other plugins with the same event. If - this function returns true, no other plugin is called for this event. - ]], - }, -- HOOK_PLAYER_PLACED_BLOCK - - HOOK_PLAYER_PLACING_BLOCK = - { - CalledWhen = "Just before a player places a block. Plugin may override / refuse.", - DefaultFnName = "OnPlayerPlacingBlock", -- also used as pagename - Desc = [[ - This hook is called just before a {{cPlayer|player}} places a block in the {{cWorld|world}}. The - block is not yet placed, plugins may choose to override the default behavior or refuse the placement - at all.

    -

    - Note that the client already expects that the block has been placed. For that reason, if a plugin - refuses the placement, MCServer sends the old block at the provided coords to the client.

    -

    - Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.

    -

    - See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after - the placement. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is placing the block" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player is interacting. One of the BLOCK_FACE_ constants" }, - { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" }, - { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" }, - { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" }, - { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, - { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, - }, - Returns = [[ - If this function returns false or no value, MCServer calls other plugins with the same event and - finally places the block and removes the corresponding item from player's inventory. If this - function returns true, no other plugin is called for this event, MCServer sends the old block at - the specified coords to the client and drops the packet. - ]], - }, -- HOOK_PLAYER_PLACING_BLOCK - - HOOK_PLAYER_RIGHT_CLICK = - { - CalledWhen = "A right-click packet is received from the client. Plugin may override / refuse.", - DefaultFnName = "OnPlayerRightClick", -- also used as pagename - Desc = [[ - This hook is called when MCServer receives a right-click packet from the {{cClientHandle|client}}. It - is called before any processing whatsoever is performed on the packet, meaning that hacked / - malicious clients may be trigerring this event very often and with unchecked parameters. Therefore - plugin authors are advised to use extreme caution with this callback.

    -

    - Plugins may refuse the default processing for the packet, causing MCServer to behave as if the - packet has never arrived. This may, however, create inconsistencies in the client - the client may - think that they placed a block, while the server didn't process the placing, etc. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, - }, - Returns = [[ - If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends - the packet for further processing.

    -

    - If the function returns true, no other plugins are called, processing is halted. - ]], - }, -- HOOK_PLAYER_RIGHT_CLICK - - HOOK_PLAYER_RIGHT_CLICKING_ENTITY = - { - CalledWhen = "A player has right-clicked an entity. Plugins may override / refuse.", - DefaultFnName = "OnPlayerRightClickingEntity", -- also used as pagename - Desc = [[ - This hook is called when the {{cPlayer|player}} right-clicks an {{cEntity|entity}}. Plugins may - override the default behavior or even cancel the default processing. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has right-clicked the entity" }, - { Name = "Entity", Type = "{{cEntity}} descendant", Notes = "The entity that has been right-clicked" }, - }, - Returns = [[ - If the functino returns false or no value, MCServer calls other plugins' callbacks and finally does - the default processing for the right-click. If the function returns true, no other callbacks are - called and the default processing is skipped. - ]], - }, -- HOOK_PLAYER_RIGHT_CLICKING_ENTITY - - HOOK_PLAYER_SHOOTING = - { - CalledWhen = "When the player releases the bow, shooting an arrow (other projectiles: unknown)", - DefaultFnName = "OnPlayerShooting", -- also used as pagename - Desc = [[ - This hook is called when the {{cPlayer|player}} shoots their bow. It is called for the actual - release of the {{cArrowEntity|arrow}}. FIXME: It is currently unknown whether other - {{cProjectileEntity|projectiles}} (snowballs, eggs) trigger this hook.

    -

    - To get the player's position and direction, use the {{cPlayer}}:GetEyePosition() and - cPlayer:GetLookVector() functions. Note that for shooting a bow, the position for the arrow creation - is not at the eye pos, some adjustments are required. FIXME: Export the {{cPlayer}} function for - this adjustment. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player shooting" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called, and finally - MCServer creates the projectile. If the functino returns true, no other callback is called and no - projectile is created. - ]], - }, -- HOOK_PLAYER_SHOOTING - - HOOK_PLAYER_SPAWNED = - { - CalledWhen = "After a player (re)spawns in the world to which they belong to.", - DefaultFnName = "OnPlayerSpawned", -- also used as pagename - Desc = [[ - This hook is called after a {{cPlayer|player}} has spawned in the world. It is called after - {{OnLogin|HOOK_LOGIN}} and {{OnPlayerJoined|HOOK_PLAYER_JOINED}}, after the player name has been - authenticated, the initial worldtime, inventory and health have been sent to the player and the - player spawn packet has been broadcast to all players near enough to the player spawn place. This is - a notification-only event, plugins wishing to refuse player's entry should kick the player using the - {{cPlayer}}:Kick() function.

    -

    - This hook is also called when the player respawns after death (and a respawn packet is received from - the client, meaning the player has already clicked the Respawn button). - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has (re)spawned" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called for this event. There is no overridable behavior. - ]], - }, -- HOOK_PLAYER_SPAWNED - - HOOK_PLAYER_TOSSING_ITEM = - { - CalledWhen = "A player is tossing an item. Plugin may override / refuse.", - DefaultFnName = "OnPlayerTossingItem", -- also used as pagename - Desc = [[ - This hook is called when a {{cPlayer|player}} has tossed an item (Q keypress). The - {{cPickup|pickup}} has not been spawned yet. Plugins may disallow the tossing, but in that case they - need to clean up - the player's client already thinks the item has been tossed so the - {{cInventory|inventory}} needs to be re-sent to the player.

    -

    - To get the item that is about to be tossed, call the {{cPlayer}}:GetEquippedItem() function. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player tossing an item" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called and finally MCServer - creates the pickup for the item and tosses it, using {{cPlayer}}:TossItem. If the function returns - true, no other callbacks are called for this event and MCServer doesn't toss the item. - ]], - }, -- HOOK_PLAYER_TOSSING_ITEM - - HOOK_PLAYER_USED_BLOCK = - { - CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", - DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename - Desc = [[ - This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a - {{cChestEntity|chest}} or a lever. It is called after MCServer processes the usage (sends the UI - handling packets / toggles redstone). Note that for UI-related blocks, the player is most likely - still using the UI. This is a notification-only event.

    -

    - Note that the block coords given in this callback are for the (solid) block that is being clicked, - not the air block between it and the player.

    -

    - To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.

    -

    - See also the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} for a similar hook called before the - use, the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} - for similar hooks called when a player interacts with any block with a usable item in hand, such as - a bucket. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the block" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, - { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, - { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, - { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called for this event. - ]], - }, -- HOOK_PLAYER_USED_BLOCK - - HOOK_PLAYER_USED_ITEM = - { - CalledWhen = "A player has used an item in hand (bucket...)", - DefaultFnName = "OnPlayerUsedItem", -- also used as pagename - Desc = [[ - This hook is called after a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that - can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a - hoe. It is called after MCServer processes the usage (places fluid / turns dirt to farmland). - This is an information-only hook, there is no way to cancel the event anymore.

    -

    - Note that the block coords given in this callback are for the (solid) block that is being clicked, - not the air block between it and the player.

    -

    - To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get - the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.

    -

    - See also the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} for a similar hook called before the use, - the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} - for similar hooks called when a player interacts with a block, such as a chest. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the item" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, - { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, - { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, - { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called for this event. - ]], - }, -- HOOK_PLAYER_USED_ITEM - - HOOK_PLAYER_USING_BLOCK = - { - CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.", - DefaultFnName = "OnPlayerUsingBlock", -- also used as pagename - Desc = [[ - This hook is called when a {{cPlayer|player}} has right-clicked a block that can be used, such as a - {{cChestEntity|chest}} or a lever. It is called before MCServer processes the usage (sends the UI - handling packets / toggles redstone). Plugins may refuse the interaction by returning true.

    -

    - Note that the block coords given in this callback are for the (solid) block that is being clicked, - not the air block between it and the player.

    -

    - To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.

    -

    - See also the {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for a similar hook called after the use, the - {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for - similar hooks called when a player interacts with any block with a usable item in hand, such as a - bucket. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the block" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, - { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, - { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, - { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called and then MCServer - processes the interaction. If the function returns true, no other callbacks are called for this - event and the interaction is silently dropped. - ]], - }, -- HOOK_PLAYER_USING_BLOCK - - HOOK_PLAYER_USING_ITEM = - { - CalledWhen = "Just before a player uses an item in hand (bucket...). Plugin may override / refuse.", - DefaultFnName = "OnPlayerUsingItem", -- also used as pagename - Desc = [[ - This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that - can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a - hoe. It is called before MCServer processes the usage (places fluid / turns dirt to farmland). - Plugins may refuse the interaction by returning true.

    -

    - Note that the block coords given in this callback are for the (solid) block that is being clicked, - not the air block between it and the player.

    -

    - To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get - the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.

    -

    - See also the {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for a similar hook called after the use, the - {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for - similar hooks called when a player interacts with a block, such as a chest. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the item" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, - { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, - { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, - { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, - { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, - { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called and then MCServer - processes the interaction. If the function returns true, no other callbacks are called for this - event and the interaction is silently dropped. - ]], - }, -- HOOK_PLAYER_USING_ITEM - - HOOK_POST_CRAFTING = - { - CalledWhen = "After the built-in recipes are checked and a recipe was found.", - DefaultFnName = "OnPostCrafting", -- also used as pagename - Desc = [[ - This hook is called when a {{cPlayer|player}} changes contents of their - {{cCraftingGrid|crafting grid}}, after the recipe has been established by MCServer. Plugins may use - this to modify the resulting recipe or provide an alternate recipe.

    -

    - If a plugin implements custom recipes, it should do so using the {{OnPreCrafting|HOOK_PRE_CRAFTING}} - hook, because that will save the server from going through the built-in recipes. The - HOOK_POST_CRAFTING hook is intended as a notification, with a chance to tweak the result.

    -

    - Note that this hook is not called if a built-in recipe is not found; - {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}} is called instead in such a case. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, - { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, - { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer has decided to use (can be tweaked by plugins)" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called for this event. In either case, MCServer uses the value - of Recipe as the recipe to be presented to the player. - ]], - }, -- HOOK_POST_CRAFTING - - HOOK_PRE_CRAFTING = - { - CalledWhen = "Before the built-in recipes are checked.", - DefaultFnName = "OnPreCrafting", -- also used as pagename - Desc = [[ - This hook is called when a {{cPlayer|player}} changes contents of their - {{cCraftingGrid|crafting grid}}, before the built-in recipes are searched for a match by MCServer. - Plugins may use this hook to provide a custom recipe.

    -

    - If you intend to tweak built-in recipes, use the {{OnPostCrafting|HOOK_POST_CRAFTING}} hook, because - that will be called once the built-in recipe is matched.

    -

    - Also note a third hook, {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}}, that is called when MCServer - cannot find any built-in recipe for the given ingredients. - ]], - Params = - { - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, - { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, - { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer will use. Modify this object to change the recipe" }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called and then MCServer - searches the built-in recipes. The Recipe output parameter is ignored in this case.

    -

    - If the function returns true, no other callbacks are called for this event and MCServer uses the - recipe stored in the Recipe output parameter. - ]], - }, -- HOOK_PRE_CRAFTING - - HOOK_SPAWNED_ENTITY = - { - CalledWhen = "After an entity is spawned in the world.", - DefaultFnName = "OnSpawnedEntity", -- also used as pagename - Desc = [[ - This hook is called after the server spawns an {{cEntity|entity}}. This is an information-only - callback, the entity is already spawned by the time it is called. If the entity spawned is a - {{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this - hook.

    -

    - See also the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} hook for a similar hook called before the - entity is spawned. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity has spawned" }, - { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that has spawned" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. - ]], - }, -- HOOK_SPAWNED_ENTITY - - HOOK_SPAWNED_MONSTER = - { - CalledWhen = "After a monster is spawned in the world", - DefaultFnName = "OnSpawnedMonster", -- also used as pagename - Desc = [[ - This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only - callback, the monster is already spawned by the time it is called. After this hook is called, the - {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity.

    -

    - See also the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook for a similar hook called before the - monster is spawned. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the monster has spawned" }, - { Name = "Monster", Type = "{{cMonster}} descendant", Notes = "The monster that has spawned" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. - ]], - }, -- HOOK_SPAWNED_MONSTER - - HOOK_SPAWNING_ENTITY = - { - CalledWhen = "Before an entity is spawned in the world.", - DefaultFnName = "OnSpawningEntity", -- also used as pagename - Desc = [[ - This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the - entity before it is spawned, or disable the spawning altogether. If the entity spawning is a - monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook is called before this hook.

    -

    - See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the - entity is spawned. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, - { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that will spawn" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. Finally, the server - spawns the entity with whatever parameters have been set on the {{cEntity}} object by the callbacks. - If the function returns true, no other callback is called for this event and the entity is not - spawned. - ]], - }, -- HOOK_SPAWNING_ENTITY - - HOOK_SPAWNING_MONSTER = - { - CalledWhen = "Before a monster is spawned in the world.", - DefaultFnName = "OnSpawningMonster", -- also used as pagename - Desc = [[ - This hook is called before the server spawns a {{cMonster|monster}}. The plugins may modify the - monster's parameters in the {{cMonster}} class, or disallow the spawning altogether. This hook is - called before the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} is called for the monster entity.

    -

    - See also the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook for a similar hook called after the - monster is spawned. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, - { Name = "Monster", Type = "{{cMonster}} descentant", Notes = "The monster that will spawn" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. Finally, the server - spawns the monster with whatever parameters the plugins set in the cMonster parameter.

    -

    - If the function returns true, no other callback is called for this event and the monster won't - spawn. - ]], - }, -- HOOK_SPAWNING_MONSTER - - HOOK_TAKE_DAMAGE = - { - CalledWhen = "An {{cEntity|entity}} is taking any kind of damage", - DefaultFnName = "OnTakeDamage", -- also used as pagename - Desc = [[ - This hook is called when any {{cEntity}} descendant, such as a {{cPlayer|player}} or a - {{cMonster|mob}}, takes any kind of damage. The plugins may modify the amount of damage or effects - with this hook by editting the {{TakeDamageInfo}} object passed.

    -

    - This hook is called after the final damage is calculated, including all the possible weapon - {{cEnchantments|enchantments}}, armor protection and potion effects. - ]], - Params = - { - { Name = "Receiver", Type = "{{cEntity}} descendant", Notes = "The entity taking damage" }, - { Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects. Plugins may modify this object to alter the final damage applied." }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called and then the server - applies the final values from the TDI object to Receiver. If the function returns true, no other - callbacks are called, and no damage nor effects are applied. - ]], - }, -- HOOK_TAKE_DAMAGE - - HOOK_TICK = - { - CalledWhen = "Every server tick (approximately 20 times per second)", - DefaultFnName = "OnTick", -- also used as pagename - Desc = [[ - This hook is called every game tick (50 msec, or 20 times a second). If the server is overloaded, - the interval is larger, which is indicated by the TimeDelta parameter.

    -

    - This hook is called in the context of the server-tick thread, that is, the thread that takes care of - {{cClientHandle|client connections}} before they're assigned to {{cPlayer|player entities}}, and - processing console commands. - ]], - Params = - { - { Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds elapsed since the last server tick. Will not be less than 50 msec." }, - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called. There is no overridable behavior. - ]], - }, -- HOOK_TICK - - HOOK_UPDATED_SIGN = - { - CalledWhen = "After the sign text is updated. Notification only.", - DefaultFnName = "OnUpdatedSign", -- also used as pagename - Desc = [[ - This hook is called after a sign has had its text updated. The text is already updated at this - point.

    -

    The update may have been caused either by a {{cPlayer|player}} directly updating the sign, or by - a plugin changing the sign text using the API.

    -

    - See also the {{OnUpdatingSign|HOOK_UPDATING_SIGN}} hook for a similar hook called before the update, - with a chance to modify the text. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the sign" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" }, - { Name = "Line1", Type = "string", Notes = "1st line of the new text" }, - { Name = "Line2", Type = "string", Notes = "2nd line of the new text" }, - { Name = "Line3", Type = "string", Notes = "3rd line of the new text" }, - { Name = "Line4", Type = "string", Notes = "4th line of the new text" }, - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." } - }, - Returns = [[ - If the function returns false or no value, other plugins' callbacks are called. If the function - returns true, no other callbacks are called. There is no overridable behavior. - ]], - }, -- HOOK_UPDATED_SIGN - HOOK_UPDATING_SIGN = - { - CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.", - DefaultFnName = "OnUpdatingSign", -- also used as pagename - Desc = [[ - This hook is called when a sign text is about to be updated, either as a result of player's - manipulation or any other event, such as a plugin setting the sign text. Plugins may modify the text - or refuse the update altogether.

    -

    - See also the {{OnUpdatedSign|HOOK_UPDATED_SIGN}} hook for a similar hook called after the update. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" }, - { Name = "BlockX", Type = "number", Notes = "X-coord of the sign" }, - { Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" }, - { Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" }, - { Name = "Line1", Type = "string", Notes = "1st line of the new text" }, - { Name = "Line2", Type = "string", Notes = "2nd line of the new text" }, - { Name = "Line3", Type = "string", Notes = "3rd line of the new text" }, - { Name = "Line4", Type = "string", Notes = "4th line of the new text" }, - { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." } - }, - Returns = [[ - The function may return up to five values. If the function returns true as the first value, no other - callbacks are called for this event and the sign is not updated. If the function returns no value or - false as its first value, other plugins' callbacks are called.

    -

    - The other up to four values returned are used to update the sign text, line by line, respectively. - Note that other plugins may again update the texts (if the first value returned is false). - ]], - CodeExamples = - { - { - Title = "Add player signature", - Desc = "The following example appends a player signature to the last line, if the sign is updated by a player:", - Code = [[ -function OnUpdatingSign(World, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player) - if (Player == nil) then - -- Not changed by a player - return false; - end - - -- Sign with playername, allow other plugins to interfere: - return false, Line1, Line2, Line3, Line4 .. Player:GetName(); -end - ]], - } - } , - }, -- HOOK_UPDATING_SIGN - - HOOK_WEATHER_CHANGED = - { - CalledWhen = "The weather has changed", - DefaultFnName = "OnWeatherChanged", -- also used as pagename - Desc = [[ - This hook is called after the weather has changed in a {{cWorld|world}}. The new weather has already - been sent to the clients.

    -

    - See also the {{OnWeatherChanging|HOOK_WEATHER_CHANGING}} hook for a similar hook called before the - change. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather has changed" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. There is no overridable behavior. - ]], - }, -- HOOK_WEATHER_CHANGED - - HOOK_WEATHER_CHANGING = - { - CalledWhen = "The weather is about to change", - DefaultFnName = "OnWeatherChanging", -- also used as pagename - Desc = [[ - This hook is called when the current weather has expired and a new weather is selected. Plugins may - override the new weather setting.

    -

    - The new weather setting is sent to the clients only after this hook has been processed.

    -

    - See also the {{OnWeatherChanged|HOOK_WEATHER_CHANGED}} hook for a similar hook called after the - change. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather is changing" }, - { Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" }, - }, - Returns = [[ - If the function returns false or no value, the server calls other plugins' callbacks and finally - sets the weather. If the function returns true, the server takes the second returned value (wSunny - by default) and sets it as the new weather. No other plugins' callbacks are called in this case. - ]], - }, -- HOOK_WEATHER_CHANGING - - HOOK_WORLD_TICK = - { - CalledWhen = "Every world tick (about 20 times per second), separately for each world", - DefaultFnName = "OnWorldTick", -- also used as pagename - Desc = [[ - This hook is called for each {{cWorld|world}} every tick (50 msec, or 20 times a second). If the - world is overloaded, the interval is larger, which is indicated by the TimeDelta parameter.

    -

    - This hook is called in the world's tick thread context and thus has access to all world data - guaranteed without blocking. - ]], - Params = - { - { Name = "World", Type = "{{cWorld}}", Notes = "World that is ticking" }, - { Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds since the previous game tick. Will not be less than 50 msec" }, - }, - Returns = [[ - If the function returns false or no value, the next plugin's callback is called. If the function - returns true, no other callback is called for this event. There is no overridable behavior. - ]], - }, -- HOOK_WORLD_TICK - - }, -- Hooks[] - - - IgnoreClasses = - { - "coroutine", - "debug", - "io", - "math", - "package", - "os", - "string", - "table", - "g_TrackedPages", - "g_Stats", - }, - - IgnoreFunctions = - { - "Globals.assert", - "Globals.collectgarbage", - "Globals.xpcall", - "Globals.decoda_output", -- When running under Decoda, this function gets added to the global namespace - "%a+\.__%a+", -- AnyClass.__Anything - "%a+\.\.collector", -- AnyClass..collector - "%a+\.new", -- AnyClass.new - "%a+.new_local", -- AnyClass.new_local - "%a+.delete", -- AnyClass.delete + IgnoreFunctions = + { + "Globals.assert", + "Globals.collectgarbage", + "Globals.xpcall", + "Globals.decoda_output", -- When running under Decoda, this function gets added to the global namespace + "%a+\.__%a+", -- AnyClass.__Anything + "%a+\.\.collector", -- AnyClass..collector + "%a+\.new", -- AnyClass.new + "%a+.new_local", -- AnyClass.new_local + "%a+.delete", -- AnyClass.delete -- Functions global in the APIDump plugin: "CreateAPITables", @@ -4518,4 +2838,3 @@ end - diff --git a/MCServer/Plugins/APIDump/Classes/BlockEntities.lua b/MCServer/Plugins/APIDump/Classes/BlockEntities.lua new file mode 100644 index 000000000..cf258160c --- /dev/null +++ b/MCServer/Plugins/APIDump/Classes/BlockEntities.lua @@ -0,0 +1,243 @@ +return +{ + cBlockEntity = + { + Desc = [[ + Block entities are simply blocks in the world that have persistent data, such as the text for a sign + or contents of a chest. All block entities are also saved in the chunk data of the chunk they reside in. + The cBlockEntity class acts as a common ancestor for all the individual block entities. + ]], + + Functions = + { + GetBlockType = { Params = "", Return = "BLOCKTYPE", Notes = "Returns the blocktype which is represented by this blockentity. This is the primary means of type-identification" }, + GetChunkX = { Params = "", Return = "number", Notes = "Returns the chunk X-coord of the block entity's chunk" }, + GetChunkZ = { Params = "", Return = "number", Notes = "Returns the chunk Z-coord of the block entity's chunk" }, + GetPosX = { Params = "", Return = "number", Notes = "Returns the block X-coord of the block entity's block" }, + GetPosY = { Params = "", Return = "number", Notes = "Returns the block Y-coord of the block entity's block" }, + GetPosZ = { Params = "", Return = "number", Notes = "Returns the block Z-coord of the block entity's block" }, + GetRelX = { Params = "", Return = "number", Notes = "Returns the relative X coord of the block entity's block within the chunk" }, + GetRelZ = { Params = "", Return = "number", Notes = "Returns the relative Z coord of the block entity's block within the chunk" }, + GetWorld = { Params = "", Return = "{{cWorld|cWorld}}", Notes = "Returns the world to which the block entity belongs" }, + }, + }, + + cBlockEntityWithItems = + { + Desc = [[ + This class is a common ancestor for all {{cBlockEntity|block entities}} that provide item storage. + Internally, the object has a {{cItemGrid|cItemGrid}} object for storing the items; this ItemGrid is + accessible through the API. The storage is a grid of items, items in it can be addressed either by a slot + number, or by XY coords within the grid. If a UI window is opened for this block entity, the item storage + is monitored for changes and the changes are immediately sent to clients of the UI window. + ]], + + Inherits = "cBlockEntity", + + Functions = + { + GetContents = { Params = "", Return = "{{cItemGrid|cItemGrid}}", Notes = "Returns the cItemGrid object representing the items stored within this block entity" }, + GetSlot = + { + { Params = "SlotNum", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot number. Returns nil for invalid slot numbers" }, + { Params = "X, Y", Return = "{{cItem|cItem}}", Notes = "Returns the cItem for the specified slot coords. Returns nil for invalid slot coords" }, + }, + SetSlot = + { + { Params = "SlotNum, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot number. Ignored if invalid slot number" }, + { Params = "X, Y, {{cItem|cItem}}", Return = "", Notes = "Sets the cItem for the specified slot coords. Ignored if invalid slot coords" }, + }, + }, + }, + + cChestEntity = + { + Desc = [[ + A chest entity is a {{cBlockEntityWithItems|cBlockEntityWithItems}} descendant that represents a chest + in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate + in any way.

    +

    + To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with + either DoWithChestAt() or ForEachChestInChunk() function. See the code example below + ]], + + Inherits = "cBlockEntityWithItems", + + Constants = + { + ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, + ContentsWidth = { Notes = "Width of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, + }, + AdditionalInfo = + { + { + Header = "Code example", + Contents = [[ + The following example code sets the top-left item of each chest in the same chunk as Player to + 64 * diamond: +

    +-- Player is a {{cPlayer}} object instance
    +local World = Player:GetWorld();
    +World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
    +	function (ChestEntity)
    +		ChestEntity:SetSlot(0, 0, cItem(E_ITEM_DIAMOND, 64));
    +	end
    +);
    +
    + ]], + }, + }, -- AdditionalInfo + }, + + cDispenserEntity = + { + Desc = [[ + This class represents a dispenser block entity in the world. Most of this block entity's + functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents + the behavior common with a {{cDropperEntity|dropper}} entity. + ]], + Inherits = "cDropSpenserEntity", + }, + + cDropperEntity = + { + Desc = [[ + This class represents a dropper block entity in the world. Most of this block entity's functionality + is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior + common with the {{cDispenserEntity|dispenser}} entity.

    +

    + An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). + ]], + Inherits = "cDropSpenserEntity", + }, -- cDropperEntity + + cDropSpenserEntity = + { + Desc = [[ + This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. + ]], + Functions = + { + Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" }, + AddDropSpenserDir = { Params = "BlockX, BlockY, BlockZ, BlockMeta", Return = "BlockX, BlockY, BlockZ", Notes = "Adjusts the block coords to where the dropspenser items materialize" }, + SetRedstonePower = { Params = "IsPowered", Return = "", Notes = "Sets the redstone status of the dropspenser. If the redstone power goes from off to on, the dropspenser will be activated" }, + }, + Constants = + { + ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, + ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, + }, + Inherits = "cBlockEntityWithItems"; + }, -- cDropSpenserEntity + + cFurnaceEntity = + { + Desc = [[ + This class represents a furnace block entity in the world.

    +

    + See also {{cRoot}}'s GetFurnaceRecipe() and GetFurnaceFuelBurnTime() functions + ]], + Functions = + { + GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" }, + GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" }, + GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" }, + GetInputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the input slot" }, + GetOutputSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the output slot" }, + GetTimeCooked = { Params = "", Return = "number", Notes = "Returns the time that the current item has been cooking, in ticks" }, + HasFuelTimeLeft = { Params = "", Return = "bool", Notes = "Returns true if there's time before the current fuel is depleted" }, + SetFuelSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the fuel slot" }, + SetInputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the input slot" }, + SetOutputSlot = { Params = "{{cItem|cItem}}", Return = "", Notes = "Sets the item in the output slot" }, + }, + Constants = + { + fsInput = { Notes = "Index of the input slot" }, + fsFuel = { Notes = "Index of the fuel slot" }, + fsOutput = { Notes = "Index of the output slot" }, + ContentsWidth = { Notes = "Width (X) of the {{cItemGrid|cItemGrid}} representing the contents" }, + ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid|cItemGrid}} representing the contents" }, + }, + ConstantGroups = + { + SlotIndices = + { + Include = "fs.*", + TextBefore = "When using the GetSlot() or SetSlot() function, use these constants for slot index:", + }, + }, + Inherits = "cBlockEntityWithItems" + }, -- cFurnaceEntity + + cHopperEntity = + { + Desc = [[ + This class represents a hopper block entity in the world. + ]], + Functions = + { + GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." }, + }, + Constants = + { + ContentsHeight = { Notes = "Height (Y) of the internal {{cItemGrid}} representing the hopper contents." }, + ContentsWidth = { Notes = "Width (X) of the internal {{cItemGrid}} representing the hopper contents." }, + TICKS_PER_TRANSFER = { Notes = "Number of ticks between when the hopper transfers items." }, + }, + Inherits = "cBlockEntityWithItems", + }, -- cHopperEntity + + cJukeboxEntity = + { + Desc = [[ + This class represents a jukebox in the world. It can play the records, either when the + {{cPlayer|player}} uses the record on the jukebox, or when a plugin instructs it to play. + ]], + Inherits = "cBlockEntity", + Functions = + { + EjectRecord = { Params = "", Return = "", Notes = "Ejects the current record as a {{cPickup|pickup}}. No action if there's no current record. To remove record without generating the pickup, use SetRecord(0)" }, + GetRecord = { Params = "", Return = "number", Notes = "Returns the record currently present. Zero for no record, E_ITEM_*_DISC for records." }, + PlayRecord = { Params = "", Return = "", Notes = "Plays the currently present record. No action if there's no current record." }, + SetRecord = { Params = "number", Return = "", Notes = "Sets the currently present record. Use zero for no record, or E_ITEM_*_DISC for records." }, + }, + }, -- cJukeboxEntity + + cNoteEntity = + { + Desc = [[ + This class represents a note block entity in the world. It takes care of the note block's pitch, + and also can play the sound, either when the {{cPlayer|player}} right-clicks it, redstone activates + it, or upon a plugin's request.

    +

    + The pitch is stored as an integer between 0 and 24. + ]], + Functions = + { + GetPitch = { Params = "", Return = "number", Notes = "Returns the current pitch set for the block" }, + IncrementPitch = { Params = "", Return = "", Notes = "Adds 1 to the current pitch. Wraps around to 0 when the pitch cannot go any higher." }, + MakeSound = { Params = "", Return = "", Notes = "Plays the sound for all {{cClientHandle|clients}} near this block." }, + SetPitch = { Params = "Pitch", Return = "", Notes = "Sets a new pitch for the block." }, + }, + Inherits = "cBlockEntity", + }, -- cNoteEntity + + cSignEntity = + { + Desc = [[ + A sign entity represents a sign in the world. This class is only used when generating chunks, so + that the plugins may generate signs within new chunks. See the code example in {{cChunkDesc}}. + ]], + Functions = + { + GetLine = { Params = "LineIndex", Return = "string", Notes = "Returns the specified line. LineIndex is expected between 0 and 3. Returns empty string and logs to server console when LineIndex is invalid." }, + SetLine = { Params = "LineIndex, LineText", Return = "", Notes = "Sets the specified line. LineIndex is expected between 0 and 3. Logs to server console when LineIndex is invalid." }, + SetLines = { Params = "Line1, Line2, Line3, Line4", Return = "", Notes = "Sets all the sign's lines at once." }, + }, + Inherits = "cBlockEntity"; + }, -- cSignEntity +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnBlockToPickups.lua b/MCServer/Plugins/APIDump/Hooks/OnBlockToPickups.lua new file mode 100644 index 000000000..e6f115f37 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnBlockToPickups.lua @@ -0,0 +1,62 @@ +return +{ + HOOK_BLOCK_TO_PICKUPS = + { + CalledWhen = "A block is about to be dug ({{cPlayer|player}}, {{cEntity|entity}} or natural reason), plugins may override what pickups that will produce.", + DefaultFnName = "OnBlockToPickups", -- also used as pagename + Desc = [[ + This callback gets called whenever a block is about to be dug. This includes {{cPlayer|players}} + digging blocks, entities causing blocks to disappear ({{cTNTEntity|TNT}}, Endermen) and natural + causes (water washing away a block). Plugins may override the amount and kinds of pickups this + action produces. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" }, + { Name = "Digger", Type = "{{cEntity}} descendant", Notes = "The entity causing the digging. May be a {{cPlayer}}, {{cTNTEntity}} or even nil (natural causes)" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "Block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "Block meta of the block" }, + { Name = "Pickups", Type = "{{cItems}}", Notes = "Items that will be spawned as pickups" }, + }, + Returns = [[ + If the function returns false or no value, the next callback in the hook chain will be called. If + the function returns true, no other callbacks in the chain will be called.

    +

    + Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable + pickups, you need to Clear the object first, then return true. + ]], + CodeExamples = + { + { + Title = "Modify pickups", + Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).", + Code = [[ +function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups) + if (a_Digger ~= nil) then + -- Not a natural cause + return false; + end + if (a_BlockType ~= E_BLOCK_TALL_GRASS) then + -- Not a tall grass being washed away + return false; + end + + -- Remove all pickups suggested by MCServer: + a_Pickups:Clear(); + + -- Drop a diamond: + a_Pickups:Add(cItem(E_ITEM_DIAMOND)); + return true; +end; + ]], + }, + } , -- CodeExamples + }, -- HOOK_BLOCK_TO_PICKUPS +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnChat.lua b/MCServer/Plugins/APIDump/Hooks/OnChat.lua new file mode 100644 index 000000000..d98df008a --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnChat.lua @@ -0,0 +1,29 @@ +return +{ + HOOK_CHAT = + { + CalledWhen = "Player sends a chat message", + DefaultFnName = "OnChat", -- also used as pagename + Desc = [[ + A plugin may implement an OnChat() function and register it as a Hook to process chat messages from + the players. The function is then called for every in-game message sent from any player. Note that + commands are handled separately using a command framework API. + ]], + Params = { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who sent the message" }, + { Name = "Message", Type = "string", Notes = "The message" }, + }, + Returns = [[ + The plugin may return 2 values. The first is a boolean specifying whether the hook handling is to be + stopped or not. If it is false, the message is broadcast to all players in the world. If it is true, + no message is broadcast and no further action is taken.

    +

    + The second value is specifies the message to broadcast. This way, plugins may modify the message. If + the second value is not provided, the original message is used. + ]], + }, -- HOOK_CHAT +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnChunkAvailable.lua b/MCServer/Plugins/APIDump/Hooks/OnChunkAvailable.lua new file mode 100644 index 000000000..61c191c57 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnChunkAvailable.lua @@ -0,0 +1,27 @@ +return +{ + HOOK_CHUNK_AVAILABLE = + { + CalledWhen = "A chunk has just been added to world, either generated or loaded. ", + DefaultFnName = "OnChunkAvailable", -- also used as pagename + Desc = [[ + This hook is called after a chunk is either generated or loaded from the disk. The chunk is + already available for manipulation using the {{cWorld}} API. This is a notification-only callback, + there is no behavior that plugins could override. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk belongs" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_CHUNK_AVAILABLE +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnChunkGenerated.lua b/MCServer/Plugins/APIDump/Hooks/OnChunkGenerated.lua new file mode 100644 index 000000000..b10dc36f5 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnChunkGenerated.lua @@ -0,0 +1,67 @@ +return +{ + HOOK_CHUNK_GENERATED = + { + CalledWhen = "After a chunk was generated. Notification only.", + DefaultFnName = "OnChunkGenerated", -- also used as pagename + Desc = [[ + This hook is called when world generator finished its work on a chunk. The chunk data has already + been generated and is about to be stored in the {{cWorld|world}}. A plugin may provide some + last-minute finishing touches to the generated data. Note that the chunk is not yet stored in the + world, so regular {{cWorld}} block API will not work! Instead, use the {{cChunkDesc}} object + received as the parameter.

    +

    + See also the {{OnChunkGenerating|HOOK_CHUNK_GENERATING}} hook. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data. Plugins may still modify the chunk data contained." }, + }, + Returns = [[ + If the plugin returns false or no value, MCServer will call other plugins' callbacks for this event. + If a plugin returns true, no other callback is called for this event.

    +

    + In either case, MCServer will then store the data from ChunkDesc as the chunk's contents in the world. + ]], + CodeExamples = + { + { + Title = "Generate emerald ore", + Desc = "This example callback function generates one block of emerald ore in each chunk, under the condition that the randomly chosen location is in an ExtremeHills biome.", + Code = [[ +function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) + -- Generate a psaudorandom value that is always the same for the same X/Z pair, but is otherwise random enough: + -- This is actually similar to how MCServer does its noise functions + local PseudoRandom = (a_ChunkX * 57 + a_ChunkZ) * 57 + 19785486 + PseudoRandom = PseudoRandom * 8192 + PseudoRandom; + PseudoRandom = ((PseudoRandom * (PseudoRandom * PseudoRandom * 15731 + 789221) + 1376312589) % 0x7fffffff; + PseudoRandom = PseudoRandom / 7; + + -- Based on the PseudoRandom value, choose a location for the ore: + local OreX = PseudoRandom % 16; + local OreY = 2 + ((PseudoRandom / 16) % 20); + local OreZ = (PseudoRandom / 320) % 16; + + -- Check if the location is in ExtremeHills: + if (a_ChunkDesc:GetBiome(OreX, OreZ) ~= biExtremeHills) then + return false; + end + + -- Only replace allowed blocks with the ore: + local CurrBlock = a_ChunDesc:GetBlockType(OreX, OreY, OreZ); + if ( + (CurrBlock == E_BLOCK_STONE) or + (CurrBlock == E_BLOCK_DIRT) or + (CurrBlock == E_BLOCK_GRAVEL) + ) then + a_ChunkDesc:SetBlockTypeMeta(OreX, OreY, OreZ, E_BLOCK_EMERALD_ORE, 0); + end +end; + ]], + }, + } , -- CodeExamples + }, -- HOOK_CHUNK_GENERATED +} \ No newline at end of file diff --git a/MCServer/Plugins/APIDump/Hooks/OnChunkGenerating.lua b/MCServer/Plugins/APIDump/Hooks/OnChunkGenerating.lua new file mode 100644 index 000000000..0db0e2727 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnChunkGenerating.lua @@ -0,0 +1,35 @@ +return +{ + HOOK_CHUNK_GENERATING = + { + CalledWhen = "A chunk is about to be generated. Plugin can override the built-in generator.", + DefaultFnName = "OnChunkGenerating", -- also used as pagename + Desc = [[ + This hook is called before the world generator starts generating a chunk. The plugin may provide + some or all parts of the generation, by-passing the built-in generator. The function is given access + to the {{cChunkDesc|ChunkDesc}} object representing the contents of the chunk. It may override parts + of the built-in generator by using the object's SetUseDefaultXXX(false) functions. After all + the callbacks for a chunk have been processed, the server will generate the chunk based on the + {{cChunkDesc|ChunkDesc}} description - those parts that are set for generating (by default + everything) are generated, the rest are read from the ChunkDesc object.

    +

    + See also the {{OnChunkGenerated|HOOK_CHUNK_GENERATED}} hook. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world to which the chunk will be added" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + { Name = "ChunkDesc", Type = "{{cChunkDesc}}", Notes = "Generated chunk data." }, + }, + Returns = [[ + If this function returns true, the server will not call any other plugin with the same chunk. If + this function returns false, the server will call the rest of the plugins with the same chunk, + possibly overwriting the ChunkDesc's contents. + ]], + }, -- HOOK_CHUNK_GENERATING +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua b/MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua new file mode 100644 index 000000000..a67d5d461 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnChunkUnloaded.lua @@ -0,0 +1,28 @@ +return +{ + HOOK_CHUNK_UNLOADED = + { + CalledWhen = "A chunk has been unloaded from the memory.", + DefaultFnName = "OnChunkUnloaded", -- also used as pagename + Desc = [[ + This hook is called when a chunk is unloaded from the memory. Though technically still in memory, + the plugin should behave as if the chunk was already not present. In particular, {{cWorld}} block + API should not be used in the area of the specified chunk. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no behavior that plugins could + override. + ]], + }, -- HOOK_CHUNK_UNLOADED +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua b/MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua new file mode 100644 index 000000000..cd79e2a13 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnChunkUnloading.lua @@ -0,0 +1,30 @@ +return +{ + HOOK_CHUNK_UNLOADING = + { + CalledWhen = " A chunk is about to be unloaded from the memory. Plugins may refuse the unload.", + DefaultFnName = "OnChunkUnloading", -- also used as pagename + Desc = [[ + MCServer calls this function when a chunk is about to be unloaded from the memory. A plugin may + force MCServer to keep the chunk in memory by returning true.

    +

    + FIXME: The return value should be used only for event propagation stopping, not for the actual + decision whether to unload. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world from which the chunk is unloading" }, + { Name = "ChunkX", Type = "number", Notes = "X-coord of the chunk" }, + { Name = "ChunkZ", Type = "number", Notes = "Z-coord of the chunk" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called and finally MCServer + unloads the chunk. If the function returns true, no other callback is called for this event and the + chunk is left in the memory. + ]], + }, -- HOOK_CHUNK_UNLOADING +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnCollectingPickup.lua b/MCServer/Plugins/APIDump/Hooks/OnCollectingPickup.lua new file mode 100644 index 000000000..0a56df2c9 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnCollectingPickup.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_COLLECTING_PICKUP = + { + CalledWhen = "Player is about to collect a pickup. Plugin can refuse / override behavior. ", + DefaultFnName = "OnCollectingPickup", -- also used as pagename + Desc = [[ + This hook is called when a player is about to collect a pickup. Plugins may refuse the action.

    +

    + Pickup collection happens within the world tick, so if the collecting is refused, it will be tried + again in the next world tick, as long as the player is within reach of the pickup.

    +

    + FIXME: There is no OnCollectedPickup() callback.

    +

    + FIXME: This callback is called even if the pickup doesn't fit into the player's inventory.

    + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who's collecting the pickup" }, + { Name = "Pickup", Type = "{{cPickup}}", Notes = "The pickup being collected" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally the + pickup is collected. If the function returns true, no other plugins are called for this event and + the pickup is not collected. + ]], + }, -- HOOK_COLLECTING_PICKUP +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua b/MCServer/Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua new file mode 100644 index 000000000..5137bbb25 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnCraftingNoRecipe.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_CRAFTING_NO_RECIPE = + { + CalledWhen = " No built-in crafting recipe is found. Plugin may provide a recipe.", + DefaultFnName = "OnCraftingNoRecipe", -- also used as pagename + Desc = [[ + This callback is called when a player places items in their {{cCraftingGrid|crafting grid}} and + MCServer cannot find a built-in {{cCraftingRecipe|recipe}} for the combination. Plugins may provide + a recipe for the ingredients given. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose crafting is reported in this hook" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "Contents of the player's crafting grid" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that will be used (can be filled by plugins)" }, + }, + Returns = [[ + If the function returns false or no value, no recipe will be used. If the function returns true, no + other plugin will have their callback called for this event and MCServer will use the crafting + recipe in Recipe.

    +

    + FIXME: To allow plugins give suggestions and overwrite other plugins' suggestions, we should change + the behavior with returning false, so that the recipe will still be used, but fill the recipe with + empty values by default. + ]], + }, -- HOOK_CRAFTING_NO_RECIPE +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua b/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua new file mode 100644 index 000000000..496e0d751 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnDisconnect.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_DISCONNECT = + { + CalledWhen = "A player has explicitly disconnected.", + DefaultFnName = "OnDisconnect", -- also used as pagename + Desc = [[ + This hook is called when a client sends the disconnect packet and is about to be disconnected from + the server.

    +

    + Note that this callback is not called if the client drops the connection or is kicked by the + server.

    +

    + FIXME: There is no callback for "client destroying" that would be called in all circumstances.

    + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has disconnected" }, + { Name = "Reason", Type = "string", Notes = "The reason that the client has sent in the disconnect packet" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks for this event + and finally broadcasts a disconnect message to the player's world. If the function returns true, no + other plugins are called for this event and the disconnect message is not broadcast. In either case, + the player is disconnected. + ]], + }, -- HOOK_DISCONNECT +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua new file mode 100644 index 000000000..dadc4e94f --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnExecuteCommand.lua @@ -0,0 +1,31 @@ +return +{ + HOOK_EXECUTE_COMMAND = + { + CalledWhen = "A player executes an in-game command, or the admin issues a console command. Note that built-in console commands are exempt to this hook - they are always performed and the hook is not called.", + DefaultFnName = "OnExecuteCommand", -- also used as pagename + Desc = [[ + A plugin may implement a callback for this hook to intercept both in-game commands executed by the + players and console commands executed by the server admin. The function is called for every in-game + command sent from any player and for those server console commands that are not built in in the + server.

    +

    + If the command is in-game, the first parameter to the hook function is the {{cPlayer|player}} who's + executing the command. If the command comes from the server console, the first parameter is nil. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "For in-game commands, the player who has sent the message. For console commands, nil" }, + { Name = "Command", Type = "table of strings", Notes = "The command and its parameters, broken into a table by spaces" }, + }, + Returns = [[ + If the plugin returns true, the command will be blocked and none of the remaining hook handlers will + be called. If the plugin returns false, MCServer calls all the remaining hook handlers and finally + the command will be executed. + ]], + }, -- HOOK_EXECUTE_COMMAND +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnExploded.lua b/MCServer/Plugins/APIDump/Hooks/OnExploded.lua new file mode 100644 index 000000000..6a01542ab --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnExploded.lua @@ -0,0 +1,49 @@ +return +{ + HOOK_EXPLODED = + { + CalledWhen = "An explosion has happened", + DefaultFnName = "OnExploded", -- also used as pagename + Desc = [[ + This hook is called after an explosion has been processed in a world.

    +

    + See also {{OnExploding|HOOK_EXPLODING}} for a similar hook called before the explosion.

    +

    + The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, + etc. It also carries the identification of the actual source. The exact type of the identification + depends on the source kind: + + + + + + + + + + + + +
    SourceSourceData TypeNotes
    esPrimedTNT{{cTNTEntity}}An exploding primed TNT entity
    esCreeper{{cCreeper}}An exploding creeper or charged creeper
    esBed{{Vector3i}}A bed exploding in the Nether or in the End. The bed coords are given.
    esEnderCrystal{{Vector3i}}An ender crystal exploding upon hit. The block coords are given.
    esGhastFireball{{cGhastFireballEntity}}A ghast fireball hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlackTBDA black wither skull hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlueTBDA blue wither skull hitting ground or an {{cEntity|entity}}.
    esWitherBirthTBDA wither boss being created
    esOtherTBDAny other previously unspecified type.
    esPluginobjectAn explosion created by a plugin. The plugin may specify any kind of data.

    + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happened" }, + { Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" }, + { Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion has turned random air blocks to fire (such as a ghast fireball)" }, + { Name = "X", Type = "number", Notes = "X-coord of the explosion center" }, + { Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" }, + { Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" }, + { Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." }, + { Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no overridable behaviour. + ]], + }, -- HOOK_EXPLODED +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnExploding.lua b/MCServer/Plugins/APIDump/Hooks/OnExploding.lua new file mode 100644 index 000000000..729f2e162 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnExploding.lua @@ -0,0 +1,50 @@ +return +{ + HOOK_EXPLODING = + { + CalledWhen = "An explosion is about to be processed", + DefaultFnName = "OnExploding", -- also used as pagename + Desc = [[ + This hook is called before an explosion has been processed in a world.

    +

    + See also {{OnExploded|HOOK_EXPLODED}} for a similar hook called after the explosion.

    +

    + The explosion carries with it the type of its source - whether it's a creeper exploding, or TNT, + etc. It also carries the identification of the actual source. The exact type of the identification + depends on the source kind: + + + + + + + + + + + + +
    SourceSourceData TypeNotes
    esPrimedTNT{{cTNTEntity}}An exploding primed TNT entity
    esCreeper{{cCreeper}}An exploding creeper or charged creeper
    esBed{{Vector3i}}A bed exploding in the Nether or in the End. The bed coords are given.
    esEnderCrystal{{Vector3i}}An ender crystal exploding upon hit. The block coords are given.
    esGhastFireball{{cGhastFireballEntity}}A ghast fireball hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlackTBDA black wither skull hitting ground or an {{cEntity|entity}}.
    esWitherSkullBlueTBDA blue wither skull hitting ground or an {{cEntity|entity}}.
    esWitherBirthTBDA wither boss being created
    esOtherTBDAny other previously unspecified type.
    esPluginobjectAn explosion created by a plugin. The plugin may specify any kind of data.

    + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world where the explosion happens" }, + { Name = "ExplosionSize", Type = "number", Notes = "The relative explosion size" }, + { Name = "CanCauseFire", Type = "bool", Notes = "True if the explosion will turn random air blocks to fire (such as a ghast fireball)" }, + { Name = "X", Type = "number", Notes = "X-coord of the explosion center" }, + { Name = "Y", Type = "number", Notes = "Y-coord of the explosion center" }, + { Name = "Z", Type = "number", Notes = "Z-coord of the explosion center" }, + { Name = "Source", Type = "eExplosionSource", Notes = "Source of the explosion. See the table above." }, + { Name = "SourceData", Type = "varies", Notes = "Additional data for the source. The exact type varies by the source. See the table above." }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called, and finally + MCServer will process the explosion - destroy blocks and push + hurt entities. If the function + returns true, no other callback is called for this event and the explosion will not occur. + ]], + }, -- HOOK_EXPLODING +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnHandshake.lua b/MCServer/Plugins/APIDump/Hooks/OnHandshake.lua new file mode 100644 index 000000000..6183cc506 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnHandshake.lua @@ -0,0 +1,29 @@ +return +{ + HOOK_HANDSHAKE = + { + CalledWhen = "A client is connecting.", + DefaultFnName = "OnHandshake", -- also used as pagename + Desc = [[ + This hook is called when a client sends the Handshake packet. At this stage, only the client IP and + (unverified) username are known. Plugins may refuse access to the server based on this + information.

    +

    + Note that the username is not authenticated - the authentication takes place only after this hook is + processed. + ]], + Params = + { + { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection. Note that there's no {{cPlayer}} object for this client yet." }, + { Name = "UserName", Type = "string", Notes = "The username presented in the packet. Note that this username is unverified." }, + }, + Returns = [[ + If the function returns false, the user is let in to the server. If the function returns true, no + other plugin's callback is called, the user is kicked and the connection is closed. + ]], + }, -- HOOK_HANDSHAKE +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnHopperPullingItem.lua b/MCServer/Plugins/APIDump/Hooks/OnHopperPullingItem.lua new file mode 100644 index 000000000..b268a76be --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnHopperPullingItem.lua @@ -0,0 +1,30 @@ +return +{ + HOOK_HOPPER_PULLING_ITEM = + { + CalledWhen = "A hopper is pulling an item from another block entity.", + DefaultFnName = "OnHopperPullingItem", -- also used as pagename + Desc = [[ + This callback is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from another + block entity into its own internal storage. A plugin may decide to disallow the move by returning + true. Note that in such a case, the hook may be called again for the same hopper, with different + slot numbers. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" }, + { Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pulling the item" }, + { Name = "DstSlot", Type = "number", Notes = "The destination slot in the hopper's {{cItemGrid|internal storage}}" }, + { Name = "SrcBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = "The block entity that is losing the item" }, + { Name = "SrcSlot", Type = "number", Notes = "Slot in SrcBlockEntity from which the item will be pulled" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event and the hopper will not pull the item. + ]], + }, -- HOOK_HOPPER_PULLING_ITEM +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnHopperPushingItem.lua b/MCServer/Plugins/APIDump/Hooks/OnHopperPushingItem.lua new file mode 100644 index 000000000..bd5702518 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnHopperPushingItem.lua @@ -0,0 +1,30 @@ +return +{ + HOOK_HOPPER_PUSHING_ITEM = + { + CalledWhen = "A hopper is pushing an item into another block entity. ", + DefaultFnName = "OnHopperPushingItem", -- also used as pagename + Desc = [[ + This hook is called whenever a {{cHopperEntity|hopper}} transfers an {{cItem|item}} from its own + internal storage into another block entity. A plugin may decide to disallow the move by returning + true. Note that in such a case, the hook may be called again for the same hopper and block, with + different slot numbers. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World where the hopper resides" }, + { Name = "Hopper", Type = "{{cHopperEntity}}", Notes = "The hopper that is pushing the item" }, + { Name = "SrcSlot", Type = "number", Notes = "Slot in the hopper that will lose the item" }, + { Name = "DstBlockEntity", Type = "{{cBlockEntityWithItems}}", Notes = " The block entity that will receive the item" }, + { Name = "DstSlot", Type = "number", Notes = " Slot in DstBlockEntity's internal storage where the item will be stored" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event and the hopper will not push the item. + ]], + }, -- HOOK_HOPPER_PUSHING_ITEM +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnKilling.lua b/MCServer/Plugins/APIDump/Hooks/OnKilling.lua new file mode 100644 index 000000000..8ec1cfe2e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnKilling.lua @@ -0,0 +1,33 @@ +return +{ + HOOK_KILLING = + { + CalledWhen = "A player or a mob is dying.", + DefaultFnName = "OnKilling", -- also used as pagename + Desc = [[ + This hook is called whenever a {{cPawn|pawn}}'s (a player's or a mob's) health reaches zero. This + means that the pawn is about to be killed, unless a plugin "revives" them by setting their health + back to a positive value.

    +

    + FIXME: There is no HOOK_KILLED notification hook yet; this is deliberate because HOOK_KILLED has + been recently renamed to HOOK_KILLING, and plugins need to be updated. Once updated, the HOOK_KILLED + notification will be implemented. + ]], + Params = + { + { Name = "Victim", Type = "{{cPawn}}", Notes = "The player or mob that is about to be killed" }, + { Name = "Killer", Type = "{{cEntity}}", Notes = "The entity that has caused the victim to lose the last point of health. May be nil for environment damage" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins with this event. If the + function returns true, no other plugin is called for this event.

    +

    + In either case, the victim's health is then re-checked and if it is greater than zero, the victim is + "revived" with that health amount. If the health is less or equal to zero, the victim is killed. + ]], + }, -- HOOK_KILLING +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnLogin.lua b/MCServer/Plugins/APIDump/Hooks/OnLogin.lua new file mode 100644 index 000000000..6859f9d11 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnLogin.lua @@ -0,0 +1,31 @@ +return +{ + HOOK_LOGIN = + { + CalledWhen = "Right before player authentication. If auth is disabled, right after the player sends their name.", + DefaultFnName = "OnLogin", -- also used as pagename + Desc = [[ + This hook is called whenever a client logs in. It is called right before the client's name is sent + to be authenticated. Plugins may refuse the client from accessing the server. Note that when this + callback is called, the {{cPlayer}} object for this client doesn't exist yet - the client has no + representation in any world. To process new players when their world is known, use a later callback, + such as {{OnPlayerJoined|HOOK_PLAYER_JOINED}} or {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}. + ]], + Params = + { + { Name = "Client", Type = "{{cClientHandle}}", Notes = "The client handle representing the connection" }, + { Name = "ProtocolVersion", Type = "number", Notes = "Versio of the protocol that the client is talking" }, + { Name = "UserName", Type = "string", Notes = "The name that the client has presented for authentication. This name will be given to the {{cPlayer}} object when it is created for this client." }, + }, + Returns = [[ + If the function returns true, no other plugins are called for this event and the client is kicked. + If the function returns false or no value, MCServer calls other plugins' callbacks and finally + sends an authentication request for the client's username to the auth server. If the auth server + is disabled in the server settings, the player object is immediately created. + ]], + }, -- HOOK_LOGIN +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua new file mode 100644 index 000000000..baf99834e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerAnimation.lua @@ -0,0 +1,28 @@ +return +{ + HOOK_PLAYER_ANIMATION = + { + CalledWhen = "A client has sent an Animation packet (0x12)", + DefaultFnName = "OnPlayerAnimation", -- also used as pagename + Desc = [[ + This hook is called when the server receives an Animation packet (0x12) from the client.

    +

    + For the list of animations that are sent by the client, see the + Protocol wiki. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player from whom the packet was received" }, + { Name = "Animation", Type = "number", Notes = "The kind of animation" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Afterwards, the + server broadcasts the animation packet to all nearby clients. If the function returns true, no other + callback is called for this event and the packet is not broadcasted. + ]], + }, -- HOOK_PLAYER_ANIMATION +} + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerBreakingBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerBreakingBlock.lua new file mode 100644 index 000000000..18f19f247 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerBreakingBlock.lua @@ -0,0 +1,36 @@ +return +{ + HOOK_PLAYER_BREAKING_BLOCK = + { + CalledWhen = "Just before a player breaks a block. Plugin may override / refuse. ", + DefaultFnName = "OnPlayerBreakingBlock", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} breaks a block, before the block is actually broken in + the {{cWorld|World}}. Plugins may refuse the breaking.

    +

    + See also the {{OnPlayerBrokenBlock|HOOK_PLAYER_BROKEN_BLOCK}} hook for a similar hook called after + the block is broken. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is digging the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player is acting. One of the BLOCK_FACE_ constants" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block being broken" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block being broken " }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called, and then the block + is broken. If the function returns true, no other plugin's callback is called and the block breaking + is cancelled. The server re-sends the block back to the player to replace it (the player's client + already thinks the block was broken). + ]], + }, -- HOOK_PLAYER_BREAKING_BLOCK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua new file mode 100644 index 000000000..e718c5d97 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerBrokenBlock.lua @@ -0,0 +1,36 @@ +return +{ + HOOK_PLAYER_BROKEN_BLOCK = + { + CalledWhen = "After a player has broken a block. Notification only.", + DefaultFnName = "OnPlayerBrokenBlock", -- also used as pagename + Desc = [[ + This function is called after a {{cPlayer|player}} breaks a block. The block is already removed + from the {{cWorld|world}} and {{cPickup|pickups}} have been spawned. To get the world in which the + block has been dug, use the {{cPlayer}}:GetWorld() function.

    +

    + See also the {{OnPlayerBreakingBlock|HOOK_PLAYER_BREAKING_BLOCK}} hook for a similar hook called + before the block is broken. To intercept the creation of pickups, see the + {{OnBlockToPickups|HOOK_BLOCK_TO_PICKUPS}} hook. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who broke the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_PLAYER_BROKEN_BLOCK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua new file mode 100644 index 000000000..e77d02a96 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerEating.lua @@ -0,0 +1,27 @@ +return +{ + HOOK_PLAYER_EATING = + { + CalledWhen = "When the player starts eating", + DefaultFnName = "OnPlayerEating", -- also used as pagename + Desc = [[ + This hook gets called when the {{cPlayer|player}} starts eating, after the server checks that the + player can indeed eat (is not satiated and is holding food). Plugins may still refuse the eating by + returning true. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who started eating" }, + }, + Returns = [[ + If the function returns false or no value, the server calls the next plugin handler, and finally + lets the player eat. If the function returns true, the server doesn't call any more callbacks for + this event and aborts the eating. A "disallow" packet is sent to the client. + ]], + }, -- HOOK_PLAYER_EATING +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua new file mode 100644 index 000000000..00805af7e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerJoined.lua @@ -0,0 +1,29 @@ +return +{ + HOOK_PLAYER_JOINED = + { + CalledWhen = "After Login and before Spawned, before being added to world. ", + DefaultFnName = "OnPlayerJoined", -- also used as pagename + Desc = [[ + This hook is called whenever a {{cPlayer|player}} has completely logged in. If authentication is + enabled, this function is called after their name has been authenticated. It is called after + {{OnLogin|HOOK_LOGIN}} and before {{OnPlayerSpawned|HOOK_PLAYER_SPAWNED}}, right after the player's + entity is created, but not added to the world yet. The player is not yet visible to other players. + This is a notification-only event, plugins wishing to refuse player's entry should kick the player + using the {{cPlayer}}:Kick() function. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has joined the game" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. Either way the player is let in. + ]], + }, -- HOOK_PLAYER_JOINED +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerLeftClick.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerLeftClick.lua new file mode 100644 index 000000000..1d9585c55 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerLeftClick.lua @@ -0,0 +1,47 @@ +return +{ + HOOK_PLAYER_LEFT_CLICK = + { + CalledWhen = "A left-click packet is received from the client. Plugin may override / refuse.", + DefaultFnName = "OnPlayerLeftClick", -- also used as pagename + Desc = [[ + This hook is called when MCServer receives a left-click packet from the {{cClientHandle|client}}. It + is called before any processing whatsoever is performed on the packet, meaning that hacked / + malicious clients may be trigerring this event very often and with unchecked parameters. Therefore + plugin authors are advised to use extreme caution with this callback.

    +

    + Plugins may refuse the default processing for the packet, causing MCServer to behave as if the + packet has never arrived. This may, however, create inconsistencies in the client - the client may + think that they broke a block, while the server didn't process the breaking, etc. For this reason, + if a plugin refuses the processing, MCServer sends the block specified in the packet back to the + client (as if placed anew), if the status code specified a block-break action. For other actions, + plugins must rectify the situation on their own.

    +

    + The client sends the left-click packet for several other occasions, such as dropping the held item + (Q keypress) or shooting an arrow. This is reflected in the Status code. Consult the + protocol documentation for details on the actions. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "Action", Type = "number", Notes = "Action to be performed on the block (\"status\" in the protocol docs)" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends + the packet for further processing.

    +

    + If the function returns true, no other plugins are called, processing is halted. If the action was a + block dig, MCServer sends the block specified in the coords back to the client. The packet is + dropped. + ]], + }, -- HOOK_PLAYER_LEFT_CLICK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua new file mode 100644 index 000000000..2756529ef --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerMoving.lua @@ -0,0 +1,27 @@ +return +{ + HOOK_PLAYER_MOVING = + { + CalledWhen = "Player tried to move in the tick being currently processed. Plugin may refuse movement.", + DefaultFnName = "OnPlayerMoving", -- also used as pagename + Desc = [[ + This function is called in each server tick for each {{cPlayer|player}} that has sent any of the + player-move packets. Plugins may refuse the movement. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has moved. The object already has the new position stored in it." }, + }, + Returns = [[ + If the function returns true, movement is prohibited. FIXME: The player's client is not informed.

    +

    + If the function returns false or no value, other plugins' callbacks are called and finally the new + position is permanently stored in the cPlayer object.

    + ]], + }, -- HOOK_PLAYER_MOVING +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua new file mode 100644 index 000000000..54888a6db --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerPlacedBlock.lua @@ -0,0 +1,40 @@ +return +{ + HOOK_PLAYER_PLACED_BLOCK = + { + CalledWhen = "After a player has placed a block. Notification only.", + DefaultFnName = "OnPlayerPlacedBlock", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has placed a block in the {{cWorld|world}}. The block + is already added to the world and the corresponding item removed from player's + {{cInventory|inventory}}.

    +

    + Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.

    +

    + See also the {{OnPlayerPlacingBlock|HOOK_PLAYER_PLACING_BLOCK}} hook for a similar hook called + before the placement. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who placed the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, + }, + Returns = [[ + If this function returns false or no value, MCServer calls other plugins with the same event. If + this function returns true, no other plugin is called for this event. + ]], + }, -- HOOK_PLAYER_PLACED_BLOCK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua new file mode 100644 index 000000000..2a928390b --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerPlacingBlock.lua @@ -0,0 +1,45 @@ +return +{ + HOOK_PLAYER_PLACING_BLOCK = + { + CalledWhen = "Just before a player places a block. Plugin may override / refuse.", + DefaultFnName = "OnPlayerPlacingBlock", -- also used as pagename + Desc = [[ + This hook is called just before a {{cPlayer|player}} places a block in the {{cWorld|world}}. The + block is not yet placed, plugins may choose to override the default behavior or refuse the placement + at all.

    +

    + Note that the client already expects that the block has been placed. For that reason, if a plugin + refuses the placement, MCServer sends the old block at the provided coords to the client.

    +

    + Use the {{cPlayer}}:GetWorld() function to get the world to which the block belongs.

    +

    + See also the {{OnPlayerPlacedBlock|HOOK_PLAYER_PLACED_BLOCK}} hook for a similar hook called after + the placement. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is placing the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the existing block upon which the player is interacting. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor within the block face (0 .. 15)" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor within the block face (0 .. 15)" }, + { Name = "BlockType", Type = "BLOCKTYPE", Notes = "The block type of the block" }, + { Name = "BlockMeta", Type = "NIBBLETYPE", Notes = "The block meta of the block" }, + }, + Returns = [[ + If this function returns false or no value, MCServer calls other plugins with the same event and + finally places the block and removes the corresponding item from player's inventory. If this + function returns true, no other plugin is called for this event, MCServer sends the old block at + the specified coords to the client and drops the packet. + ]], + }, -- HOOK_PLAYER_PLACING_BLOCK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua new file mode 100644 index 000000000..d767b449d --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua @@ -0,0 +1,37 @@ +return +{ + HOOK_PLAYER_RIGHT_CLICK = + { + CalledWhen = "A right-click packet is received from the client. Plugin may override / refuse.", + DefaultFnName = "OnPlayerRightClick", -- also used as pagename + Desc = [[ + This hook is called when MCServer receives a right-click packet from the {{cClientHandle|client}}. It + is called before any processing whatsoever is performed on the packet, meaning that hacked / + malicious clients may be trigerring this event very often and with unchecked parameters. Therefore + plugin authors are advised to use extreme caution with this callback.

    +

    + Plugins may refuse the default processing for the packet, causing MCServer to behave as if the + packet has never arrived. This may, however, create inconsistencies in the client - the client may + think that they placed a block, while the server didn't process the placing, etc. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player whose client sent the packet" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + }, + Returns = [[ + If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends + the packet for further processing.

    +

    + If the function returns true, no other plugins are called, processing is halted. + ]], + }, -- HOOK_PLAYER_RIGHT_CLICK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClickingEntity.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClickingEntity.lua new file mode 100644 index 000000000..796622307 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClickingEntity.lua @@ -0,0 +1,27 @@ +return +{ + HOOK_PLAYER_RIGHT_CLICKING_ENTITY = + { + CalledWhen = "A player has right-clicked an entity. Plugins may override / refuse.", + DefaultFnName = "OnPlayerRightClickingEntity", -- also used as pagename + Desc = [[ + This hook is called when the {{cPlayer|player}} right-clicks an {{cEntity|entity}}. Plugins may + override the default behavior or even cancel the default processing. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has right-clicked the entity" }, + { Name = "Entity", Type = "{{cEntity}} descendant", Notes = "The entity that has been right-clicked" }, + }, + Returns = [[ + If the functino returns false or no value, MCServer calls other plugins' callbacks and finally does + the default processing for the right-click. If the function returns true, no other callbacks are + called and the default processing is skipped. + ]], + }, -- HOOK_PLAYER_RIGHT_CLICKING_ENTITY +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerShooting.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerShooting.lua new file mode 100644 index 000000000..aefae2c2f --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerShooting.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_PLAYER_SHOOTING = + { + CalledWhen = "When the player releases the bow, shooting an arrow (other projectiles: unknown)", + DefaultFnName = "OnPlayerShooting", -- also used as pagename + Desc = [[ + This hook is called when the {{cPlayer|player}} shoots their bow. It is called for the actual + release of the {{cArrowEntity|arrow}}. FIXME: It is currently unknown whether other + {{cProjectileEntity|projectiles}} (snowballs, eggs) trigger this hook.

    +

    + To get the player's position and direction, use the {{cPlayer}}:GetEyePosition() and + cPlayer:GetLookVector() functions. Note that for shooting a bow, the position for the arrow creation + is not at the eye pos, some adjustments are required. FIXME: Export the {{cPlayer}} function for + this adjustment. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player shooting" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called, and finally + MCServer creates the projectile. If the functino returns true, no other callback is called and no + projectile is created. + ]], + }, -- HOOK_PLAYER_SHOOTING +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua new file mode 100644 index 000000000..190909ee5 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerSpawned.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_PLAYER_SPAWNED = + { + CalledWhen = "After a player (re)spawns in the world to which they belong to.", + DefaultFnName = "OnPlayerSpawned", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has spawned in the world. It is called after + {{OnLogin|HOOK_LOGIN}} and {{OnPlayerJoined|HOOK_PLAYER_JOINED}}, after the player name has been + authenticated, the initial worldtime, inventory and health have been sent to the player and the + player spawn packet has been broadcast to all players near enough to the player spawn place. This is + a notification-only event, plugins wishing to refuse player's entry should kick the player using the + {{cPlayer}}:Kick() function.

    +

    + This hook is also called when the player respawns after death (and a respawn packet is received from + the client, meaning the player has already clicked the Respawn button). + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has (re)spawned" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. There is no overridable behavior. + ]], + }, -- HOOK_PLAYER_SPAWNED +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerTossingItem.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerTossingItem.lua new file mode 100644 index 000000000..85c943721 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerTossingItem.lua @@ -0,0 +1,30 @@ +return +{ + HOOK_PLAYER_TOSSING_ITEM = + { + CalledWhen = "A player is tossing an item. Plugin may override / refuse.", + DefaultFnName = "OnPlayerTossingItem", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} has tossed an item (Q keypress). The + {{cPickup|pickup}} has not been spawned yet. Plugins may disallow the tossing, but in that case they + need to clean up - the player's client already thinks the item has been tossed so the + {{cInventory|inventory}} needs to be re-sent to the player.

    +

    + To get the item that is about to be tossed, call the {{cPlayer}}:GetEquippedItem() function. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player tossing an item" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and finally MCServer + creates the pickup for the item and tosses it, using {{cPlayer}}:TossItem. If the function returns + true, no other callbacks are called for this event and MCServer doesn't toss the item. + ]], + }, -- HOOK_PLAYER_TOSSING_ITEM +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua new file mode 100644 index 000000000..4c91ea89e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedBlock.lua @@ -0,0 +1,46 @@ +return +{ + HOOK_PLAYER_USED_BLOCK = + { + CalledWhen = "A player has just used a block (chest, furnace…). Notification only.", + DefaultFnName = "OnPlayerUsedBlock", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has right-clicked a block that can be used, such as a + {{cChestEntity|chest}} or a lever. It is called after MCServer processes the usage (sends the UI + handling packets / toggles redstone). Note that for UI-related blocks, the player is most likely + still using the UI. This is a notification-only event.

    +

    + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

    +

    + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.

    +

    + See also the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} for a similar hook called before the + use, the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} + for similar hooks called when a player interacts with any block with a usable item in hand, such as + a bucket. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. + ]], + }, -- HOOK_PLAYER_USED_BLOCK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedItem.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedItem.lua new file mode 100644 index 000000000..998058c35 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsedItem.lua @@ -0,0 +1,46 @@ +return +{ + HOOK_PLAYER_USED_ITEM = + { + CalledWhen = "A player has used an item in hand (bucket...)", + DefaultFnName = "OnPlayerUsedItem", -- also used as pagename + Desc = [[ + This hook is called after a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that + can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a + hoe. It is called after MCServer processes the usage (places fluid / turns dirt to farmland). + This is an information-only hook, there is no way to cancel the event anymore.

    +

    + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

    +

    + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get + the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.

    +

    + See also the {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} for a similar hook called before the use, + the {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} + for similar hooks called when a player interacts with a block, such as a chest. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who used the item" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. + ]], + }, -- HOOK_PLAYER_USED_ITEM +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua new file mode 100644 index 000000000..8acc84b5f --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsingBlock.lua @@ -0,0 +1,46 @@ +return +{ + HOOK_PLAYER_USING_BLOCK = + { + CalledWhen = "Just before a player uses a block (chest, furnace...). Plugin may override / refuse.", + DefaultFnName = "OnPlayerUsingBlock", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} has right-clicked a block that can be used, such as a + {{cChestEntity|chest}} or a lever. It is called before MCServer processes the usage (sends the UI + handling packets / toggles redstone). Plugins may refuse the interaction by returning true.

    +

    + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

    +

    + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function.

    +

    + See also the {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for a similar hook called after the use, the + {{OnPlayerUsingItem|HOOK_PLAYER_USING_ITEM}} and {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for + similar hooks called when a player interacts with any block with a usable item in hand, such as a + bucket. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the block" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + processes the interaction. If the function returns true, no other callbacks are called for this + event and the interaction is silently dropped. + ]], + }, -- HOOK_PLAYER_USING_BLOCK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerUsingItem.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsingItem.lua new file mode 100644 index 000000000..09674606d --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerUsingItem.lua @@ -0,0 +1,47 @@ +return +{ + HOOK_PLAYER_USING_ITEM = + { + CalledWhen = "Just before a player uses an item in hand (bucket...). Plugin may override / refuse.", + DefaultFnName = "OnPlayerUsingItem", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} has right-clicked a block with an {{cItem|item}} that + can be used (is not placeable, is not food and clicked block is not use-able), such as a bucket or a + hoe. It is called before MCServer processes the usage (places fluid / turns dirt to farmland). + Plugins may refuse the interaction by returning true.

    +

    + Note that the block coords given in this callback are for the (solid) block that is being clicked, + not the air block between it and the player.

    +

    + To get the world at which the right-click occurred, use the {{cPlayer}}:GetWorld() function. To get + the item that the player is using, use the {{cPlayer}}:GetEquippedItem() function.

    +

    + See also the {{OnPlayerUsedItem|HOOK_PLAYER_USED_ITEM}} for a similar hook called after the use, the + {{OnPlayerUsingBlock|HOOK_PLAYER_USING_BLOCK}} and {{OnPlayerUsedBlock|HOOK_PLAYER_USED_BLOCK}} for + similar hooks called when a player interacts with a block, such as a chest. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is using the item" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the clicked block" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the clicked block" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the clicked block" }, + { Name = "BlockFace", Type = "number", Notes = "Face of clicked block which has been clicked. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the cursor crosshair on the block being clicked" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the cursor crosshair on the block being clicked" }, + { Name = "BlockType", Type = "number", Notes = "Block type of the clicked block" }, + { Name = "BlockMeta", Type = "number", Notes = "Block meta of the clicked block" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + processes the interaction. If the function returns true, no other callbacks are called for this + event and the interaction is silently dropped. + ]], + }, -- HOOK_PLAYER_USING_ITEM +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua b/MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua new file mode 100644 index 000000000..8af78ba62 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPostCrafting.lua @@ -0,0 +1,36 @@ +return +{ + HOOK_POST_CRAFTING = + { + CalledWhen = "After the built-in recipes are checked and a recipe was found.", + DefaultFnName = "OnPostCrafting", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} changes contents of their + {{cCraftingGrid|crafting grid}}, after the recipe has been established by MCServer. Plugins may use + this to modify the resulting recipe or provide an alternate recipe.

    +

    + If a plugin implements custom recipes, it should do so using the {{OnPreCrafting|HOOK_PRE_CRAFTING}} + hook, because that will save the server from going through the built-in recipes. The + HOOK_POST_CRAFTING hook is intended as a notification, with a chance to tweak the result.

    +

    + Note that this hook is not called if a built-in recipe is not found; + {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}} is called instead in such a case. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer has decided to use (can be tweaked by plugins)" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called for this event. In either case, MCServer uses the value + of Recipe as the recipe to be presented to the player. + ]], + }, -- HOOK_POST_CRAFTING +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua b/MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua new file mode 100644 index 000000000..b404e0e73 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnPreCrafting.lua @@ -0,0 +1,37 @@ +return +{ + HOOK_PRE_CRAFTING = + { + CalledWhen = "Before the built-in recipes are checked.", + DefaultFnName = "OnPreCrafting", -- also used as pagename + Desc = [[ + This hook is called when a {{cPlayer|player}} changes contents of their + {{cCraftingGrid|crafting grid}}, before the built-in recipes are searched for a match by MCServer. + Plugins may use this hook to provide a custom recipe.

    +

    + If you intend to tweak built-in recipes, use the {{OnPostCrafting|HOOK_POST_CRAFTING}} hook, because + that will be called once the built-in recipe is matched.

    +

    + Also note a third hook, {{OnCraftingNoRecipe|HOOK_CRAFTING_NO_RECIPE}}, that is called when MCServer + cannot find any built-in recipe for the given ingredients. + ]], + Params = + { + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who has changed their crafting grid contents" }, + { Name = "Grid", Type = "{{cCraftingGrid}}", Notes = "The new crafting grid contents" }, + { Name = "Recipe", Type = "{{cCraftingRecipe}}", Notes = "The recipe that MCServer will use. Modify this object to change the recipe" }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then MCServer + searches the built-in recipes. The Recipe output parameter is ignored in this case.

    +

    + If the function returns true, no other callbacks are called for this event and MCServer uses the + recipe stored in the Recipe output parameter. + ]], + }, -- HOOK_PRE_CRAFTING +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua b/MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua new file mode 100644 index 000000000..037a90f1c --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnSpawnedEntity.lua @@ -0,0 +1,31 @@ +return +{ + HOOK_SPAWNED_ENTITY = + { + CalledWhen = "After an entity is spawned in the world.", + DefaultFnName = "OnSpawnedEntity", -- also used as pagename + Desc = [[ + This hook is called after the server spawns an {{cEntity|entity}}. This is an information-only + callback, the entity is already spawned by the time it is called. If the entity spawned is a + {{cMonster|monster}}, the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook is called before this + hook.

    +

    + See also the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} hook for a similar hook called before the + entity is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity has spawned" }, + { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that has spawned" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_SPAWNED_ENTITY +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnSpawnedMonster.lua b/MCServer/Plugins/APIDump/Hooks/OnSpawnedMonster.lua new file mode 100644 index 000000000..c319a77ea --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnSpawnedMonster.lua @@ -0,0 +1,30 @@ +return +{ + HOOK_SPAWNED_MONSTER = + { + CalledWhen = "After a monster is spawned in the world", + DefaultFnName = "OnSpawnedMonster", -- also used as pagename + Desc = [[ + This hook is called after the server spawns a {{cMonster|monster}}. This is an information-only + callback, the monster is already spawned by the time it is called. After this hook is called, the + {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} is called for the monster entity.

    +

    + See also the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook for a similar hook called before the + monster is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the monster has spawned" }, + { Name = "Monster", Type = "{{cMonster}} descendant", Notes = "The monster that has spawned" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. + ]], + }, -- HOOK_SPAWNED_MONSTER +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua b/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua new file mode 100644 index 000000000..c4bff3916 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnSpawningEntity.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_SPAWNING_ENTITY = + { + CalledWhen = "Before an entity is spawned in the world.", + DefaultFnName = "OnSpawningEntity", -- also used as pagename + Desc = [[ + This hook is called before the server spawns an {{cEntity|entity}}. The plugin can either modify the + entity before it is spawned, or disable the spawning altogether. If the entity spawning is a + monster, the {{OnSpawningMonster|HOOK_SPAWNING_MONSTER}} hook is called before this hook.

    +

    + See also the {{OnSpawnedEntity|HOOK_SPAWNED_ENTITY}} hook for a similar hook called after the + entity is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, + { Name = "Entity", Type = "{{cEntity}} descentant", Notes = "The entity that will spawn" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Finally, the server + spawns the entity with whatever parameters have been set on the {{cEntity}} object by the callbacks. + If the function returns true, no other callback is called for this event and the entity is not + spawned. + ]], + }, -- HOOK_SPAWNING_ENTITY +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnSpawningMonster.lua b/MCServer/Plugins/APIDump/Hooks/OnSpawningMonster.lua new file mode 100644 index 000000000..4c0519e27 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnSpawningMonster.lua @@ -0,0 +1,33 @@ +return +{ + HOOK_SPAWNING_MONSTER = + { + CalledWhen = "Before a monster is spawned in the world.", + DefaultFnName = "OnSpawningMonster", -- also used as pagename + Desc = [[ + This hook is called before the server spawns a {{cMonster|monster}}. The plugins may modify the + monster's parameters in the {{cMonster}} class, or disallow the spawning altogether. This hook is + called before the {{OnSpawningEntity|HOOK_SPAWNING_ENTITY}} is called for the monster entity.

    +

    + See also the {{OnSpawnedMonster|HOOK_SPAWNED_MONSTER}} hook for a similar hook called after the + monster is spawned. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the entity will spawn" }, + { Name = "Monster", Type = "{{cMonster}} descentant", Notes = "The monster that will spawn" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. Finally, the server + spawns the monster with whatever parameters the plugins set in the cMonster parameter.

    +

    + If the function returns true, no other callback is called for this event and the monster won't + spawn. + ]], + }, -- HOOK_SPAWNING_MONSTER +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua b/MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua new file mode 100644 index 000000000..608126f2b --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnTakeDamage.lua @@ -0,0 +1,31 @@ +return +{ + HOOK_TAKE_DAMAGE = + { + CalledWhen = "An {{cEntity|entity}} is taking any kind of damage", + DefaultFnName = "OnTakeDamage", -- also used as pagename + Desc = [[ + This hook is called when any {{cEntity}} descendant, such as a {{cPlayer|player}} or a + {{cMonster|mob}}, takes any kind of damage. The plugins may modify the amount of damage or effects + with this hook by editting the {{TakeDamageInfo}} object passed.

    +

    + This hook is called after the final damage is calculated, including all the possible weapon + {{cEnchantments|enchantments}}, armor protection and potion effects. + ]], + Params = + { + { Name = "Receiver", Type = "{{cEntity}} descendant", Notes = "The entity taking damage" }, + { Name = "TDI", Type = "{{TakeDamageInfo}}", Notes = "The damage type, cause and effects. Plugins may modify this object to alter the final damage applied." }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called and then the server + applies the final values from the TDI object to Receiver. If the function returns true, no other + callbacks are called, and no damage nor effects are applied. + ]], + }, -- HOOK_TAKE_DAMAGE +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnTick.lua b/MCServer/Plugins/APIDump/Hooks/OnTick.lua new file mode 100644 index 000000000..d8c329253 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnTick.lua @@ -0,0 +1,29 @@ +return +{ + HOOK_TICK = + { + CalledWhen = "Every server tick (approximately 20 times per second)", + DefaultFnName = "OnTick", -- also used as pagename + Desc = [[ + This hook is called every game tick (50 msec, or 20 times a second). If the server is overloaded, + the interval is larger, which is indicated by the TimeDelta parameter.

    +

    + This hook is called in the context of the server-tick thread, that is, the thread that takes care of + {{cClientHandle|client connections}} before they're assigned to {{cPlayer|player entities}}, and + processing console commands. + ]], + Params = + { + { Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds elapsed since the last server tick. Will not be less than 50 msec." }, + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called. There is no overridable behavior. + ]], + }, -- HOOK_TICK +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua b/MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua new file mode 100644 index 000000000..937e6b981 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnUpdatedSign.lua @@ -0,0 +1,38 @@ +return +{ + HOOK_UPDATED_SIGN = + { + CalledWhen = "After the sign text is updated. Notification only.", + DefaultFnName = "OnUpdatedSign", -- also used as pagename + Desc = [[ + This hook is called after a sign has had its text updated. The text is already updated at this + point.

    +

    The update may have been caused either by a {{cPlayer|player}} directly updating the sign, or by + a plugin changing the sign text using the API.

    +

    + See also the {{OnUpdatingSign|HOOK_UPDATING_SIGN}} hook for a similar hook called before the update, + with a chance to modify the text. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the sign" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" }, + { Name = "Line1", Type = "string", Notes = "1st line of the new text" }, + { Name = "Line2", Type = "string", Notes = "2nd line of the new text" }, + { Name = "Line3", Type = "string", Notes = "3rd line of the new text" }, + { Name = "Line4", Type = "string", Notes = "4th line of the new text" }, + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." } + }, + Returns = [[ + If the function returns false or no value, other plugins' callbacks are called. If the function + returns true, no other callbacks are called. There is no overridable behavior. + ]], + }, -- HOOK_UPDATED_SIGN +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua b/MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua new file mode 100644 index 000000000..d74458182 --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnUpdatingSign.lua @@ -0,0 +1,58 @@ +return +{ + HOOK_UPDATING_SIGN = + { + CalledWhen = "Before the sign text is updated. Plugin may modify the text / refuse.", + DefaultFnName = "OnUpdatingSign", -- also used as pagename + Desc = [[ + This hook is called when a sign text is about to be updated, either as a result of player's + manipulation or any other event, such as a plugin setting the sign text. Plugins may modify the text + or refuse the update altogether.

    +

    + See also the {{OnUpdatedSign|HOOK_UPDATED_SIGN}} hook for a similar hook called after the update. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "The world in which the sign resides" }, + { Name = "BlockX", Type = "number", Notes = "X-coord of the sign" }, + { Name = "BlockY", Type = "number", Notes = "Y-coord of the sign" }, + { Name = "BlockZ", Type = "number", Notes = "Z-coord of the sign" }, + { Name = "Line1", Type = "string", Notes = "1st line of the new text" }, + { Name = "Line2", Type = "string", Notes = "2nd line of the new text" }, + { Name = "Line3", Type = "string", Notes = "3rd line of the new text" }, + { Name = "Line4", Type = "string", Notes = "4th line of the new text" }, + { Name = "Player", Type = "{{cPlayer}}", Notes = "The player who is changing the text. May be nil for non-player updates." } + }, + Returns = [[ + The function may return up to five values. If the function returns true as the first value, no other + callbacks are called for this event and the sign is not updated. If the function returns no value or + false as its first value, other plugins' callbacks are called.

    +

    + The other up to four values returned are used to update the sign text, line by line, respectively. + Note that other plugins may again update the texts (if the first value returned is false). + ]], + CodeExamples = + { + { + Title = "Add player signature", + Desc = "The following example appends a player signature to the last line, if the sign is updated by a player:", + Code = [[ +function OnUpdatingSign(World, BlockX, BlockY, BlockZ, Line1, Line2, Line3, Line4, Player) + if (Player == nil) then + -- Not changed by a player + return false; + end + + -- Sign with playername, allow other plugins to interfere: + return false, Line1, Line2, Line3, Line4 .. Player:GetName(); +end + ]], + } + } , + }, -- HOOK_UPDATING_SIGN +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnWeatherChanged.lua b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanged.lua new file mode 100644 index 000000000..2a3bbe92b --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanged.lua @@ -0,0 +1,28 @@ +return +{ + HOOK_WEATHER_CHANGED = + { + CalledWhen = "The weather has changed", + DefaultFnName = "OnWeatherChanged", -- also used as pagename + Desc = [[ + This hook is called after the weather has changed in a {{cWorld|world}}. The new weather has already + been sent to the clients.

    +

    + See also the {{OnWeatherChanging|HOOK_WEATHER_CHANGING}} hook for a similar hook called before the + change. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather has changed" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no overridable behavior. + ]], + }, -- HOOK_WEATHER_CHANGED +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua new file mode 100644 index 000000000..d36164e8e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnWeatherChanging.lua @@ -0,0 +1,32 @@ +return +{ + HOOK_WEATHER_CHANGING = + { + CalledWhen = "The weather is about to change", + DefaultFnName = "OnWeatherChanging", -- also used as pagename + Desc = [[ + This hook is called when the current weather has expired and a new weather is selected. Plugins may + override the new weather setting.

    +

    + The new weather setting is sent to the clients only after this hook has been processed.

    +

    + See also the {{OnWeatherChanged|HOOK_WEATHER_CHANGED}} hook for a similar hook called after the + change. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World for which the weather is changing" }, + { Name = "Weather", Type = "number", Notes = "The newly selected weather. One of wSunny, wRain, wStorm" }, + }, + Returns = [[ + If the function returns false or no value, the server calls other plugins' callbacks and finally + sets the weather. If the function returns true, the server takes the second returned value (wSunny + by default) and sets it as the new weather. No other plugins' callbacks are called in this case. + ]], + }, -- HOOK_WEATHER_CHANGING +} + + + + + diff --git a/MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua b/MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua new file mode 100644 index 000000000..657716d9e --- /dev/null +++ b/MCServer/Plugins/APIDump/Hooks/OnWorldTick.lua @@ -0,0 +1,29 @@ +return +{ + HOOK_WORLD_TICK = + { + CalledWhen = "Every world tick (about 20 times per second), separately for each world", + DefaultFnName = "OnWorldTick", -- also used as pagename + Desc = [[ + This hook is called for each {{cWorld|world}} every tick (50 msec, or 20 times a second). If the + world is overloaded, the interval is larger, which is indicated by the TimeDelta parameter.

    +

    + This hook is called in the world's tick thread context and thus has access to all world data + guaranteed without blocking. + ]], + Params = + { + { Name = "World", Type = "{{cWorld}}", Notes = "World that is ticking" }, + { Name = "TimeDelta", Type = "number", Notes = "The number of milliseconds since the previous game tick. Will not be less than 50 msec" }, + }, + Returns = [[ + If the function returns false or no value, the next plugin's callback is called. If the function + returns true, no other callback is called for this event. There is no overridable behavior. + ]], + }, -- HOOK_WORLD_TICK +} + + + + + diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index 9c4fb17f8..f77409f91 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -41,6 +41,16 @@ function Initialize(Plugin) LOG("Initialising " .. Plugin:GetName() .. " v." .. Plugin:GetVersion()) g_PluginFolder = Plugin:GetLocalFolder(); + + -- Load the API descriptions from the Classes and Hooks subfolders: + if (g_APIDesc.Classes == nil) then + g_APIDesc.Classes = {}; + end + if (g_APIDesc.Hooks == nil) then + g_APIDesc.Hooks = {}; + end + LoadAPIFiles("/Classes/", g_APIDesc.Classes); + LoadAPIFiles("/Hooks/", g_APIDesc.Hooks); -- dump all available API functions and objects: -- DumpAPITxt(); @@ -57,6 +67,29 @@ end +function LoadAPIFiles(a_Folder, a_DstTable) + local Folder = g_PluginFolder .. a_Folder; + for idx, fnam in ipairs(cFile:GetFolderContents(Folder)) do + local FileName = Folder .. fnam; + -- We only want .lua files from the folder: + if (cFile:IsFile(FileName) and fnam:match(".*%.lua$")) then + local TablesFn, Err = loadfile(FileName); + if (TablesFn == nil) then + LOGWARNING("Cannot load API descriptions from " .. FileName .. ", Lua error '" .. Err .. "'."); + else + local Tables = TablesFn(); + for k, cls in pairs(Tables) do + a_DstTable[k] = cls; + end + end -- if (TablesFn) + end -- if (is lua file) + end -- for fnam - Folder[] +end + + + + + function DumpAPITxt() LOG("Dumping all available functions to API.txt..."); function dump (prefix, a, Output) -- cgit v1.2.3 From 3ef7f2008f87d2ea1f99a1dc008a4688d9b13c7b Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 23 Nov 2013 21:32:18 +0100 Subject: APIDump: Reformatted the sqlite docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 1ad5bf5e4..8778727e1 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2439,11 +2439,23 @@ Parser:close(); Functions = { complete = { Params = "string", Return = "bool", Notes = "Returns true if the string sql comprises one or more complete SQL statements and false otherwise." }, - open = { Params = "string", Return = "Userdata", Notes = [[Opens (or creates if it does not exist) an SQLite database with name filename and returns its handle as userdata (the returned object should be used for all further method calls in connection with this specific database, see {{http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki#database_methods|Database methods}}). Example:

    myDB=sqlite3.open('MyDatabase.sqlite3')  -- open
    +				open = { Params = "FileName", Return = "DBClass", Notes = [[
    +					Opens (or creates if it does not exist) an SQLite database with name filename and returns its
    +					handle as userdata (the returned object should be used for all further method calls in connection
    +					with this specific database, see
    +					{{http://lua.sqlite.org/index.cgi/doc/tip/doc/lsqlite3.wiki#database_methods|Database methods}}).
    +					Example:
    +
    +-- open the database:
    +myDB = sqlite3.open('MyDatabaseFile.sqlite3')
    +
     -- do some database calls...
    -myDB:close()  -- close
    -TakeDamageInfo =
    ]], }, - open_memory = { Return = "userdata", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, + +-- Close the database: +myDB:close() +
    + ]], }, + open_memory = { Return = "DBClass", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, temp_directory = { Params = "string", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, version = { Return = "string", Notes = "Returns a string with SQLite version information, in the form 'x.y[.z]'." }, }, -- cgit v1.2.3 From 38fe16d8b6bfc41f077cb700a3bc5a537cf28959 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 23 Nov 2013 21:43:38 +0100 Subject: APIDump: Removed unwanted functions. --- MCServer/Plugins/APIDump/APIDesc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 8778727e1..afe002784 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2456,7 +2456,6 @@ myDB:close()
    ]], }, open_memory = { Return = "DBClass", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, - temp_directory = { Params = "string", Notes = "Opens an SQLite database in memory and returns its handle as userdata. In case of an error, the function returns nil, an error code and an error message. (In-memory databases are volatile as they are never stored on disk.)" }, version = { Return = "string", Notes = "Returns a string with SQLite version information, in the form 'x.y[.z]'." }, }, }, @@ -2813,6 +2812,7 @@ end "Globals.collectgarbage", "Globals.xpcall", "Globals.decoda_output", -- When running under Decoda, this function gets added to the global namespace + "sqlite3.__newindex", "%a+\.__%a+", -- AnyClass.__Anything "%a+\.\.collector", -- AnyClass..collector "%a+\.new", -- AnyClass.new @@ -2828,6 +2828,7 @@ end "ListMissingPages", "ListUndocumentedObjects", "ListUnexportedObjects", + "LoadAPIFiles", "ReadDescriptions", "ReadHooks", "WriteHtmlClass", -- cgit v1.2.3 From 51b02854f9f9dc597d095f14c1b05150edf604e4 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 24 Nov 2013 10:03:02 +0100 Subject: APIDump: Removed needless whitespace output. --- MCServer/Plugins/APIDump/main_APIDump.lua | 231 ++++++++++++++---------------- 1 file changed, 108 insertions(+), 123 deletions(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/main_APIDump.lua b/MCServer/Plugins/APIDump/main_APIDump.lua index f77409f91..de4239f7e 100644 --- a/MCServer/Plugins/APIDump/main_APIDump.lua +++ b/MCServer/Plugins/APIDump/main_APIDump.lua @@ -289,50 +289,53 @@ function DumpAPIHtml() end f:write([[ - - + + MCServer API - Index - - + +
    -
    -

    MCServer API - Index

    -
    -
    -

    The API reference is divided into the following sections:

    - - - -
    -

    Class index

    -

    The following classes are available in the MCServer Lua scripting language:

    - -
      -]]); +
      +

      MCServer API - Index

      +
      +
      +

      The API reference is divided into the following sections:

      + +
      +

      Class index

      +

      The following classes are available in the MCServer Lua scripting language: +

      - -
      -

      Hooks

      - -

      A plugin can register to be called whenever an "interesting event" occurs. It does so by calling cPluginManager's AddHook() function and implementing a callback function to handle the event.

      -

      A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it from them. This is determined by the return value from the hook callback function. If the function returns false or no value, the event is propagated further. If the function returns true, the processing is stopped, no other plugin receives the notification (and possibly MCServer disables the default behavior for the event). See each hook's details to see the exact behavior.

      - - - - - - -]]); + f:write([[ +

      +
      +

      Hooks

      +

      + A plugin can register to be called whenever an "interesting event" occurs. It does so by calling + cPluginManager's AddHook() function and implementing a callback + function to handle the event.

      +

      + A plugin can decide whether it will let the event pass through to the rest of the plugins, or hide it + from them. This is determined by the return value from the hook callback function. If the function + returns false or no value, the event is propagated further. If the function returns true, the processing + is stopped, no other plugin receives the notification (and possibly MCServer disables the default + behavior for the event). See each hook's details to see the exact behavior.

      +
      Hook nameCalled when
      + + + + + ]]); for i, hook in ipairs(Hooks) do if (hook.DefaultFnName == nil) then -- The hook is not documented yet @@ -826,16 +829,16 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("

      Functions inherited from ", a_InheritedName, "

      \n"); + cf:write("

      Functions inherited from ", a_InheritedName, "

      \n"); end - cf:write("
      Hook nameCalled when
      \n \n \n \n \n \n \n"); + cf:write("
      NameParametersReturn valueNotes
      \n\n"); for i, func in ipairs(a_Functions) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n"); - cf:write(" \n \n"); + cf:write("\n"); + cf:write("\n"); + cf:write("\n"); + cf:write("\n"); end - cf:write("
      NameParametersReturn valueNotes
      " .. func.Name .. "", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), "
      ", func.Name, "", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "", LinkifyString(func.Notes or "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), "
      \n\n"); + cf:write("\n"); end local function WriteConstantTable(a_Constants, a_Source) @@ -879,16 +882,16 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("

      Member variables inherited from ", a_InheritedName, "

      \n"); + cf:write("

      Member variables inherited from ", a_InheritedName, "

      \n"); end - cf:write(" \n \n \n \n \n \n"); + cf:write("
      NameTypeNotes
      \n"); for i, var in ipairs(a_Variables) do - cf:write(" \n \n"); - cf:write(" \n"); - cf:write(" \n \n"); + cf:write("\n"); + cf:write("\n"); + cf:write("\n \n"); end - cf:write("
      NameTypeNotes
      ", var.Name, "", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), "", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "
      ", var.Name, "", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), "", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "
      \n\n"); + cf:write("\n\n"); end local function WriteDescendants(a_Descendants) @@ -914,25 +917,23 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) CurrInheritance = CurrInheritance.Inherits; end - cf:write([[ - - + cf:write([[ + MCServer API - ]], a_ClassAPI.Name, [[ Class - - + +
      -
      -

      ]], a_ClassAPI.Name, [[

      -
      -
      -

      Contents

      - -

      \n"); -- Write the class description: - cf:write("

      " .. ClassName .. " class

      \n"); + cf:write("

      ", ClassName, " class

      \n"); if (a_ClassAPI.Desc ~= nil) then - cf:write("

      "); + cf:write("

      "); cf:write(LinkifyString(a_ClassAPI.Desc, ClassName)); - cf:write("

      \n\n"); + cf:write("

      \n\n"); end; -- Write the inheritance, if available: if (HasInheritance) then - cf:write(" \n

      Inheritance

      \n"); + cf:write("

      Inheritance

      \n"); if (#InheritanceChain > 0) then - cf:write("

      This class inherits from the following parent classes:

      \n\n
        \n"); + cf:write("

        This class inherits from the following parent classes:

        \n\n"); + cf:write("

      \n"); end if (#a_ClassAPI.Descendants > 0) then - cf:write("

      This class has the following descendants:\n"); + cf:write("

      This class has the following descendants:\n"); WriteDescendants(a_ClassAPI.Descendants); - cf:write("

      \n\n"); + cf:write("

      \n\n"); end end -- Write the constants: if (HasConstants) then - cf:write("

      Constants

      \n"); + cf:write("

      Constants

      \n"); WriteConstants(a_ClassAPI.Constants, a_ClassAPI.ConstantGroups, a_ClassAPI.NumConstantsInGroups, nil); g_Stats.NumTotalConstants = g_Stats.NumTotalConstants + #a_ClassAPI.Constants + (a_ClassAPI.NumConstantsInGroups or 0); for i, cls in ipairs(InheritanceChain) do @@ -1002,7 +1003,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the member variables: if (HasVariables) then - cf:write("

      Member variables

      \n"); + cf:write("

      Member variables

      \n"); WriteVariables(a_ClassAPI.Variables, nil); g_Stats.NumTotalVariables = g_Stats.NumTotalVariables + #a_ClassAPI.Variables; for i, cls in ipairs(InheritanceChain) do @@ -1012,7 +1013,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the functions, including the inherited ones: if (HasFunctions) then - cf:write("

      Functions

      \n"); + cf:write("

      Functions

      \n"); WriteFunctions(a_ClassAPI.Functions, nil); g_Stats.NumTotalFunctions = g_Stats.NumTotalFunctions + #a_ClassAPI.Functions; for i, cls in ipairs(InheritanceChain) do @@ -1023,19 +1024,12 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the additional infos: if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write("

      ", additional.Header, "

      \n"); + cf:write("

      ", additional.Header, "

      \n"); cf:write(LinkifyString(additional.Contents, ClassName)); end end - cf:write([[ -
      - - - - ]]); + cf:write([[
    ]]); cf:close(); end @@ -1052,27 +1046,26 @@ function WriteHtmlHook(a_Hook) end local HookName = a_Hook.DefaultFnName; - f:write([[ - - - MCServer API - ]] .. HookName .. [[ Hook + f:write([[ + + MCServer API - ]], HookName, [[ Hook - - + +
    -
    -

    ]] .. a_Hook.Name .. [[

    -
    -
    -

    -]]); +

    +

    ]], a_Hook.Name, [[

    +
    +
    +

    + ]]); f:write(LinkifyString(a_Hook.Desc, HookName)); - f:write("

    \n

    Callback function

    \n

    The default name for the callback function is "); - f:write(a_Hook.DefaultFnName .. ". It has the following signature:\n\n"); - f:write("

    function " .. HookName .. "(");
    +	f:write("

    \n

    Callback function

    \n

    The default name for the callback function is "); + f:write(a_Hook.DefaultFnName, ". It has the following signature:\n"); + f:write("

    function ", HookName, "(");
     	if (a_Hook.Params == nil) then
     		a_Hook.Params = {};
     	end
    @@ -1082,30 +1075,22 @@ function WriteHtmlHook(a_Hook)
     		end
     		f:write(param.Name);
     	end
    -	f:write(")
    \n\n

    Parameters:

    \n\n \n \n \n \n \n \n"); + f:write(")\n

    Parameters:

    \n
    NameTypeNotes
    \n"); for i, param in ipairs(a_Hook.Params) do - f:write(" \n \n \n \n \n"); + f:write("\n"); end - f:write("
    NameTypeNotes
    " .. param.Name .. "" .. LinkifyString(param.Type, HookName) .. "" .. LinkifyString(param.Notes, HookName) .. "
    ", param.Name, "", LinkifyString(param.Type, HookName), "", LinkifyString(param.Notes, HookName), "
    \n\n

    " .. (a_Hook.Returns or "") .. "

    \n\n"); - f:write([[

    Code examples

    -

    Registering the callback

    - -]]); - f:write("
    \n");
    +	f:write("\n

    " .. (a_Hook.Returns or "") .. "

    \n\n"); + f:write([[

    Code examples

    Registering the callback

    ]]); + f:write("
    \n");
     	f:write([[cPluginManager.AddHook(cPluginManager.]] .. a_Hook.Name .. ", My" .. a_Hook.DefaultFnName .. [[);]]);
     	f:write("
    \n\n"); local Examples = a_Hook.CodeExamples or {}; for i, example in ipairs(Examples) do - f:write("

    " .. (example.Title or "missing Title") .. "

    \n"); - f:write("

    " .. (example.Desc or "missing Desc") .. "

    \n\n"); - f:write("
    " .. (example.Code or "missing Code") .. "\n			
    \n\n"); + f:write("

    ", (example.Title or "missing Title"), "

    \n"); + f:write("

    ", (example.Desc or "missing Desc"), "

    \n"); + f:write("
    ", (example.Code or "missing Code"), "\n
    \n\n"); end - f:write([[
    - - -]]); + f:write([[]]); f:close(); end -- cgit v1.2.3 From e683c54b49f88e989efaef0225de996293f7444c Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 24 Nov 2013 10:08:04 +0100 Subject: APIDump: Moved projectiles' documentation to a separate file. --- MCServer/Plugins/APIDump/APIDesc.lua | 111 +---------------------- MCServer/Plugins/APIDump/Classes/Projectiles.lua | 111 +++++++++++++++++++++++ 2 files changed, 112 insertions(+), 110 deletions(-) create mode 100644 MCServer/Plugins/APIDump/Classes/Projectiles.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index afe002784..44e4bb35f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -63,45 +63,6 @@ g_APIDesc = }, ]]-- - cArrowEntity = - { - Desc = [[ - Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}. - ]], - - Functions = - { - CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" }, - GetDamageCoeff = { Params = "", Return = "number", Notes = "Returns the damage coefficient stored within the arrow. The damage dealt by this arrow is multiplied by this coeff" }, - GetPickupState = { Params = "", Return = "PickupState", Notes = "Returns the pickup state (one of the psXXX constants, above)" }, - IsCritical = { Params = "", Return = "bool", Notes = "Returns true if the arrow should deal critical damage. Based on the bow charge when the arrow was shot." }, - SetDamageCoeff = { Params = "number", Return = "", Notes = "Sets the damage coefficient. The damage dealt by this arrow is multiplied by this coeff" }, - SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" }, - SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" }, - }, - - Constants = - { - psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" }, - psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" }, - psNoPickup = { Notes = "The arrow cannot be picked up at all" }, - }, - - ConstantGroups = - { - PickupState = - { - Include = "ps.*", - TextBefore = [[ - The following constants are used to signalize whether the arrow, once it lands, can be picked by - players: - ]], - }, - }, - - Inherits = "cProjectileEntity", - }, - cBlockArea = { Desc = [[ @@ -850,20 +811,6 @@ cFile:Delete("/usr/bin/virus.exe"); }, }, -- cFile - cFireChargeEntity = - { - Desc = "", - Functions = {}, - Inherits = "cProjectileEntity", - } , - - cGhastFireballEntity = - { - Desc = "", - Functions = {}, - Inherits = "cProjectileEntity", - }, -- cGhastFireballEntity - cGroup = { Desc = [[ @@ -1828,42 +1775,7 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); HOOK_WEATHER_CHANGING = { Notes = "Called just before the weather changes" }, HOOK_WORLD_TICK = { Notes = "Called in each world's tick thread when the game logic is about to tick (20 times a second)." }, }, - }, - - cProjectileEntity = - { - Desc = "", - Functions = - { - GetCreator = { Params = "", Return = "{{cEntity}} descendant", Notes = "Returns the entity who created this projectile. May return nil." }, - GetMCAClassName = { Params = "", Return = "string", Notes = "Returns the string that identifies the projectile type (class name) in MCA files" }, - GetProjectileKind = { Params = "", Return = "ProjectileKind", Notes = "Returns the kind of this projectile (pkXXX constant)" }, - IsInGround = { Params = "", Return = "bool", Notes = "Returns true if this projectile has hit the ground." }, - }, - Constants = - { - pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" }, - pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" }, - pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" }, - pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" }, - pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" }, - pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" }, - pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" }, - pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" }, - pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" }, - pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" }, - pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" }, - }, - ConstantGroups = - { - ProjectileKind = - { - Include = "pk.*", - TextBefore = "The following constants are used to distinguish between the different projectile kinds:", - }, - }, - Inherits = "cEntity", - }, + }, -- cPluginManager cRoot = { @@ -1948,27 +1860,6 @@ end }, }, -- cServer - cThrownEggEntity = - { - Desc = "", - Functions = {}, - Inherits = "cProjectileEntity", - }, -- cThrownEggEntity - - cThrownEnderPearlEntity = - { - Desc = "", - Functions = {}, - Inherits = "cProjectileEntity", - }, -- cThrownEnderPearlEntity - - cThrownSnowballEntity = - { - Desc = "", - Functions = {}, - Inherits = "cProjectileEntity", - }, -- cThrownSnowballEntity - cTracer = { Desc = [[ diff --git a/MCServer/Plugins/APIDump/Classes/Projectiles.lua b/MCServer/Plugins/APIDump/Classes/Projectiles.lua new file mode 100644 index 000000000..08c981e5d --- /dev/null +++ b/MCServer/Plugins/APIDump/Classes/Projectiles.lua @@ -0,0 +1,111 @@ +return +{ + cArrowEntity = + { + Desc = [[ + Represents the arrow when it is shot from the bow. A subclass of the {{cProjectileEntity}}. + ]], + Functions = + { + CanPickup = { Params = "{{cPlayer|Player}}", Return = "bool", Notes = "Returns true if the specified player can pick the arrow when it's on the ground" }, + GetDamageCoeff = { Params = "", Return = "number", Notes = "Returns the damage coefficient stored within the arrow. The damage dealt by this arrow is multiplied by this coeff" }, + GetPickupState = { Params = "", Return = "PickupState", Notes = "Returns the pickup state (one of the psXXX constants, above)" }, + IsCritical = { Params = "", Return = "bool", Notes = "Returns true if the arrow should deal critical damage. Based on the bow charge when the arrow was shot." }, + SetDamageCoeff = { Params = "number", Return = "", Notes = "Sets the damage coefficient. The damage dealt by this arrow is multiplied by this coeff" }, + SetIsCritical = { Params = "bool", Return = "", Notes = "Sets the IsCritical flag on the arrow. Critical arrow deal additional damage" }, + SetPickupState = { Params = "PickupState", Return = "", Notes = "Sets the pickup state (one of the psXXX constants, above)" }, + }, + Constants = + { + psInCreative = { Notes = "The arrow can be picked up only by players in creative gamemode" }, + psInSurvivalOrCreative = { Notes = "The arrow can be picked up by players in survival or creative gamemode" }, + psNoPickup = { Notes = "The arrow cannot be picked up at all" }, + }, + ConstantGroups = + { + PickupState = + { + Include = "ps.*", + TextBefore = [[ + The following constants are used to signalize whether the arrow, once it lands, can be picked by + players: + ]], + }, + }, + Inherits = "cProjectileEntity", + }, -- cArrowEntity + + cFireChargeEntity = + { + Desc = "", + Functions = {}, + Inherits = "cProjectileEntity", + }, -- cFireChargeEntity + + cGhastFireballEntity = + { + Desc = "", + Functions = {}, + Inherits = "cProjectileEntity", + }, -- cGhastFireballEntity + + cProjectileEntity = + { + Desc = "", + Functions = + { + GetCreator = { Params = "", Return = "{{cEntity}} descendant", Notes = "Returns the entity who created this projectile. May return nil." }, + GetMCAClassName = { Params = "", Return = "string", Notes = "Returns the string that identifies the projectile type (class name) in MCA files" }, + GetProjectileKind = { Params = "", Return = "ProjectileKind", Notes = "Returns the kind of this projectile (pkXXX constant)" }, + IsInGround = { Params = "", Return = "bool", Notes = "Returns true if this projectile has hit the ground." }, + }, + Constants = + { + pkArrow = { Notes = "The projectile is an {{cArrowEntity|arrow}}" }, + pkEgg = { Notes = "The projectile is a {{cThrownEggEntity|thrown egg}}" }, + pkEnderPearl = { Notes = "The projectile is a {{cThrownEnderPearlEntity|thrown enderpearl}}" }, + pkExpBottle = { Notes = "The projectile is a thrown exp bottle (NYI)" }, + pkFireCharge = { Notes = "The projectile is a {{cFireChargeEntity|fire charge}}" }, + pkFirework = { Notes = "The projectile is a (flying) firework (NYI)" }, + pkFishingFloat = { Notes = "The projectile is a fishing float (NYI)" }, + pkGhastFireball = { Notes = "The projectile is a {{cGhastFireballEntity|ghast fireball}}" }, + pkSnowball = { Notes = "The projectile is a {{cThrownSnowballEntity|thrown snowball}}" }, + pkSplashPotion = { Notes = "The projectile is a thrown splash potion (NYI)" }, + pkWitherSkull = { Notes = "The projectile is a wither skull (NYI)" }, + }, + ConstantGroups = + { + ProjectileKind = + { + Include = "pk.*", + TextBefore = "The following constants are used to distinguish between the different projectile kinds:", + }, + }, + Inherits = "cEntity", + }, -- cProjectileEntity + + cThrownEggEntity = + { + Desc = "", + Functions = {}, + Inherits = "cProjectileEntity", + }, -- cThrownEggEntity + + cThrownEnderPearlEntity = + { + Desc = "", + Functions = {}, + Inherits = "cProjectileEntity", + }, -- cThrownEnderPearlEntity + + cThrownSnowballEntity = + { + Desc = "", + Functions = {}, + Inherits = "cProjectileEntity", + }, -- cThrownSnowballEntity +} + + + + -- cgit v1.2.3 From a0c6342a294077b67f509b6f319468f56e39e344 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Mon, 25 Nov 2013 21:51:52 +0100 Subject: Documented SpawnExperienceOrb in cWorld --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 44e4bb35f..9f558f58c 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2075,6 +2075,7 @@ end { Params = "{{cItems|Pickups}}, X, Y, Z, SpeedX, SpeedY, SpeedZ", Return = "", Notes = "Spawns the specified pickups at the position specified. All the pickups fly away from the spawn position using the specified speed." }, }, SpawnMob = { Params = "X, Y, Z, {{cMonster|MonsterType}}", Return = "EntityID", Notes = "Spawns the specified type of mob at the specified coords. Returns the EntityID of the creates entity, or -1 on failure. " }, + SpawnExperienceOrb = { Params = "X, Y, Z, Reward", Return = "", Notes = "Spawns an {{cExpOrb|experience orb at the specified coords, with the given reward" }, SpawnPrimedTNT = { Params = "X, Y, Z, FuseTimeSecs, InitialVelocityCoeff", Return = "", Notes = "Spawns a {{cTNTEntity|primed TNT entity}} at the specified coords, with the given fuse time. The entity gets a random speed multiplied by the InitialVelocityCoeff, 1 being the default value." }, TryGetHeight = { Params = "BlockX, BlockZ", Return = "IsValid, Height", Notes = "Returns true and height of the highest non-air block if the chunk is loaded, or false otherwise." }, UnloadUnusedChunks = { Params = "", Return = "", Notes = "Unloads chunks that are no longer needed, and are saved. NOTE: This API is deprecated and will be removed soon." }, -- cgit v1.2.3 From 686e0c12e2fa1b8d8e0970306e57cbcfa247f5f5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Tue, 26 Nov 2013 15:37:15 +0100 Subject: cWorld::SpawnExperienceOrb() now returns the entity ID of the spawned orb. Documented etExpOrb. --- MCServer/Plugins/APIDump/APIDesc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 9f558f58c..6545c1f9f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -769,6 +769,7 @@ end { etBoat = { Notes = "The entity is a {{cBoat}}" }, etEntity = { Notes = "No further specialization available" }, + etExpOrb = { Notes = "The entity is a {{cExpOrb}}" }, etFallingBlock = { Notes = "The entity is a {{cFallingBlock}}" }, etMob = { Notes = "The entity is a {{cMonster}} descendant" }, etMonster = { Notes = "The entity is a {{cMonster}} descendant" }, @@ -2075,7 +2076,7 @@ end { Params = "{{cItems|Pickups}}, X, Y, Z, SpeedX, SpeedY, SpeedZ", Return = "", Notes = "Spawns the specified pickups at the position specified. All the pickups fly away from the spawn position using the specified speed." }, }, SpawnMob = { Params = "X, Y, Z, {{cMonster|MonsterType}}", Return = "EntityID", Notes = "Spawns the specified type of mob at the specified coords. Returns the EntityID of the creates entity, or -1 on failure. " }, - SpawnExperienceOrb = { Params = "X, Y, Z, Reward", Return = "", Notes = "Spawns an {{cExpOrb|experience orb at the specified coords, with the given reward" }, + SpawnExperienceOrb = { Params = "X, Y, Z, Reward", Return = "EntityID", Notes = "Spawns an {{cExpOrb|experience orb}} at the specified coords, with the given reward" }, SpawnPrimedTNT = { Params = "X, Y, Z, FuseTimeSecs, InitialVelocityCoeff", Return = "", Notes = "Spawns a {{cTNTEntity|primed TNT entity}} at the specified coords, with the given fuse time. The entity gets a random speed multiplied by the InitialVelocityCoeff, 1 being the default value." }, TryGetHeight = { Params = "BlockX, BlockZ", Return = "IsValid, Height", Notes = "Returns true and height of the highest non-air block if the chunk is loaded, or false otherwise." }, UnloadUnusedChunks = { Params = "", Return = "", Notes = "Unloads chunks that are no longer needed, and are saved. NOTE: This API is deprecated and will be removed soon." }, -- cgit v1.2.3 From ca79a1a6a6c7b22f82985662a9e688965bfd1d3e Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sat, 30 Nov 2013 13:36:40 +0100 Subject: APIDump: Updated the project file to include all partial docs files. --- MCServer/Plugins/APIDump/APIDump.deproj | 155 +++++++++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDump.deproj b/MCServer/Plugins/APIDump/APIDump.deproj index 9ee9170f2..dffe3eaee 100644 --- a/MCServer/Plugins/APIDump/APIDump.deproj +++ b/MCServer/Plugins/APIDump/APIDump.deproj @@ -4,6 +4,159 @@ APIDesc.lua - main.lua + Classes\BlockEntities.lua + + + Hooks\OnBlockToPickups.lua + + + Hooks\OnChat.lua + + + Hooks\OnChunkAvailable.lua + + + Hooks\OnChunkGenerated.lua + + + Hooks\OnChunkGenerating.lua + + + Hooks\OnChunkUnloaded.lua + + + Hooks\OnChunkUnloading.lua + + + Hooks\OnCollectingPickup.lua + + + Hooks\OnCraftingNoRecipe.lua + + + Hooks\OnDisconnect.lua + + + Hooks\OnExecuteCommand.lua + + + Hooks\OnExploded.lua + + + Hooks\OnExploding.lua + + + Hooks\OnHandshake.lua + + + Hooks\OnHopperPullingItem.lua + + + Hooks\OnHopperPushingItem.lua + + + Hooks\OnKilling.lua + + + Hooks\OnLogin.lua + + + Hooks\OnPlayerAnimation.lua + + + Hooks\OnPlayerBreakingBlock.lua + + + Hooks\OnPlayerBrokenBlock.lua + + + Hooks\OnPlayerEating.lua + + + Hooks\OnPlayerJoined.lua + + + Hooks\OnPlayerLeftClick.lua + + + Hooks\OnPlayerMoving.lua + + + Hooks\OnPlayerPlacedBlock.lua + + + Hooks\OnPlayerPlacingBlock.lua + + + Hooks\OnPlayerRightClick.lua + + + Hooks\OnPlayerRightClickingEntity.lua + + + Hooks\OnPlayerShooting.lua + + + Hooks\OnPlayerSpawned.lua + + + Hooks\OnPlayerTossingItem.lua + + + Hooks\OnPlayerUsedBlock.lua + + + Hooks\OnPlayerUsedItem.lua + + + Hooks\OnPlayerUsingBlock.lua + + + Hooks\OnPlayerUsingItem.lua + + + Hooks\OnPostCrafting.lua + + + Hooks\OnPreCrafting.lua + + + Hooks\OnSpawnedEntity.lua + + + Hooks\OnSpawnedMonster.lua + + + Hooks\OnSpawningEntity.lua + + + Hooks\OnSpawningMonster.lua + + + Hooks\OnTakeDamage.lua + + + Hooks\OnTick.lua + + + Hooks\OnUpdatedSign.lua + + + Hooks\OnUpdatingSign.lua + + + Hooks\OnWeatherChanged.lua + + + Hooks\OnWeatherChanging.lua + + + Hooks\OnWorldTick.lua + + + Classes\Projectiles.lua + + + main_APIDump.lua -- cgit v1.2.3 From e07c54f7f80fc6fe6f2abd8f81b45c8d6dc4e2d7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 1 Dec 2013 16:34:04 +0100 Subject: APIDump: Added missing params to OnPlayerRightClick() hook. --- MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua index d767b449d..de9b3662c 100644 --- a/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua +++ b/MCServer/Plugins/APIDump/Hooks/OnPlayerRightClick.lua @@ -21,6 +21,9 @@ return { Name = "BlockY", Type = "number", Notes = "Y-coord of the block" }, { Name = "BlockZ", Type = "number", Notes = "Z-coord of the block" }, { Name = "BlockFace", Type = "number", Notes = "Face of the block upon which the player interacted. One of the BLOCK_FACE_ constants" }, + { Name = "CursorX", Type = "number", Notes = "X-coord of the mouse crosshair on the block" }, + { Name = "CursorY", Type = "number", Notes = "Y-coord of the mouse crosshair on the block" }, + { Name = "CursorZ", Type = "number", Notes = "Z-coord of the mouse crosshair on the block" }, }, Returns = [[ If the function returns false or no value, MCServer calls other plugins' callbacks and finally sends -- cgit v1.2.3 From 0a2fcf909c5affcb13ef42377c6e0c880dd887c7 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 3 Dec 2013 21:48:40 +0100 Subject: Added a quick LuaRocks testing plugin. You need to install the luarocks system and through it the luasocket and 30log rocks. --- MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua new file mode 100644 index 000000000..6e90b1ae9 --- /dev/null +++ b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua @@ -0,0 +1,49 @@ + +-- TestLuaRocks.lua + +-- This is a mockup plugin that does a quick test of LuaRocks capability in MCServer + +-- "Success" is when the plugin loads, downloads the forum webpage and displays the headers and length and then displays both libs as loaded. +-- "Failure" usually manifests as one of the "require" lines failing, although you have the luarock installed. +-- Note that the plugin deliberately never fully loads, so that it can be reloaded fast by pressing its Enable button in the webadmin's plugin list. + + + + + + +local log30 = require("30log"); +local socket = require("socket"); +local http = require("socket.http"); + + + + + +LOGINFO("Trying to download a webpage..."); +local body, code, headers = http.request('http://forum.mc-server.org/index.php'); +LOG("code: " .. tostring(code)); +LOG("headers: "); +for k, v in pairs(headers or {}) do + LOG(" " .. k .. ": " .. v); +end +LOG("body length: " .. string.length(body)); + + + + + +function Initialize(a_Plugin) + if (socket == nil) then + LOG("LuaSocket not found"); + else + LOG("LuaSocket loaded"); + end + if (log30 == nil) then + LOG("30log not found"); + else + LOG("30log loaded"); + end + LOGINFO("Preventing plugin load so that it may be requested again from the webadmin."); + return false; +end \ No newline at end of file -- cgit v1.2.3 From 5832781727784c9926e397f3ff61d0d456c64797 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Tue, 3 Dec 2013 21:15:43 +0000 Subject: Updated TransAPI, fixes #389 @madmaxoft is this the right API usage? --- MCServer/Plugins/TransAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI index 52e1de433..da2723724 160000 --- a/MCServer/Plugins/TransAPI +++ b/MCServer/Plugins/TransAPI @@ -1 +1 @@ -Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e +Subproject commit da272372406e0990235b008dba73b7bfbda040e8 -- cgit v1.2.3 From a02ed3b92e5d9693df3a31f57d3d93cd70e48417 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 5 Dec 2013 22:06:52 +0100 Subject: APIDump: Documented the new cPluginManager:GetCurrentPlugin() function. --- MCServer/Plugins/APIDump/APIDesc.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 6545c1f9f..a08f6f24b 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -1715,8 +1715,9 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Get = { Params = "", Return = "cPluginManager", Notes = "Returns the single instance of the plugin manager" }, GetAllPlugins = { Params = "", Return = "table", Notes = "Returns a table (dictionary) of all plugins, [name => {{cPlugin}}] pairing." }, GetCommandPermission = { Params = "Command", Return = "Permission", Notes = "Returns the permission needed for executing the specified command" }, + GetCurrentPlugin = { Params = "", Return = "{{cPlugin}}", Notes = "Returns the {{cPlugin}} object for the calling plugin. This is the same object that the Initialize function receives as the argument." }, GetNumPlugins = { Params = "", Return = "number", Notes = "Returns the number of plugins, including the disabled ones" }, - GetPlugin = { Params = "PluginName", Return = "{{cPlugin|cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" }, + GetPlugin = { Params = "PluginName", Return = "{{cPlugin}}", Notes = "Returns a plugin handle of the specified plugin" }, IsCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if in-game Command is already bound (by any plugin)" }, IsConsoleCommandBound = { Params = "Command", Return = "bool", Notes = "Returns true if console Command is already bound (by any plugin)" }, LoadPlugin = { Params = "PluginFolder", Return = "", Notes = "(DEPRECATED) Loads a plugin from the specified folder. NOTE: Loading plugins may be an unsafe operation and may result in a deadlock or a crash. This API is deprecated and might be removed." }, -- cgit v1.2.3 From 88d64548821a24fd8036a75ed6f30fb8069181b3 Mon Sep 17 00:00:00 2001 From: Samuel Barney Date: Thu, 5 Dec 2013 22:42:52 -0700 Subject: I don't know how this dissapeard. --- MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua new file mode 100644 index 000000000..6e90b1ae9 --- /dev/null +++ b/MCServer/Plugins/TestLuaRocks/TestLuaRocks.lua @@ -0,0 +1,49 @@ + +-- TestLuaRocks.lua + +-- This is a mockup plugin that does a quick test of LuaRocks capability in MCServer + +-- "Success" is when the plugin loads, downloads the forum webpage and displays the headers and length and then displays both libs as loaded. +-- "Failure" usually manifests as one of the "require" lines failing, although you have the luarock installed. +-- Note that the plugin deliberately never fully loads, so that it can be reloaded fast by pressing its Enable button in the webadmin's plugin list. + + + + + + +local log30 = require("30log"); +local socket = require("socket"); +local http = require("socket.http"); + + + + + +LOGINFO("Trying to download a webpage..."); +local body, code, headers = http.request('http://forum.mc-server.org/index.php'); +LOG("code: " .. tostring(code)); +LOG("headers: "); +for k, v in pairs(headers or {}) do + LOG(" " .. k .. ": " .. v); +end +LOG("body length: " .. string.length(body)); + + + + + +function Initialize(a_Plugin) + if (socket == nil) then + LOG("LuaSocket not found"); + else + LOG("LuaSocket loaded"); + end + if (log30 == nil) then + LOG("30log not found"); + else + LOG("30log loaded"); + end + LOGINFO("Preventing plugin load so that it may be requested again from the webadmin."); + return false; +end \ No newline at end of file -- cgit v1.2.3 From 38563db3ce2cd66e46880798c4420019735fe881 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 7 Dec 2013 07:22:48 +0000 Subject: Updated TRANSAPI --- MCServer/Plugins/TransAPI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/TransAPI b/MCServer/Plugins/TransAPI index 52e1de433..6527b80a7 160000 --- a/MCServer/Plugins/TransAPI +++ b/MCServer/Plugins/TransAPI @@ -1 +1 @@ -Subproject commit 52e1de4332a026e58fda843aae98c1f51e57199e +Subproject commit 6527b80a77b3b7f5fac0ef214c1b59ad83e39b20 -- cgit v1.2.3 From 02301bc9871a707f34cbeb8b2b0cae02b16c1a4f Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Sat, 7 Dec 2013 14:30:17 +0100 Subject: Documented SpawnFallingBlock() --- MCServer/Plugins/APIDump/APIDesc.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index a08f6f24b..75d5c011f 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -2077,6 +2077,7 @@ end { Params = "{{cItems|Pickups}}, X, Y, Z, SpeedX, SpeedY, SpeedZ", Return = "", Notes = "Spawns the specified pickups at the position specified. All the pickups fly away from the spawn position using the specified speed." }, }, SpawnMob = { Params = "X, Y, Z, {{cMonster|MonsterType}}", Return = "EntityID", Notes = "Spawns the specified type of mob at the specified coords. Returns the EntityID of the creates entity, or -1 on failure. " }, + SpawnFallingBlock = { Params = "X, Y, Z, BlockType, BlockMeta", Return = "EntityID", Notes = "Spawns an {{cFallingBlock|Falling Block}} entity at the specified coords with the given block type/meta" }, SpawnExperienceOrb = { Params = "X, Y, Z, Reward", Return = "EntityID", Notes = "Spawns an {{cExpOrb|experience orb}} at the specified coords, with the given reward" }, SpawnPrimedTNT = { Params = "X, Y, Z, FuseTimeSecs, InitialVelocityCoeff", Return = "", Notes = "Spawns a {{cTNTEntity|primed TNT entity}} at the specified coords, with the given fuse time. The entity gets a random speed multiplied by the InitialVelocityCoeff, 1 being the default value." }, TryGetHeight = { Params = "BlockX, BlockZ", Return = "IsValid, Height", Notes = "Returns true and height of the highest non-air block if the chunk is loaded, or false otherwise." }, -- cgit v1.2.3 From 87680186ef66e957ef664bff4405a5a5235e4635 Mon Sep 17 00:00:00 2001 From: Alexander Harkness Date: Sat, 7 Dec 2013 16:34:38 +0000 Subject: Updated core. --- MCServer/Plugins/Core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'MCServer/Plugins') diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core index de53a607f..ede668bc7 160000 --- a/MCServer/Plugins/Core +++ b/MCServer/Plugins/Core @@ -1 +1 @@ -Subproject commit de53a607f30c583e08c06b6e5eb936cd278ab8cd +Subproject commit ede668bc7c310af49ad7354c00d3f11adbae792a -- cgit v1.2.3