From 1c0f47704f81f06923fac2ad995e74ae972da6b3 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Thu, 26 Sep 2013 21:28:23 +0200 Subject: APIDump: completed cChestEntity docs. --- MCServer/Plugins/APIDump/APIDesc.lua | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua index efe0fc43f..69e1e213d 100644 --- a/MCServer/Plugins/APIDump/APIDesc.lua +++ b/MCServer/Plugins/APIDump/APIDesc.lua @@ -376,17 +376,46 @@ g_APIDesc = Desc = [[ A chest entity is a {{cBlockEntityWithItems|cBlockEntityWithItems}} descendant that represents a chest in the world. Note that doublechests consist of two separate cChestEntity objects, they do not collaborate - in any way. + in any way.

+

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

+

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

+-- Player is a {{cPlayer}} object instance
+local World = Player:GetWorld();
+World:ForEachChestInChunk(Player:GetChunkX(), Player:GetChunkZ(),
+	function (ChestEntity)
+		ChestEntity:SetSlot(0, 0, cItem(E_ITEM_DIAMOND, 64));
+	end
+);
+
+ ]], + }, + }, -- AdditionalInfo }, cChunkDesc = -- cgit v1.2.3