diff options
Diffstat (limited to 'MCServer')
-rw-r--r-- | MCServer/Plugins/APIDump/APIDesc.lua | 349 | ||||
-rw-r--r-- | MCServer/Plugins/APIDump/main.lua | 53 | ||||
-rw-r--r-- | MCServer/Plugins/Debuggers/Debuggers.lua | 52 | ||||
-rw-r--r-- | MCServer/items.ini | 2 |
4 files changed, 338 insertions, 118 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index 321f50732..450bc9f28 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -403,20 +403,12 @@ g_APIDesc = in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate in any way.</p> <p> - The chest entity can be created by the plugins only in the {{OnChunkGenerating}} and - {{OnChunkGenerated}} hooks, as part of the new chunk being generated. Plugins may generate chests - with contents in this way.</p> - <p> To manipulate a chest already in the game, you need to use {{cWorld}}'s callback mechanism with either DoWithChestAt() or ForEachChestInChunk() function. See the code example below ]], Inherits = "cBlockEntityWithItems", - Functions = - { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cChestEntity", Notes = "Creates a new cChestEntity object. To be used only in the chunk generating hooks {{OnChunkGenerating}} and {{OnChunkGenerated}}." }, - }, Constants = { ContentsHeight = { Notes = "Height of the contents' {{cItemGrid|ItemGrid}}, as required by the parent class, {{cBlockEntityWithItems}}" }, @@ -466,6 +458,7 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), { Params = "MinRelX, MaxRelX, MinRelY, MaxRelY, MinRelZ, MaxRelZ, BlockType, BlockMeta", Return = "", Notes = "Fills those blocks of the cuboid (specified in relative coords) that are considered non-floor (air, water) with the specified block type and meta. Cuboid may reach outside the chunk, only the part intersecting with this chunk is filled." }, }, GetBiome = { Params = "RelX, RelZ", Return = "EMCSBiome", Notes = "Returns the biome at the specified relative coords" }, + GetBlockEntity = { Params = "RelX, RelY, RelZ", Return = "{{cBlockEntity}} descendant", Notes = "Returns the block entity for the block at the specified coords. Creates it if it doesn't exist. Returns nil if the block has no block entity capability." }, GetBlockMeta = { Params = "RelX, RelY, RelZ", Return = "NIBBLETYPE", Notes = "Returns the block meta at the specified relative coords" }, GetBlockType = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE", Notes = "Returns the block type at the specified relative coords" }, GetBlockTypeMeta = { Params = "RelX, RelY, RelZ", Return = "BLOCKTYPE, NIBBLETYPE", Notes = "Returns the block type and meta at the specified relative coords" }, @@ -504,7 +497,42 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), Constants = { }, - }, + AdditionalInfo = + { + { + Header = "Manipulating block entities", + Contents = [[ + To manipulate block entities while the chunk is generated, first use SetBlockTypeMeta() to set + the correct block type and meta at the position. Then use the GetBlockEntity() to create and + return the correct block entity instance. Finally, use {{tolua}}.cast() to cast to the proper + type.</p> + Note that you don't need to check if a block entity has previously existed at the place, because + GetBlockEntity() will automatically re-create the correct type for you.</p> + <p> + The following code is taken from the Debuggers plugin, it creates a sign at each chunk's [0, 0] + coords, with the text being the chunk coords: +<pre class="prettyprint lang-lua"> +function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) + -- Get the topmost block coord: + local Height = a_ChunkDesc:GetHeight(0, 0); + + -- Create a sign there: + a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0); + local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0); + if (BlockEntity ~= nil) then + LOG("Setting sign lines..."); + local SignEntity = tolua.cast(BlockEntity, "cSignEntity"); + SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)"); + end + + -- Update the heightmap: + a_ChunkDesc:SetHeight(0, 0, Height + 1); +end +</pre> + ]], + }, + }, -- AdditionalInfo + }, -- cChunkDesc cClientHandle = { @@ -642,40 +670,31 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cDispenserEntity = { - Desc = [[This class represents a dispenser block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with a {{cDropperEntity|dropper}} entity. -</p> - <p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). -]], - Functions = - { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDispenserEntity", Notes = "Creates a new cDispenserEntity at the specified coords" }, - }, - Constants = - { - }, + Desc = [[ + This class represents a dispenser block entity in the world. Most of this block entity's + functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents + the behavior common with a {{cDropperEntity|dropper}} entity. + ]], Inherits = "cDropSpenserEntity", }, cDropperEntity = { - Desc = [[This class represents a dropper block entity in the world. Most of this block entity's functionality is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior common with the {{cDispenserEntity|dispenser}} entity. -</p> - <p>An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). -]], - Functions = - { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cDropperEntity", Notes = "Creates a new cDropperEntity at the specified coords" }, - }, - Constants = - { - }, + Desc = [[ + This class represents a dropper block entity in the world. Most of this block entity's functionality + is implemented in the {{cDropSpenserEntity|cDropSpenserEntity}} class that represents the behavior + common with the {{cDispenserEntity|dispenser}} entity.</p> + <p> + An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks). + ]], Inherits = "cDropSpenserEntity", - }, + }, -- cDropperEntity cDropSpenserEntity = { - Desc = [[This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. -]], + Desc = [[ + This is a class that implements behavior common to both {{cDispenserEntity|dispensers}} and {{cDropperEntity|droppers}}. + ]], Functions = { Activate = { Params = "", Return = "", Notes = "Sets the block entity to dropspense an item in the next tick" }, @@ -687,9 +706,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), ContentsWidth = { Notes = "Width (X) of the {{cItemGrid}} representing the contents" }, ContentsHeight = { Notes = "Height (Y) of the {{cItemGrid}} representing the contents" }, }, - Inherits = "cBlockEntityWithItems"; - }, + }, -- cDropSpenserEntity cEnchantments = { @@ -738,6 +756,8 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), enchInfinity = { Notes = "" }, enchKnockback = { Notes = "" }, enchLooting = { Notes = "" }, + enchLuckOfTheSea = { Notes = "" }, + enchLure = { Notes = "" }, enchPower = { Notes = "" }, enchProjectileProtection = { Notes = "" }, enchProtection = { Notes = "" }, @@ -913,7 +933,6 @@ World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(), cFile:Delete("/usr/bin/virus.exe"); </pre></p> ]], - Functions = { Copy = { Params = "SrcFileName, DstFileName", Return = "bool", Notes = "Copies a single file to a new destination. Returns true if successful. Fails if the destination already exists." }, @@ -925,8 +944,7 @@ cFile:Delete("/usr/bin/virus.exe"); IsFolder = { Params = "Path", Return = "bool", Notes = "Returns true if the specified path points to an existing folder." }, Rename = { Params = "OrigPath, NewPath", Return = "bool", Notes = "Renames a file or a folder. Returns true if successful. Undefined result if NewPath already exists." }, }, - - }, + }, -- cFile cFireChargeEntity = { @@ -938,11 +956,11 @@ cFile:Delete("/usr/bin/virus.exe"); cFurnaceEntity = { - Desc = [[This class represents a furnace block entity in the world. An object of this class can be created from scratch when generating chunks ({{OnChunkGenerated|OnChunkGenerated}} and {{OnChunkGenerating|OnChunkGenerating}} hooks) -]], + Desc = [[ + This class represents a furnace block entity in the world. + ]], Functions = { - constructor = { Params = "BlockX, BlockY, BlockZ, BlockType, BlockMeta", Return = "cFurnaceEntity", Notes = "Creates a new cFurnaceEntity at the specified coords and the specified block type / meta" }, GetCookTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current item finishes cooking, in ticks" }, GetFuelBurnTimeLeft = { Params = "", Return = "number", Notes = "Returns the time until the current fuel is depleted, in ticks" }, GetFuelSlot = { Params = "", Return = "{{cItem|cItem}}", Notes = "Returns the item in the fuel slot" }, @@ -996,14 +1014,10 @@ cFile:Delete("/usr/bin/virus.exe"); cHopperEntity = { Desc = [[ - This class represents a hopper block entity in the world.</p> - <p> - Plugins may use this class during chunk generation ({{OnChunkGenerated|HOOK_CHUNK_GENERATED}} and - {{OnChunkGenerating|HOOK_CHUNK_GENERATING}}) to add hoppers to the generated chunk. + This class represents a hopper block entity in the world. ]], Functions = { - constructor = { Params = "BlockX, BlockY, BlockZ", Return = "cHopperEntity", Notes = "Creates and returns a new hopper at the specified coords." }, GetOutputBlockPos = { Params = "BlockMeta", Return = "bool, BlockX, BlockY, BlockZ", Notes = "Returns whether the hopper is attached, and if so, the block coords of the block receiving the output items, based on the given meta." }, }, Constants = @@ -1255,6 +1269,7 @@ These ItemGrids are available in the API and can be manipulated by the plugins, DamageItem = { Params = "[Amount]", Return = "bool", Notes = "Adds the specified damage. Returns true when damage reaches max value and the item should be destroyed (but doesn't destroy the item)" }, Empty = { Params = "", Return = "", Notes = "Resets the instance to an empty item" }, GetMaxDamage = { Params = "", Return = "number", Notes = "Returns the maximum value for damage that this item can get before breaking; zero if damage is not accounted for for this item type" }, + GetMaxStackSize = { Params = "", Return = "number", Notes = "Returns the maximum stack size for this item." }, IsDamageable = { Params = "", Return = "bool", Notes = "Returns true if this item does account for its damage" }, IsEmpty = { Params = "", Return = "bool", Notes = "Returns true if this object represents an empty item (zero count or invalid ID)" }, IsEqual = { Params = "cItem", Return = "bool", Notes = "Returns true if the item in the parameter is the same as the one stored in the object (type, damage and enchantments)" }, @@ -1452,6 +1467,22 @@ end }, }, -- cItems + cJukeboxEntity = + { + Desc = [[ + This class represents a jukebox in the world. It can play the records, either when the + {{cPlayer|player}} uses the record on the jukebox, or when a plugin instructs it to play. + ]], + Inherits = "cBlockEntity", + Functions = + { + EjectRecord = { Params = "", Return = "", Notes = "Ejects the current record as a {{cPickup|pickup}}. No action if there's no current record. To remove record without generating the pickup, use SetRecord(0)" }, + GetRecord = { Params = "", Return = "number", Notes = "Returns the record currently present. Zero for no record, E_ITEM_*_DISC for records." }, + PlayRecord = { Params = "", Return = "", Notes = "Plays the currently present record. No action if there's no current record." }, + SetRecord = { Params = "number", Return = "", Notes = "Sets the currently present record. Use zero for no record, or E_ITEM_*_DISC for records." }, + }, + }, -- cJukeboxEntity + cLineBlockTracer = { Desc = [[Objects of this class provide an easy-to-use interface to tracing lines through individual @@ -1683,7 +1714,26 @@ a_Player:OpenWindow(Window); mtZombiePigman = { Notes = "" }, }, Inherits = "cPawn", - }, + }, -- cMonster + + cNoteEntity = + { + Desc = [[ + This class represents a note block entity in the world. It takes care of the note block's pitch, + and also can play the sound, either when the {{cPlayer|player}} right-clicks it, redstone activates + it, or upon a plugin's request.</p> + <p> + 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 = { @@ -1852,7 +1902,7 @@ a_Player:OpenWindow(Window); <pre class="prettyprint lang-lua"> cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); </pre></p> -]], + ]], Functions = { AddHook = @@ -1872,7 +1922,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, DisablePlugin = { Params = "PluginName", Return = "bool", Notes = "Disables a plugin specified by its name. Returns true if the plugin was disabled, false if it wasn't found or wasn't active." }, ExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Executes the command as if given by the specified Player. Checks permissions. Returns true if executed." }, - ExecuteConsoleCommand = { Params = "CommandStr", Return = "bool", Notes = "Executes the command as if given on the server console. Returns true if executed." }, FindPlugins = { Params = "", Return = "", Notes = "Refreshes the list of plugins to include all folders inside the Plugins folder (potentially new disabled plugins)" }, ForceExecuteCommand = { Params = "{{cPlayer|Player}}, CommandStr", Return = "bool", Notes = "Same as ExecuteCommand, but doesn't check permissions" }, ForEachCommand = { Params = "CallbackFn", Return = "bool", Notes = "Calls the CallbackFn function for each command that has been bound using BindCommand(). The CallbackFn has the following signature: <pre class=\"prettyprint lang-lua\">function(Command, Permission, HelpString)</pre>. If the callback returns true, the enumeration is aborted and this API function returns false; if it returns false or no value, the enumeration continues with the next command, and the API function returns true." }, @@ -2000,8 +2049,8 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); GetVirtualRAMUsage = { Params = "", Return = "number", Notes = "Returns the amount of virtual RAM that the entire MCServer process is using, in KiB. Negative if the OS doesn't support this query." }, GetWebAdmin = { Params = "", Return = "{{cWebAdmin|cWebAdmin}}", Notes = "Returns the cWebAdmin object." }, GetWorld = { Params = "WorldName", Return = "{{cWorld|cWorld}}", Notes = "Returns the cWorld object of the given world. It returns nil if there is no world with the given name." }, - QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread The command's output will be sent to console " .. '"stop" and "restart" commands have special handling.' }, - SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds." }, + QueueExecuteConsoleCommand = { Params = "Message", Return = "", Notes = "Queues a console command for execution through the cServer class. The command will be executed in the tick thread. The command's output will be sent to console." }, + SaveAllChunks = { Params = "", Return = "", Notes = "Saves all the chunks in all the worlds. 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 = @@ -2030,35 +2079,22 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); Constants = { }, - }, + }, -- cServer cSignEntity = { Desc = [[ A sign entity represents a sign in the world. This class is only used when generating chunks, so - that the plugins may generate signs within new chunks. + that the plugins may generate signs within new chunks. See the code example in {{cChunkDesc}}. ]], Functions = { + GetLine = { Params = "LineIndex", Return = "string", Notes = "Returns the specified line. LineIndex is expected between 0 and 3. Returns empty string and logs to server console when LineIndex is invalid." }, + SetLine = { Params = "LineIndex, LineText", Return = "", Notes = "Sets the specified line. LineIndex is expected between 0 and 3. Logs to server console when LineIndex is invalid." }, + SetLines = { Params = "Line1, Line2, Line3, Line4", Return = "", Notes = "Sets all the sign's lines at once." }, }, - Constants = - { - }, - Inherits = "cBlockEntity"; - }, - - cStringMap = - { - Desc = [[cStringMap is an object that maps strings with strings, it's also known as a dictionary -]], - Functions = - { - }, - Constants = - { - }, - }, + }, -- cSignEntity cThrownEggEntity = { @@ -2238,7 +2274,6 @@ cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChatMessage); }, GetBlockSkyLight = { Params = "BlockX, BlockY, BlockZ", Return = "number", Notes = "Returns the block skylight of the block at the specified coords, or 0 if the appropriate chunk is not loaded." }, GetBlockTypeMeta = { Params = "BlockX, BlockY, BlockZ", Return = "BlockValid, BlockType, BlockMeta", Notes = "Returns the block type and metadata for the block at the specified coords. The first value specifies if the block is in a valid loaded chunk, the other values are valid only if BlockValid is true." }, - GetClassStatic = { Params = "", Return = "string", Notes = "Returns the name of the class, \"cWorld\"." }, GetDimension = { Params = "", Return = "eDimension", Notes = "Returns the dimension of the world - dimOverworld, dimNether or dimEnd." }, GetGameMode = { Params = "", Return = "eGameMode", Notes = "Returns the gamemode of the world - gmSurvival, gmCreative or gmAdventure." }, GetGeneratorQueueLength = { Params = "", Return = "number", Notes = "Returns the number of chunks that are queued in the chunk generator." }, @@ -2443,6 +2478,112 @@ end }, }, -- ItemCategory + lxp = + { + Desc = [[ + This class provides an interface to the XML parser, + {{http://matthewwild.co.uk/projects/luaexpat/|LuaExpat}}. It provides a SAX interface with an + incremental XML parser.</p> + <p> + With an event-based API like SAX the XML document can be fed to the parser in chunks, and the + parsing begins as soon as the parser receives the first document chunk. LuaExpat reports parsing + events (such as the start and end of elements) directly to the application through callbacks. The + parsing of huge documents can benefit from this piecemeal operation.</p> + <p> + See the online + {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}} for details + on how to work with this parser. The code examples below should provide some basic help, too. + ]], + Functions = + { + new = {Params = "CallbacksTable, [SeparatorChar]", Return = "XMLParser object", Notes = "Creates a new XML parser object, with the specified callbacks table and optional separator character."}, + }, + Constants = + { + _COPYRIGHT = { Notes = "" }, + _DESCRIPTION = { Notes = "" }, + _VERSION = { Notes = "" }, + }, + AdditionalInfo = + { + { + Header = "Parser callbacks", + Contents = [[ + The callbacks table passed to the new() function specifies the Lua functions that the parser + calls upon various events. The following table lists the most common functions used, for a + complete list see the online + {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}}.</p> + <table> + <tr><th>Function name</th><th>Parameters</th><th>Notes</th></tr> + <tr><td>CharacterData</td><td>Parser, string</td><td>Called when the parser recognizes a raw string inside the element</td></tr> + <tr><td>EndElement</td><td>Parser, ElementName</td><td>Called when the parser detects the ending of an XML element</td></tr> + <tr><td>StartElement</td><td>Parser, ElementName, AttributesTable</td><td>Called when the parser detects the start of an XML element. The AttributesTable is a Lua table containing all the element's attributes, both in the array section (in the order received) and in the dictionary section.</td></tr> + </table> + ]], + }, + { + Header = "XMLParser object", + Contents = [[ + The XMLParser object returned by lxp.new provides the functions needed to parse the XML. The + following list provides the most commonly used ones, for a complete list see the online + {{http://matthewwild.co.uk/projects/luaexpat/manual.html#parser|LuaExpat documentation}}. + <ul> + <li>close() - closes the parser, freeing all memory used by it.</li> + <li>getCallbacks() - returns the callbacks table for this parser.</li> + <li>parse(string) - parses more document data. the string contains the next part (or possibly all) of the document. Returns non-nil for success or nil, msg, line, col, pos for error.</li> + <li>stop() - aborts parsing (can be called from within the parser callbacks).</li> + </ul> + ]], + }, + { + Header = "Code example", + Contents = [[ + The following code reads an entire XML file and outputs its logical structure into the console: +<pre class="prettyprint lang-lua"> +local Depth = 0; + +-- Define the callbacks: +local Callbacks = { + CharacterData = function(a_Parser, a_String) + LOG(string.rep(" ", Depth) .. "* " .. a_String); + end + + EndElement = function(a_Parser, a_ElementName) + Depth = Depth - 1; + LOG(string.rep(" ", Depth) .. "- " .. a_ElementName); + end + + StartElement = function(a_Parser, a_ElementName, a_Attribs) + LOG(string.rep(" ", Depth) .. "+ " .. a_ElementName); + Depth = Depth + 1; + end +} + +-- Create the parser: +local Parser = lxp.new(Callbacks); + +-- Parse the XML file: +local f = io.open("file.xml", "rb"); +while (true) do + local block = f:read(128 * 1024); -- Use a 128KiB buffer for reading + if (block == nil) then + -- End of file + break; + end + Parser:parse(block); +end + +-- Signalize to the parser that no more data is coming +Parser:parse(); + +-- Close the parser: +Parser:close(); +</pre> + ]], + }, + }, -- AdditionalInfo + }, -- lxp + TakeDamageInfo = { Desc = [[ @@ -2525,7 +2666,10 @@ end Vector3d = { Desc = [[ - A Vector3d object uses double precision floating point values to describe a point in 3D space. + A Vector3d object uses double precision floating point values to describe a point in 3D space.</p> + <p> + See also {{Vector3f}} for single-precision floating point 3D coords and {{Vector3i}} for integer + 3D coords. ]], Functions = { @@ -2566,25 +2710,72 @@ end Vector3f = { - Desc = [[A Vector3f object uses floating point values to describe a point in space. Vector3f is part of the {{vector3|vector3}} family. -]], + Desc = [[ + A Vector3f object uses floating point values to describe a point in space.</p> + <p> + See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3i}} for integer + 3D coords. + ]], Functions = { + constructor = + { + { Params = "", Return = "Vector3f", Notes = "Creates a new Vector3f object with zero coords" }, + { Params = "x, y, z", Return = "Vector3f", Notes = "Creates a new Vector3f object with the specified coords" }, + { Params = "Vector3f", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified vector" }, + { Params = "{{Vector3d}}", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified {{Vector3d}}" }, + { Params = "{{Vector3i}}", Return = "Vector3f", Notes = "Creates a new Vector3f object as a copy of the specified {{Vector3i}}" }, + }, + operator_mul = + { + { Params = "number", Return = "Vector3f", Notes = "Returns a new Vector3f object that has each of its coords multiplied by the specified number" }, + { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that has each of its coords multiplied by the respective coord of the specified vector." }, + }, + operator_plus = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the vector sum of this vector and the specified vector." }, + operator_sub = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the vector differrence between this vector and the specified vector." }, + Cross = { Params = "Vector3f", Return = "Vector3f", Notes = "Returns a new Vector3f object that holds the cross product of this vector and the specified vector." }, + Dot = { Params = "Vector3f", Return = "number", Notes = "Returns the dot product of this vector and the specified vector." }, + Equals = { Params = "Vector3f", Return = "bool", Notes = "Returns true if the specified vector is exactly equal to this vector." }, + Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector" }, + Normalize = { Params = "", Return = "", Notes = "Normalizes this vector (makes it 1 unit long while keeping the direction). FIXME: Fails for zero vectors." }, + NormalizeCopy = { Params = "", Return = "Vector3f", Notes = "Returns a copy of this vector that is normalized (1 unit long while keeping the same direction). FIXME: Fails for zero vectors." }, + Set = { Params = "x, y, z", Return = "", Notes = "Sets all the coords of the vector at once." }, + SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison." }, }, - Constants = + Variables = { + x = { Type = "number", Notes = "The X coord of the vector." }, + y = { Type = "number", Notes = "The Y coord of the vector." }, + z = { Type = "number", Notes = "The Z coord of the vector." }, }, }, -- Vector3f Vector3i = { - Desc = [[A Vector3i object uses integer values to describe a point in space. Vector3i is part of the {{vector3|vector3}} family. -]], + Desc = [[ + A Vector3i object uses integer values to describe a point in space.</p> + <p> + See also {{Vector3d}} for double-precision floating point 3D coords and {{Vector3f}} for + single-precision floating point 3D coords. + ]], Functions = { + constructor = + { + { Params = "", Return = "Vector3i", Notes = "Creates a new Vector3i object with zero coords." }, + { Params = "x, y, z", Return = "Vector3i", Notes = "Creates a new Vector3i object with the specified coords." }, + { Params = "{{Vector3d}}", Return = "Vector3i", Notes = "Creates a new Vector3i object with coords copied and floor()-ed from the specified {{Vector3d}}." }, + }, + Equals = { Params = "Vector3i", Return = "bool", Notes = "Returns true if this vector is exactly the same as the specified vector." }, + Length = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector." }, + Set = { Params = "x, y, z", Return = "", Notes = "Sets all the coords of the vector at once" }, + SqrLength = { Params = "", Return = "number", Notes = "Returns the (euclidean) length of this vector, squared. This operation is slightly less computationally expensive than Length(), while it conserves some properties of Length(), such as comparison." }, }, - Constants = + Variables = { + x = { Type = "number", Notes = "The X coord of the vector." }, + y = { Type = "number", Notes = "The Y coord of the vector." }, + z = { Type = "number", Notes = "The Z coord of the vector." }, }, }, -- Vector3i diff --git a/MCServer/Plugins/APIDump/main.lua b/MCServer/Plugins/APIDump/main.lua index d84926b53..fa9d29423 100644 --- a/MCServer/Plugins/APIDump/main.lua +++ b/MCServer/Plugins/APIDump/main.lua @@ -373,13 +373,18 @@ function ReadDescriptions(a_API) return false; end - -- Returns true if the function (specified by its fully qualified name) is to be ignored - local function IsFunctionIgnored(a_FnName) + -- Returns true if the function is to be ignored + local function IsFunctionIgnored(a_ClassName, a_FnName) if (g_APIDesc.IgnoreFunctions == nil) then return false; end + if (((g_APIDesc.Classes[a_ClassName] or {}).Functions or {})[a_FnName] ~= nil) then + -- The function is documented, don't ignore + return false; + end + local FnName = a_ClassName .. "." .. a_FnName; for i, name in ipairs(g_APIDesc.IgnoreFunctions) do - if (a_FnName:match(name)) then + if (FnName:match(name)) then return true; end end @@ -482,7 +487,7 @@ function ReadDescriptions(a_API) if (FnDesc == nil) then -- No description for this API function AddFunction(func.Name); - if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + if not(IsFunctionIgnored(cls.Name, FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end else @@ -505,7 +510,7 @@ function ReadDescriptions(a_API) else -- if (APIDesc.Functions ~= nil) for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; - if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + if not(IsFunctionIgnored(cls.Name, FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end end @@ -567,7 +572,7 @@ function ReadDescriptions(a_API) g_Stats.NumUndocumentedClasses = g_Stats.NumUndocumentedClasses + 1; for j, func in ipairs(cls.Functions) do local FnName = func.DocID or func.Name; - if not(IsFunctionIgnored(cls.Name .. "." .. FnName)) then + if not(IsFunctionIgnored(cls.Name, FnName)) then table.insert(cls.UndocumentedFunctions, FnName); end end -- for j, func - cls.Functions[] @@ -586,7 +591,7 @@ function ReadDescriptions(a_API) -- Remove ignored functions: local NewFunctions = {}; for j, fn in ipairs(cls.Functions) do - if (not(IsFunctionIgnored(cls.Name .. "." .. fn.Name))) then + if (not(IsFunctionIgnored(cls.Name, fn.Name))) then table.insert(NewFunctions, fn); end end -- for j, fn @@ -735,14 +740,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write(" <h2>Functions inherited from " .. a_InheritedName .. "</h2>\n"); + cf:write(" <h2>Functions inherited from ", a_InheritedName, "</h2>\n"); end cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Parameters</th>\n <th>Return value</th>\n <th>Notes</th>\n </tr>\n"); for i, func in ipairs(a_Functions) do cf:write(" <tr>\n <td>" .. func.Name .. "</td>\n"); - cf:write(" <td>" .. LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)).. "</td>\n"); - cf:write(" <td>" .. LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)).. "</td>\n"); - cf:write(" <td>" .. LinkifyString(func.Notes or "<i>(undocumented)</i>", (a_InheritedName or a_ClassAPI.Name)) .. "</td>\n </tr>\n"); + cf:write(" <td>", LinkifyString(func.Params or "", (a_InheritedName or a_ClassAPI.Name)), "</td>\n"); + cf:write(" <td>", LinkifyString(func.Return or "", (a_InheritedName or a_ClassAPI.Name)), "</td>\n"); + cf:write(" <td>", LinkifyString(func.Notes or "<i>(undocumented)</i>", (a_InheritedName or a_ClassAPI.Name)), "</td>\n </tr>\n"); end cf:write(" </table>\n\n"); end @@ -753,14 +758,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write(" <h2>Constants inherited from " .. a_InheritedName .. "</h2>\n"); + cf:write(" <h2>Constants inherited from ", a_InheritedName, "</h2>\n"); end cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Value</th>\n <th>Notes</th>\n </tr>\n"); for i, cons in ipairs(a_Constants) do - cf:write(" <tr>\n <td>" .. cons.Name .. "</td>\n"); - cf:write(" <td>" .. cons.Value .. "</td>\n"); - cf:write(" <td>" .. LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "</td>\n </tr>\n"); + cf:write(" <tr>\n <td>", cons.Name, "</td>\n"); + cf:write(" <td>", cons.Value, "</td>\n"); + cf:write(" <td>", LinkifyString(cons.Notes or "", a_InheritedName or a_ClassAPI.Name), "</td>\n </tr>\n"); end cf:write(" </table>\n\n"); end @@ -771,14 +776,14 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end if (a_InheritedName ~= nil) then - cf:write(" <h2>Member variables inherited from " .. a_InheritedName .. "</h2>\n"); + cf:write(" <h2>Member variables inherited from ", a_InheritedName, "</h2>\n"); end cf:write(" <table>\n <tr>\n <th>Name</th>\n <th>Type</th>\n <th>Notes</th>\n </tr>\n"); for i, var in ipairs(a_Variables) do - cf:write(" <tr>\n <td>" .. var.Name .. "</td>\n"); - cf:write(" <td>" .. LinkifyString(var.Type or "<i>(undocumented)</i>", a_InheritedName or a_ClassAPI.Name) .. "</td>\n"); - cf:write(" <td>" .. LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name) .. "</td>\n </tr>\n"); + cf:write(" <tr>\n <td>", var.Name, "</td>\n"); + cf:write(" <td>", LinkifyString(var.Type or "<i>(undocumented)</i>", a_InheritedName or a_ClassAPI.Name), "</td>\n"); + cf:write(" <td>", LinkifyString(var.Notes or "", a_InheritedName or a_ClassAPI.Name), "</td>\n </tr>\n"); end cf:write(" </table>\n\n"); end @@ -789,7 +794,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) end cf:write("<ul>"); for i, desc in ipairs(a_Descendants) do - cf:write("<li><a href=\"".. desc.Name .. ".html\">" .. desc.Name .. "</a>"); + cf:write("<li><a href=\"", desc.Name, ".html\">", desc.Name, "</a>"); WriteDescendants(desc.Descendants); cf:write("</li>\n"); end @@ -809,7 +814,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) cf:write([[<!DOCTYPE html> <html> <head> - <title>MCServer API - ]] .. a_ClassAPI.Name .. [[ Class</title> + <title>MCServer API - ]], a_ClassAPI.Name, [[ Class</title> <link rel="stylesheet" type="text/css" href="main.css" /> <link rel="stylesheet" type="text/css" href="prettify.css" /> <script src="prettify.js"></script> @@ -818,7 +823,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) <body> <div id="content"> <header> - <h1>]] .. a_ClassAPI.Name .. [[</h1> + <h1>]], a_ClassAPI.Name, [[</h1> <hr /> </header> <h1>Contents</h1> @@ -852,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(" <li><a href=\"#additionalinfo_" .. i .. "\">" .. (additional.Header or "<i>(No header)</i>").. "</a></li>\n"); + cf:write(" <li><a href=\"#additionalinfo_", i, "\">", (additional.Header or "<i>(No header)</i>"), "</a></li>\n"); end end cf:write(" </ul>\n\n"); @@ -915,7 +920,7 @@ function WriteHtmlClass(a_ClassAPI, a_AllAPI) -- Write the additional infos: if (a_ClassAPI.AdditionalInfo ~= nil) then for i, additional in ipairs(a_ClassAPI.AdditionalInfo) do - cf:write(" <a name=\"additionalinfo_" .. i .. "\"><h1>" .. additional.Header .. "</h1></a>\n"); + cf:write(" <a name=\"additionalinfo_", i, "\"><h1>", additional.Header, "</h1></a>\n"); cf:write(LinkifyString(additional.Contents, ClassName)); end end diff --git a/MCServer/Plugins/Debuggers/Debuggers.lua b/MCServer/Plugins/Debuggers/Debuggers.lua index 04a15a002..9350606cc 100644 --- a/MCServer/Plugins/Debuggers/Debuggers.lua +++ b/MCServer/Plugins/Debuggers/Debuggers.lua @@ -26,6 +26,7 @@ function Initialize(Plugin) cPluginManager.AddHook(cPluginManager.HOOK_CHAT, OnChat); cPluginManager.AddHook(cPluginManager.HOOK_PLAYER_RIGHT_CLICKING_ENTITY, OnPlayerRightClickingEntity); cPluginManager.AddHook(cPluginManager.HOOK_WORLD_TICK, OnWorldTick); + cPluginManager.AddHook(cPluginManager.HOOK_CHUNK_GENERATED, OnChunkGenerated); PluginManager = cRoot:Get():GetPluginManager(); PluginManager:BindCommand("/le", "debuggers", HandleListEntitiesCmd, "- Shows a list of all the loaded entities"); @@ -44,6 +45,8 @@ function Initialize(Plugin) PluginManager:BindCommand("/fs", "debuggers", HandleFoodStatsCmd, "- Turns regular foodstats message on or off"); PluginManager:BindCommand("/arr", "debuggers", HandleArrowCmd, "- Creates an arrow going away from the player"); PluginManager:BindCommand("/fb", "debuggers", HandleFireballCmd, "- Creates a ghast fireball as if shot by the player"); + PluginManager:BindCommand("/xpa", "debuggers", HandleAddExperience, "- Adds 200 experience to the player"); + PluginManager:BindCommand("/xpr", "debuggers", HandleRemoveXp, "- Remove all xp"); -- Enable the following line for BlockArea / Generator interface testing: -- PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATED); @@ -499,32 +502,38 @@ end -function OnChunkGenerated(World, ChunkX, ChunkZ, ChunkDesc) - -- Test ChunkDesc / BlockArea interaction - local BlockArea = cBlockArea(); - ChunkDesc:ReadBlockArea(BlockArea, 0, 15, 50, 70, 0, 15); - - -- BlockArea:SaveToSchematicFile("ChunkBlocks_" .. ChunkX .. "_" .. ChunkZ .. ".schematic"); - - ChunkDesc:WriteBlockArea(BlockArea, 5, 115, 5); - return false; +function OnChat(a_Player, a_Message) + return false, "blabla " .. a_Message; end -function OnChat(a_Player, a_Message) - return false, "blabla " .. a_Message; +function OnPlayerRightClickingEntity(a_Player, a_Entity) + LOG("Player " .. a_Player:GetName() .. " right-clicking entity ID " .. a_Entity:GetUniqueID() .. ", a " .. a_Entity:GetClass()); + return false; end -function OnPlayerRightClickingEntity(a_Player, a_Entity) - LOG("Player " .. a_Player:GetName() .. " right-clicking entity ID " .. a_Entity:GetUniqueID() .. ", a " .. a_Entity:GetClass()); - return false; +function OnChunkGenerated(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc) + -- Get the topmost block coord: + local Height = a_ChunkDesc:GetHeight(0, 0); + + -- Create a sign there: + a_ChunkDesc:SetBlockTypeMeta(0, Height + 1, 0, E_BLOCK_SIGN_POST, 0); + local BlockEntity = a_ChunkDesc:GetBlockEntity(0, Height + 1, 0); + if (BlockEntity ~= nil) then + LOG("Setting sign lines..."); + local SignEntity = tolua.cast(BlockEntity, "cSignEntity"); + SignEntity:SetLines("Chunk:", tonumber(a_ChunkX) .. ", " .. tonumber(a_ChunkZ), "", "(Debuggers)"); + end + + -- Update the heightmap: + a_ChunkDesc:SetHeight(0, 0, Height + 1); end @@ -839,3 +848,18 @@ end +function HandleAddExperience(a_Split, a_Player) + a_Player:DeltaExperience(200); + + return true; +end + + + + + +function HandleRemoveXp(a_Split, a_Player) + a_Player:SetCurrentExperience(0); + + return true; +end diff --git a/MCServer/items.ini b/MCServer/items.ini index 42ab22fa3..c09b32f17 100644 --- a/MCServer/items.ini +++ b/MCServer/items.ini @@ -119,7 +119,7 @@ redwool=35:14 blackwool=35:15 dandelion=37 -; Obselete, use a specific flower name instead (or flower) +; Renamed in 1.7, use "poppy" instead; kept for compatibility reasons, will be removed later on. rose=38 flower=38 |