03-13-2017, 05:00 AM
Then you probably want something like this:
You can add new areas by putting them into g_Areas. Currently only one world is used, but it shouldn't be hard to make this work for multiple worlds.
-- g_Areas - An array containing cuboid objects. We assume all cuboids have their coordinates sorted. -- world - The cWorld object where all modifications will be taking place -- g_CoolDownPeriodTicks - The amount of ticks before the areas should be replaced again. function ReplaceAllBlocks() -- Assuming area is a cCuboid for idx, area in ipairs(g_Areas) do local blockArea = cBlockArea(); blockArea:Read(world, area); local sizeX, sizeY, sizeZ = blockArea:GetCoordRange() for relX = 0, sizeX do for relY = 0, sizeY do for relZ = 0, sizeZ do if (blockArea:GetRelBlockType(relX, relY, relZ) == E_BLOCK_STONE) then blockArea:SetRelBlockType(relX, relY, relZ, E_BLOCK_DIRT) end end end end blockArea:Write(world, area.p1) end world:ScheduleTask(g_CoolDownPeriodTicks, world) end
You can add new areas by putting them into g_Areas. Currently only one world is used, but it shouldn't be hard to make this work for multiple worlds.