Placing blocks in lua
#11
Then you probably want something like this:
-- 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.
Reply
Thanks given by:


Messages In This Thread
Placing blocks in lua - by yoboykai - 02-25-2017, 03:56 AM
RE: Placing blocks in lua - by Seadragon91 - 02-25-2017, 06:02 AM
RE: Placing blocks in lua - by yoboykai - 02-25-2017, 09:32 AM
RE: Placing blocks in lua - by Seadragon91 - 02-25-2017, 06:18 PM
RE: Placing blocks in lua - by yoboykai - 02-26-2017, 08:40 AM
RE: Placing blocks in lua - by Seadragon91 - 02-27-2017, 11:51 PM
RE: Placing blocks in lua - by yoboykai - 02-28-2017, 10:11 AM
RE: Placing blocks in lua - by yoboykai - 03-12-2017, 09:45 AM
RE: Placing blocks in lua - by NiLSPACE - 03-12-2017, 06:20 PM
RE: Placing blocks in lua - by yoboykai - 03-13-2017, 04:30 AM
RE: Placing blocks in lua - by NiLSPACE - 03-13-2017, 05:00 AM
RE: Placing blocks in lua - by yoboykai - 03-13-2017, 05:59 AM
RE: Placing blocks in lua - by ThuGie - 03-13-2017, 08:22 AM
RE: Placing blocks in lua - by yoboykai - 03-13-2017, 12:27 PM
RE: Placing blocks in lua - by xoft - 03-13-2017, 06:23 PM



Users browsing this thread: 1 Guest(s)