1
0
cuberite-2a/Server/Plugins/APIDump/Hooks/OnBlockSpread.lua

57 lines
2.1 KiB
Lua
Raw Normal View History

2014-03-16 11:12:16 -04:00
return
{
HOOK_BLOCK_SPREAD =
{
CalledWhen = "Called when a block spreads based on world conditions",
DefaultFnName = "OnBlockSpread", -- also used as pagename
Desc = [[
This hook is called when a block spreads.</p>
<p>
2014-03-24 15:01:57 -04:00
The spread carries with it the type of its source - whether it's a block spreads.
It also carries the identification of the actual source. The exact type of the identification
2014-03-16 11:12:16 -04:00
depends on the source kind:
<table>
<tr><th>Source</th><th>Notes</th></tr>
2014-03-16 17:28:53 -04:00
<tr><td>ssFireSpread</td><td>Fire spreading</td></tr>
<tr><td>ssGrassSpread</td><td>Grass spreading</td></tr>
<tr><td>ssMushroomSpread</td><td>Mushroom spreading</td></tr>
<tr><td>ssMycelSpread</td><td>Mycel spreading</td></tr>
<tr><td>ssVineSpread</td><td>Vine spreading</td></tr>
2014-03-16 11:12:16 -04:00
</table></p>
]],
Params =
{
{ Name = "World", Type = "{{cWorld}}", Notes = "The world in which the block resides" },
{ 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 = "Source", Type = "eSpreadSource", Notes = "Source of the spread. See the table above." },
},
Returns = [[
If the function returns false or no value, the next plugin's callback is called, and finally
Cuberite will process the spread. If the function
2014-03-16 11:12:16 -04:00
returns true, no other callback is called for this event and the spread will not occur.
]],
Examples =
{
{
Title = "Stop fire spreading",
Desc = "Stops fire from spreading, but does not remove any player-placed fire.",
Code = [[
function OnBlockSpread(World, BlockX, Blocky, BlockZ, source)
if (source == ssFireSpread) then
-- Return true to block the fire spreading.
return true
end
-- We don't care about any other events, let them continue.
return false
end
-- Add the callback.
cPluginManager:AddHook(cPluginManager.HOOK_BLOCK_SPREAD, OnBlockSpread);
]],
},
},
2014-03-16 11:12:16 -04:00
}, -- HOOK_BLOCK_SPREAD
}