====== OnChunkGenerating hook callback function ======
OnChunkGenerating() 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 [[API:cChunkDesc|ChunkDesc]] object representing the contents of the chunk. It may override parts of the built-in generator by using the object's **SetUseDefault...(false)** functions.
After all the callbacks for a chunk have been processed, the server will generate the chunk based on the ChunkDesc description - those parts that are set for generating (by default everything) are generated, the rest are read from the ChunkDesc object.

===== Function signature =====
<code lua>
function OnChunkGenerating(World, ChunkX, ChunkZ, ChunkDesc)
</code>
Parameters:
| World | [[API:cWorld]] | World to which the chunk will belong |
| ChunkX | number | X-coord of the chunk |
| ChunkZ | number | Z-coord of the chunk |
| ChunkDesc | [[API:cChunkDesc]] | Chunk contents |

===== Return Values =====
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.


===== Register Callback =====
To register your plugin to receive a callback through this function, use the hook [[api:plugin:hooks|HOOK_CHUNK_GENERATING]]
<code lua>
PluginManager = cPluginManager:GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.HOOK_CHUNK_GENERATING)
</code>