Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 and #tArgs ~= 6 and #tArgs ~= 7 then
- print("citygen <Command> <Corner X> <Height> <Corner Z> <Chunks X> <Chunks Y>")
- return
- end
- wall_blocks = {"stone", "cobblestone", "netherrack", "brick_block", "nether_brick", "sandstone", "sandstone 2"}
- floor_blocks = {"planks", "planks 1", "planks 2", "planks 3", "planks 4", "planks 5"}
- glass_blocks = {"glass", "stained_glass", "stained_glass 3", "stained_glass 11"}
- door_blocks = {"wooden_door"}
- function csetblock(xshift, yshift, zshift, block)
- x = tArgs[2] + xshift
- y = tArgs[3] + yshift
- z = tArgs[4] + zshift
- --print("Placing block of "..block.." at "..x.." "..y.." "..z)
- commands.exec("setblock "..x.." "..y.." "..z.." "..block)
- end
- function fillblock(xshift, yshift, zshift, xlength, zlength, block)
- xposition = 0
- while xposition < xlength do
- zposition = 0
- while zposition < zlength do
- csetblock(xshift + xposition, yshift, zshift + zposition, block)
- zposition = zposition + 1
- end
- xposition = xposition + 1
- end
- end
- function createoutline(xshift, yshift, zshift, xlength, zlength, block)
- xposition = 0
- while xposition < xlength do
- zposition = 0
- while zposition < zlength do
- if (xposition == 0 or xposition == xlength - 1) or (zposition == 0 or zposition == zlength - 1) then
- csetblock(xshift + xposition, yshift, zshift + zposition, block)
- end
- zposition = zposition + 1
- end
- xposition = xposition + 1
- end
- end
- function createoutlinewcorners(xshift, yshift, zshift, xlength, zlength, block, cornerblock)
- xposition = 0
- while xposition < xlength do
- zposition = 0
- while zposition < zlength do
- if (xposition == 0 or xposition == zlength - 1) and (zposition == 0 or zposition == zlength - 1) then
- csetblock(xshift + xposition, yshift, zshift + zposition, cornerblock)
- elseif (xposition == 0 or xposition == zlength - 1) or (zposition == 0 or zposition == zlength - 1) then
- csetblock(xshift + xposition, yshift, zshift + zposition, block)
- end
- zposition = zposition + 1
- end
- xposition = xposition + 1
- end
- end
- function buildsidewalk(xshift, zshift)
- fillblock(xshift + 1, 0, zshift + 1, 14, 14, "grass")
- createoutline(xshift, 0, zshift, 16, 16, "stone")
- end
- function buildskyscraper(xshift, zshift)
- wall = wall_blocks[math.random(1, #wall_blocks)]
- floor = floor_blocks[math.random(1, #floor_blocks)]
- glass = glass_blocks[math.random(1, #glass_blocks)]
- door = door_blocks[math.random(1, #door_blocks)]
- lawn = math.random(1, 3)
- createoutline(xshift + lawn + 1, 0, zshift + lawn + 1, 16 - (2 * lawn) - 2, 16 - (2 * lawn) - 2, wall)
- fillblock(xshift + lawn + 2, 0, zshift + lawn + 2, 16 - (2 * lawn) - 4, 16 - (2 * lawn) - 4, floor)
- floors = math.random(3,10)
- --the below line is for quick debugging
- --floors = 1
- blocky = 1
- floory = 0
- door_direction = math.random(1, 4)
- if door_direction == 1 then
- fillblock(xshift + 7, 0, zshift + 1, 2, lawn, "stone")
- elseif door_direction == 2 then
- fillblock(xshift + 7, 0, zshift + 15 - lawn, 2, lawn, "stone")
- elseif door_direction == 3 then
- fillblock(xshift + 1, 0, zshift + 7, lawn, 2, "stone")
- elseif door_direction == 4 then
- fillblock(xshift + 15 - lawn, 0, zshift + 7, lawn, 2, "stone")
- end
- while floory * 4 + blocky < floors * 4 + 1 do
- if blocky == 0 then
- createoutline(xshift + lawn + 1, floory * 4 + blocky, zshift + lawn + 1, 16 - (2 * lawn) - 2, 16 - (2 * lawn) - 2, wall)
- fillblock(xshift + lawn + 2, floory * 4 + blocky, zshift + lawn + 2, 16 - (2 * lawn) - 4, 16 - (2 * lawn) - 4, floor)
- else
- createoutlinewcorners(xshift + lawn + 1, floory * 4 + blocky, zshift + lawn + 1, 16 - (2 * lawn) - 2, 16 - (2 * lawn) - 2, glass, wall)
- end
- if blocky == 3 then
- floory = floory + 1
- blocky = 0
- else
- blocky = blocky + 1
- end
- end
- createoutline(xshift + lawn + 1, floory * 4 + blocky, zshift + lawn + 1, 16 - (2 * lawn) - 2, 16 - (2 * lawn) - 2, wall)
- end
- if tArgs[1] == "gen" or tArgs[1] == "generate" then
- xchunk = 0
- while xchunk < tArgs[5] * 1 do
- zchunk = 0
- while zchunk < tArgs[6] * 1 do
- print("Terraforming chunk "..xchunk..", "..zchunk)
- buildsidewalk(16 * xchunk, 16 * zchunk)
- print("Building chunk "..xchunk..", "..zchunk)
- buildskyscraper(16 * xchunk, 16 * zchunk)
- zchunk = zchunk + 1
- end
- xchunk = xchunk + 1
- end
- elseif tArgs[1] == "reset" then
- xchunk = 0
- while xchunk < tArgs[5] * 1 do
- zchunk = 0
- while zchunk < tArgs[6] * 1 do
- print("Reseting chunk "..xchunk..", "..zchunk)
- yposition = 0
- while yposition < 255 - tArgs[3] do
- if yposition == 0 then
- if #tArgs == 6 then
- fillblock(xchunk * 16, yposition, zchunk * 16, 16, 16, "grass")
- elseif #tArgs >= 7 then
- fillblock(xchunk * 16, yposition, zchunk * 16, 16, 16, tArgs[7])
- end
- else
- fillblock(xchunk * 16, yposition, zchunk * 16, 16, 16, "air")
- end
- yposition = yposition + 1
- end
- zchunk = zchunk + 1
- end
- xchunk = xchunk + 1
- end
- elseif tArgs[1] == "terraform" then
- xchunk = 0
- while xchunk < tArgs[5] * 1 do
- zchunk = 0
- while zchunk < tArgs[6] * 1 do
- print("Terraforming chunk "..xchunk..", "..zchunk)
- buildsidewalk(16 * xchunk, 16 * zchunk)
- zchunk = zchunk + 1
- end
- xchunk = xchunk + 1
- end
- elseif tArgs[1] == "build" then
- xchunk = 0
- while xchunk < tArgs[5] * 1 do
- zchunk = 0
- while zchunk < tArgs[6] * 1 do
- print("Building chunk "..xchunk..", "..zchunk)
- buildskyscraper(16 * xchunk, 16 * zchunk)
- zchunk = zchunk + 1
- end
- xchunk = xchunk + 1
- end
- else
- print("Error: Invalid command.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement