summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-10-12 18:29:06 +0200
committermadmaxoft <github@xoft.cz>2013-10-12 18:29:06 +0200
commit9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc (patch)
tree29d69f258c96d8d6be25cd62a88ad0ed8f48d865
parentAPIDump: Added the possibility of extra code examples for hooks. (diff)
downloadcuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.tar
cuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.tar.gz
cuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.tar.bz2
cuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.tar.lz
cuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.tar.xz
cuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.tar.zst
cuberite-9b13a401f60d7bc9d5f0ff8fe326125fe8ab44bc.zip
Diffstat (limited to '')
-rw-r--r--MCServer/Plugins/APIDump/APIDesc.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/MCServer/Plugins/APIDump/APIDesc.lua b/MCServer/Plugins/APIDump/APIDesc.lua
index 513af7816..78ae4be1e 100644
--- a/MCServer/Plugins/APIDump/APIDesc.lua
+++ b/MCServer/Plugins/APIDump/APIDesc.lua
@@ -2086,6 +2086,32 @@ World:ForEachEntity(
Either way, the server will then spawn pickups specified in the Pickups parameter, so to disable
pickups, you need to Clear the object first, then return true.
]],
+ CodeExamples =
+ {
+ {
+ Title = "Modify pickups",
+ Desc = "This example callback function makes tall grass drop diamonds when digged by natural causes (washed away by water).",
+ Code = [[
+function OnBlockToPickups(a_World, a_Digger, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_Pickups)
+ if (a_Digger ~= nil) then
+ -- Not a natural cause
+ return false;
+ end
+ if (a_BlockType ~= E_BLOCK_TALL_GRASS) then
+ -- Not a tall grass being washed away
+ return false;
+ end
+
+ -- Remove all pickups suggested by MCServer:
+ a_Pickups:Clear();
+
+ -- Drop a diamond:
+ a_Pickups:Add(cItem(E_ITEM_DIAMOND));
+ return true;
+end;
+ ]],
+ },
+ } , -- CodeExamples
}, -- HOOK_BLOCK_TO_PICKUPS
HOOK_CHAT =