]] .. 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 .. "
\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: madmaxoftfunction 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
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
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: madmaxoftDate: 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') 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():
"; +end + + + + -- cgit v1.2.3 From 7a2170f6b323c4ff1a974699ae3d2e43601d94ad Mon Sep 17 00:00:00 2001 From: madmaxoft
- " .. table.concat(FolderContents, "
- ") .. "
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') 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 - - - --- -]]); - 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("- -MCServer API - Index
-
-The API reference is divided into the following sections:
- --
- -- Class index
-- Hooks
-- Extra pages
-- Documentation statistics
-
-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("Hook name -Called when -\n \n"); - table.insert(UndocumentedHooks, hook.Name); - else - f:write("" .. hook.Name .. " \n(No documentation yet) \n\n \n"); - WriteHtmlHook(hook); - end - end - f:write([[" .. hook.Name .. " \n" .. LinkifyString(hook.CalledWhen, hook.Name) .. " \n
-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("
"); - - -- 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([[ -- " .. extra.Title .. "
\n"); - else - f:write("- " .. extra.Title .. " (file is missing)
\n"); - end - end - f:write("Functions inherited from ", a_InheritedName, "
\n"); - end - cf:write("\n
\n\n"); - end - - local function WriteConstants(a_Constants, a_InheritedName) - if (#a_Constants == 0) then - return; - end - - if (a_InheritedName ~= nil) then - cf:write("\n \n"); - for i, func in ipairs(a_Functions) do - cf:write("Name \nParameters \nReturn value \nNotes \n\n \n"); - end - cf:write("" .. 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 "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), " \nConstants inherited from ", a_InheritedName, "
\n"); - end - - cf:write("\n
\n\n"); - end - - local function WriteVariables(a_Variables, a_InheritedName) - if (#a_Variables == 0) then - return; - end - - if (a_InheritedName ~= nil) then - cf:write("\n \n"); - for i, cons in ipairs(a_Constants) do - cf:write("Name \nValue \nNotes \n\n \n"); - end - cf:write("", cons.Name, " \n"); - cf:write("", cons.Value, " \n"); - cf:write("", LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name), " \nMember variables inherited from ", a_InheritedName, "
\n"); - end - - cf:write("\n
\n\n"); - end - - local function WriteDescendants(a_Descendants) - if (#a_Descendants == 0) then - return; - end - cf:write("\n \n"); - for i, var in ipairs(a_Variables) do - cf:write("Name \nType \nNotes \n\n \n"); - end - cf:write("", var.Name, " \n"); - cf:write("", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), " \n"); - cf:write("", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), " \n"); - for i, desc in ipairs(a_Descendants) do - 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([[ - - -- ", desc.Name, ""); - WriteDescendants(desc.Descendants); - cf:write("
\n"); - end - cf:write("MCServer API - ]], a_ClassAPI.Name, [[ Class - - - - - - --- - - - ]]); - 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([[ - - -- -]], 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("
\n\n"); - - -- Write the class description: - 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("" .. 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(" \nInheritance
\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("
\n\n"); - end - if (#a_ClassAPI.Descendants > 0) then - cf:write("- " .. cls.Name .. "
\n"); - end - 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([[ -MCServer API - ]] .. HookName .. [[ Hook - - - - - - --- - -]]); - 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", - "- -]] .. a_Hook.Name .. [[
-
--]]); - f:write(LinkifyString(a_Hook.Desc, HookName)); - f:write("
\nCallback function
\nThe 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\nParameters:
\n\n\n
\n\n\n \n"); - for i, param in ipairs(a_Hook.Params) do - f:write("Name \nType \nNotes \n\n \n"); - end - f:write("" .. param.Name .. " \n" .. LinkifyString(param.Type, HookName) .. " \n" .. LinkifyString(param.Notes, HookName) .. " \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([[\n", - "\n", - string.format("%.2f", a_Percent), - " %", - }; - return table.concat(meter, ""); - end - - f:write([[ - Documentation statistics
--
- ]]); - f:write(" Object Total Documented Undocumented Documented % \n"); - - f:write(" 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(" \n"); - - 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(" \n"); - - 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(" \n"); - - 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(" \n"); - - 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 + + + +++ +]]); + 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("+ +MCServer API - Index
+
+The API reference is divided into the following sections:
+ ++
+ +- Class index
+- Hooks
+- Extra pages
+- Documentation statistics
+
+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("Hook name +Called when +\n \n"); + table.insert(UndocumentedHooks, hook.Name); + else + f:write("" .. hook.Name .. " \n(No documentation yet) \n\n \n"); + WriteHtmlHook(hook); + end + end + f:write([[" .. hook.Name .. " \n" .. LinkifyString(hook.CalledWhen, hook.Name) .. " \n
+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("
"); + + -- 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([[ +- " .. extra.Title .. "
\n"); + else + f:write("- " .. extra.Title .. " (file is missing)
\n"); + end + end + f:write("Functions inherited from ", a_InheritedName, "
\n"); + end + cf:write("\n
\n\n"); + end + + local function WriteConstantTable(a_Constants, a_Source) + cf:write("\n \n"); + for i, func in ipairs(a_Functions) do + cf:write("Name \nParameters \nReturn value \nNotes \n\n \n"); + end + cf:write("" .. 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 "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), " \n\n
\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("\n"); + for i, cons in ipairs(a_Constants) do + cf:write(" Name Value Notes \n"); + end + cf:write(" ", cons.Name, " \n"); + cf:write("", cons.Value, " \n"); + cf:write("", LinkifyString(cons.Notes or "", a_Source), " 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"); + end + + local function WriteDescendants(a_Descendants) + if (#a_Descendants == 0) then + return; + end + cf:write("\n \n"); + for i, var in ipairs(a_Variables) do + cf:write("Name \nType \nNotes \n\n \n"); + end + cf:write("", var.Name, " \n"); + cf:write("", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), " \n"); + cf:write("", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), " \n"); + for i, desc in ipairs(a_Descendants) do + 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([[ + + +- ", desc.Name, ""); + WriteDescendants(desc.Descendants); + cf:write("
\n"); + end + cf:write("MCServer API - ]], a_ClassAPI.Name, [[ Class + + + + + + +++ + + + ]]); + 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([[ + + ++ +]], 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("
\n\n"); + + -- Write the class description: + 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("" .. 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(" \nInheritance
\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("
\n\n"); + end + if (#a_ClassAPI.Descendants > 0) then + cf:write("- " .. cls.Name .. "
\n"); + end + 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([[ +MCServer API - ]] .. HookName .. [[ Hook + + + + + + +++ + +]]); + 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", + "+ +]] .. a_Hook.Name .. [[
+
++]]); + f:write(LinkifyString(a_Hook.Desc, HookName)); + f:write("
\nCallback function
\nThe 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\nParameters:
\n\n\n
\n\n\n \n"); + for i, param in ipairs(a_Hook.Params) do + f:write("Name \nType \nNotes \n\n \n"); + end + f:write("" .. param.Name .. " \n" .. LinkifyString(param.Type, HookName) .. " \n" .. LinkifyString(param.Notes, HookName) .. " \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([[\n", + "\n", + string.format("%.2f", a_Percent), + " %", + }; + return table.concat(meter, ""); + end + + f:write([[ + Documentation statistics
++
+ ]]); + f:write(" Object Total Documented Undocumented Documented % \n"); + + f:write(" 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(" \n"); + + 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(" \n"); + + 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(" \n"); + + 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(" \n"); + + 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: madmaxoftDate: 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') 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
"); + cf:write(LinkifyString(group.TextAfter or "", Source), ""); end end end -- cgit v1.2.3 From cc77ffd0698ed9a533d8e06de53bab9380b45b80 Mon Sep 17 00:00:00 2001 From: STRWarriorDate: 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') 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 "", "
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') 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: madmaxoftDate: 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') 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: -
-
- ]], - 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. -- Source SourceData Type Notes - 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}}. - esWitherSkullBlack TBD A black wither skull hitting ground or an {{cEntity|entity}}. - esWitherSkullBlue TBD A blue wither skull hitting ground or an {{cEntity|entity}}. - esWitherBirth TBD A wither boss being created - esOther TBD Any other previously unspecified type. - esPlugin object An explosion created by a plugin. The plugin may specify any kind of data. - 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: -
-
- ]], - 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. -- Source SourceData Type Notes - 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}}. - esWitherSkullBlack TBD A black wither skull hitting ground or an {{cEntity|entity}}. - esWitherSkullBlue TBD A blue wither skull hitting ground or an {{cEntity|entity}}. - esWitherBirth TBD A wither boss being created - esOther TBD Any other previously unspecified type. - esPlugin object An explosion created by a plugin. The plugin may specify any kind of data. - 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: +
+
+ ]], + 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. ++ Source SourceData Type Notes + 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}}. + esWitherSkullBlack TBD A black wither skull hitting ground or an {{cEntity|entity}}. + esWitherSkullBlue TBD A blue wither skull hitting ground or an {{cEntity|entity}}. + esWitherBirth TBD A wither boss being created + esOther TBD Any other previously unspecified type. + esPlugin object An explosion created by a plugin. The plugin may specify any kind of data. + 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: +
+
+ ]], + 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. ++ Source SourceData Type Notes + 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}}. + esWitherSkullBlack TBD A black wither skull hitting ground or an {{cEntity|entity}}. + esWitherSkullBlue TBD A blue wither skull hitting ground or an {{cEntity|entity}}. + esWitherBirth TBD A wither boss being created + esOther TBD Any other previously unspecified type. + esPlugin object An explosion created by a plugin. The plugin may specify any kind of data. + 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') 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_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+-- 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() +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') 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') 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
-- Hooks
-- Extra pages
-- Documentation statistics
-
-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
+- Hooks
+- Extra pages
+- Documentation statistics
+
+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"); + 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.
- --
- -]]); + f:write([[ + +Hook name -Called when -
+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 @@ -826,16 +829,16 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write("Hook name +Called when +Functions inherited from ", a_InheritedName, "
\n"); + cf:write("Functions inherited from ", a_InheritedName, "
\n"); end - cf:write("\n
\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("\n \n"); + cf:write("Name \nParameters \nReturn value \nNotes \n\n
\n\n"); + cf:write("\n"); for i, func in ipairs(a_Functions) do - cf:write(" Name Parameters Return value Notes \n \n"); + cf:write("" .. 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 "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), " \n\n"); end - cf:write(" ", 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 "(undocumented)", (a_InheritedName or a_ClassAPI.Name)), " Member variables inherited from ", a_InheritedName, "
\n"); + cf:write("Member variables inherited from ", a_InheritedName, "
\n"); end - cf:write("\n
\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([[ +\n \n"); + cf:write("Name \nType \nNotes \n\n\n"); + cf:write("
\n"); for i, var in ipairs(a_Variables) do - cf:write(" Name Type Notes \n \n"); + cf:write("", var.Name, " \n"); - cf:write("", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), " \n"); - cf:write("", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), " \n\n"); end - cf:write(" ", var.Name, " \n"); + cf:write("", LinkifyString(var.Type or "(undocumented)", a_InheritedName or a_ClassAPI.Name), " \n"); + cf:write("", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), " \nMCServer API - ]], a_ClassAPI.Name, [[ Class - - + +-- - - - ]]); + cf:write([[]]); cf:close(); end @@ -1052,27 +1046,26 @@ function WriteHtmlHook(a_Hook) end local HookName = a_Hook.DefaultFnName; - f:write([[ - - -- -]], a_ClassAPI.Name, [[
-
-Contents
- --]]); +
\n"); -- Write the class description: - cf:write("+ +]], a_ClassAPI.Name, [[
+
+Contents
++ ]]); local HasInheritance = ((#a_ClassAPI.Descendants > 0) or (a_ClassAPI.Inherits ~= nil)); @@ -947,52 +948,52 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the table of contents: if (HasInheritance) then - cf:write("
\n\n"); + cf:write("- Inheritance
\n"); + cf:write("- Inheritance
\n"); end if (HasConstants) then - cf:write("- Constants
\n"); + cf:write("- Constants
\n"); end if (HasVariables) then - cf:write("- Member variables
\n"); + cf:write("- Member variables
\n"); end if (HasFunctions) then - cf:write("- Functions
\n"); + 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"); + cf:write("- ", (additional.Header or "(No header)"), "
\n"); end end - 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(" \nInheritance
\n"); + cf:write("Inheritance
\n"); if (#InheritanceChain > 0) then - cf:write("This class inherits from the following parent classes:
\n\n\n"); + cf:write("
\n"); end if (#a_ClassAPI.Descendants > 0) then - cf:write("This class inherits from the following parent classes:
\n"); for i, cls in ipairs(InheritanceChain) do - cf:write("
\n\n"); + cf:write("- " .. cls.Name .. "
\n"); + cf:write("- ", cls.Name, "
\n"); end - 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([[ -MCServer API - ]] .. HookName .. [[ Hook + f:write([[ + +MCServer API - ]], HookName, [[ Hook - - + +-- - -]]); + f:write([[]]); f:close(); end -- cgit v1.2.3 From e683c54b49f88e989efaef0225de996293f7444c Mon Sep 17 00:00:00 2001 From: madmaxoft- -]] .. a_Hook.Name .. [[
-
--]]); +
+ +]], a_Hook.Name, [[
+
++ ]]); f:write(LinkifyString(a_Hook.Desc, HookName)); - f:write("
\nCallback function
\nThe 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("\nCallback function
\nThe 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\nParameters:
\n\n\n
\n\n \n"); + f:write(")\nName \nType \nNotes \nParameters:
\n\n\n
\n"); for i, param in ipairs(a_Hook.Params) do - f:write(" Name Type Notes \n \n"); + f:write("" .. param.Name .. " \n" .. LinkifyString(param.Type, HookName) .. " \n" .. LinkifyString(param.Notes, HookName) .. " \n\n"); end - f:write(" ", param.Name, " ", LinkifyString(param.Type, HookName), " ", LinkifyString(param.Notes, HookName), " " .. (a_Hook.Returns or "") .. "
\n\n"); - f:write([[Code examples
-Registering the callback
- -]]); - f:write("\n"); + f:write("" .. (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([[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') 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