06-06-2012, 01:24 AM
Wow, I'm good
OnChunkGenerated hook is available in Rev 558. It is called by the chunk generator each time a new chunk is generated. At the time of calling, the chunk is already valid in cWorld, so it can be modified directly using cWorld's methods (note that they are notoriously slow, you don't want to query an entire chunk block-by-block!)
Here's a quick sample plugin that uses that hook. It logs every chunk generated and then places a glowstone block at the XZ center of each chunk in Y=40:
OnChunkGenerated hook is available in Rev 558. It is called by the chunk generator each time a new chunk is generated. At the time of calling, the chunk is already valid in cWorld, so it can be modified directly using cWorld's methods (note that they are notoriously slow, you don't want to query an entire chunk block-by-block!)
Here's a quick sample plugin that uses that hook. It logs every chunk generated and then places a glowstone block at the XZ center of each chunk in Y=40:
Code:
function Initialize( Plugin )
PLUGIN = Plugin
Plugin:SetName( "GeneLog" )
Plugin:SetVersion(1)
PluginManager = cRoot:Get():GetPluginManager()
PluginManager:AddHook(Plugin, cPluginManager.E_PLUGIN_CHUNK_GENERATED)
LOG( "Initialized " .. Plugin:GetName() .. " v." .. Plugin:GetVersion() )
return true
end
function OnChunkGenerated(World, ChunkX, ChunkZ)
LOG("Lua GeneLog: Generated chunk [" .. ChunkX .. ", " .. ChunkZ .. "] in world " .. World:GetName() .. ".")
World:SetBlock(ChunkX * 16 + 8, 40, ChunkZ * 16 + 8, E_BLOCK_GLOWSTONE, 0)
end