Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --made by elopus001
- --@QuantumWarpCode
- --Version 3.1
- print("Initializing arguements")
- local tArgs = { ... }
- if #tArgs == 1 then
- command = tArgs[1]
- elseif #tArgs == 6 then
- command = tArgs[1]
- xstart = tArgs[2]
- ystart = tArgs[3]
- zstart = tArgs[4]
- xtotal_chunks = tArgs[5]
- ztotal_chunks = tArgs[6]
- elseif #tArgs == 7 then
- command = tArgs[1]
- xstart = tArgs[2]
- ystart = tArgs[3]
- zstart = tArgs[4]
- xtotal_chunks = tArgs[5]
- ztotal_chunks = tArgs[6]
- block_type = tArgs[7]
- else
- print("citygen <Command> <Corner X> <Height> <Corner Z> <Chunks X> <Chunks Y>")
- return
- end
- print("Initializing files...")
- if fs.exists("/blocklog") == true then
- blocklog = io.open("/blocklog", "a")
- else
- blocklog = io.open("/blocklog", "w")
- end
- if fs.exists("/chunklog") == true then
- chunklog = io.open("/chunklog", "a")
- else
- chunklog = io.open("/chunklog", "w")
- end
- print("Initializing variables...")
- --probabilities
- --all values must be integers unless otherwise states
- sleep_time = 0 --does not have to be an integer
- --configure
- async = false
- --block types
- sidewalk_blocks = {"stone", "cobblestone", "stonebrick", "double_stone_slab"}
- wall_blocks = {"stone", "cobblestone", "stonebrick", "iron_block"}
- floor_blocks = {"planks", "planks 1", "planks 5", "wool", "wool 9", "wool 14", "wool 15"}
- ceiling_blocks ={"planks", "planks 1", "planks 5", "stone", "cobblestone", "stonebrick"}
- glass_blocks = {"glass", "stained_glass", "stained_glass 3", "stained_glass 11", "stained_glass 12", "stained_glass 15", "glass_pane", "stained_glass_pane", "stained_glass_pane 3", "stained_glass_pane 11", "stained_glass_pane 12", "stained_glass_pane 15"}
- leave_blocks = {"leaves 4", "leaves 5", "leaves 6", "leaves 7", "leaves2 4", "leaves2 5"}
- flower_blocks = {"tallgrass 1", "tallgrass 2", "yellow_flower", "red_flower", "red_flower 1", "red_flower 2", "red_flower 3" , "red_flower 4", "red_flower 5", "red_flower 6", "red_flower 7", "red_flower 8"}
- light_blocks = {"glowstone"}
- print("Initializing functions...")
- function shiftsetblock(xshift, yshift, zshift, block)
- x = xstart + xshift
- y = ystart + yshift
- z = zstart + zshift
- --blocklog:write("Placing block of "..block.." at "..x.." "..y.." "..z.."\n")
- if async == true then
- commands.execAsync("setblock "..x.." "..y.." "..z.." "..block)
- else
- commands.exec("setblock "..x.." "..y.." "..z.." "..block)
- end
- sleep(sleep_time)
- end
- function fillrectangle(xshift, yshift, zshift, xlength, zlength, block)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, block)
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- function fillrectangleE(xshift, yshift, zshift, xlength, zlength, interiorblock, edgeblock)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- if xcounter == 0 or xcounter == xlength - 1 or zcounter == 0 or zcounter == zlength - 1 then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, edgeblock)
- else
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, interiorblock)
- end
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- function fillrectangleH(xshift, yshift, zshift, xlength, zlength, block)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- if xcounter == 0 or xcounter == xlength - 1 or zcounter == 0 or zcounter == zlength - 1 then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, block)
- end
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- function fillrectangleC(xshift, yshift, zshift, xlength, zlength, interiorblock, cornerblock)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- if (xcounter == 0 or xcounter == xlength - 1) and (zcounter == 0 or zcounter == zlength - 1) then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, cornerblock)
- else
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, interiorblock)
- end
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- function fillrectangleHC(xshift, yshift, zshift, xlength, zlength, edgeblock, cornerblock)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- if (xcounter == 0 or xcounter == xlength - 1) and (zcounter == 0 or zcounter == zlength - 1) then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, cornerblock)
- elseif xcounter == 0 or xcounter == xlength - 1 or zcounter == 0 or zcounter == zlength - 1 then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, edgeblock)
- end
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- function fillrectangleHEC(xshift, yshift, zshift, xlength, zlength, edgeblock, cornerblock)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- if (xcounter == 0 or xcounter == xlength - 1) and (zcounter == 0 or zcounter == zlength - 1) then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, cornerblock)
- elseif xcounter == 0 or xcounter == xlength - 1 or zcounter == 0 or zcounter == zlength - 1 then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, edgeblock)
- end
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- function fillrectangleEC(xshift, yshift, zshift, xlength, zlength, interiorblock, edgeblock, cornerblock)
- xcounter = 0
- while xcounter < xlength do
- zcounter = 0
- while zcounter < zlength do
- if (xcounter == 0 or xcounter == xlength - 1) and (zcounter == 0 or zcounter == zlength - 1) then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, cornerblock)
- elseif xcounter == 0 or xcounter == xlength - 1 or zcounter == 0 or zcounter == zlength - 1 then
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, edgeblock)
- else
- shiftsetblock(xshift + xcounter, yshift, zshift + zcounter, interiorblock)
- end
- zcounter = zcounter + 1
- end
- xcounter = xcounter + 1
- end
- end
- --Building functions
- function buildskyscraper(xshift, yshift, zshift, xlength, zlength, sidewalk_block)
- lawn = math.random(1, 3)
- lawn = 2
- wall = wall_blocks[math.random(1, #wall_blocks)]
- ceiling = ceiling_blocks[math.random(1, #ceiling_blocks)]
- floor_block = floor_blocks[math.random(1, #floor_blocks)]
- glass = glass_blocks[math.random(1, #glass_blocks)]
- light = light_blocks[math.random(1, #light_blocks)]
- leave = leave_blocks[math.random(1, #leave_blocks)]
- floors = math.random(3, 10)
- floory = 0
- ycounter = 0
- floors = 2
- fillrectangleE(xshift + lawn + 1, yshift, zshift + lawn + 1, xlength * 16 - lawn * 2 - 2, zlength * 16 - lawn * 2 - 2, floor_block, wall)
- while floory * 5 + ycounter < floors * 5 do
- if ycounter == 3 then
- fillrectangleE(xshift + lawn + 1, yshift + ycounter + floory * 5 + 1, zshift + lawn + 1, xlength * 16 - lawn * 2 - 2, zlength * 16 - lawn * 2 - 2, ceiling, wall)
- fillrectangle(xshift + 7, yshift + ycounter + floory * 5 + 1, zshift + 7, 2, 2, light)
- shiftsetblock(xshift +7 , yshift + ycounter + floory * 5 + 1, zshift + 8, wall)
- shiftsetblock(xshift +7 , yshift + ycounter + floory * 5 + 1, zshift + 7, "ladder 2")
- elseif ycounter == 4 then
- fillrectangleE(xshift + lawn + 1, yshift + ycounter + floory * 5 + 1, zshift + lawn + 1, xlength * 16 - lawn * 2 - 2, zlength * 16 - lawn * 2 - 2, floor_block, wall)
- if floory * 5 + ycounter + 1 ~= floors * 5 then
- shiftsetblock(xshift +7 , yshift + ycounter + floory * 5 + 1, zshift + 8, wall)
- end
- shiftsetblock(xshift +7 , yshift + ycounter + floory * 5 + 1, zshift + 7, "ladder 2")
- else
- fillrectangleHEC(xshift + lawn + 1, yshift + ycounter + floory * 5 + 1, zshift + lawn + 1, xlength * 16 - lawn * 2 - 2, zlength * 16 - lawn * 2 - 2, glass, wall)
- shiftsetblock(xshift +7 , yshift + ycounter + floory * 5 + 1, zshift + 8, wall)
- shiftsetblock(xshift +7 , yshift + ycounter + floory * 5 + 1, zshift + 7, "ladder 2")
- end
- if ycounter == 4 then
- floory = floory + 1
- ycounter = 0
- else
- ycounter = ycounter + 1
- end
- end
- fillrectangleH(xshift + lawn + 1, yshift + floors * 5 + 1, zshift + lawn + 1, xlength * 16 - lawn * 2 - 2, zlength * 16 - lawn * 2 - 2, wall)
- hedge = math.random(1, 4)
- if hedge == 1 and lawn == 3 then
- fillrectangleH(xshift + lawn - 1, yshift + 1, zshift + lawn - 1, 12, 12, leave)
- end
- door = math.random(1, 15)
- if door == 1 or door == 5 or door == 7 or door == 9 or door == 11 or door == 13 or door == 14 or door == 15 then
- fillrectangle(xshift + 7, 0, zshift + 1, 2, lawn, sidewalk_block)
- fillrectangle(xshift + 7, 1, zshift + 1, 2, lawn + 1, "air")
- fillrectangle(xshift + 7, 2, zshift + 1, 2, lawn + 1, "air")
- end
- if door == 2 or door == 5 or door == 8 or door == 10 or door == 11 or door == 12 or door == 14 or door == 15 then
- fillrectangle(xshift + 1, 0, zshift + 7, lawn, 2, sidewalk_block)
- fillrectangle(xshift + 1, 1, zshift + 7, lawn + 1, 2, "air")
- fillrectangle(xshift + 1, 2, zshift + 7, lawn + 1, 2, "air")
- end
- if door == 3 or door == 6 or door == 7 or door == 10 or door == 11 or door == 12 or door == 13 or door == 15 then
- fillrectangle(xshift + 7, 0, zshift + 14 - lawn, 2, lawn, sidewalk_block)
- fillrectangle(xshift + 7, 1, zshift + 14 - lawn, 2, lawn + 1, "air")
- fillrectangle(xshift + 7, 2, zshift + 14 - lawn, 2, lawn + 1, "air")
- end
- if door == 4 or door == 6 or door == 8 or door == 9 or door == 12 or door == 13 or door == 14 or door == 15 then
- fillrectangle(xshift + 14 - lawn, 0, zshift + 7, lawn, 2, sidewalk_block)
- fillrectangle(xshift + 14 - lawn, 1, zshift + 7, lawn + 1, 2, "air")
- fillrectangle(xshift + 14 - lawn, 2, zshift + 7, lawn + 1, 2, "air")
- end
- end
- print("Running command")
- if command == "gen" or command == "generate" then
- if #tArgs == 6 then
- xchunkcounter = 0
- while xchunkcounter < xtotal_chunks * 1 do --A glitchy fix for an error involving comparing string with number
- zchunkcounter = 0
- while zchunkcounter < ztotal_chunks * 1 do --A glitchy fix for an error involving comparing string with number
- commands.getBlockInfo(xchunkcounter * 16 + xstart, ystart * 1, zchunkcounter * 16 + zstart) --Force chunk loading
- zchunkcounter = zchunkcounter + 1
- end
- xchunkcounter = xchunkcounter + 1
- end
- sidewalk_block = sidewalk_blocks[math.random(1, #sidewalk_blocks)]
- xchunkcounter = 0
- while xchunkcounter < xtotal_chunks * 1 do --A glitchy fix for an error involving comparing string with number
- zchunkcounter = 0
- while zchunkcounter < ztotal_chunks * 1 do --A glitchy fix for an error involving comparing string with number
- fillrectangleE(xchunkcounter * 16, 0, zchunkcounter * 16, 16, 16, "grass", sidewalk_block)
- buildskyscraper(xchunkcounter * 16, 0, zchunkcounter * 16, 1, 1, sidewalk_block)
- zchunkcounter = zchunkcounter + 1
- end
- xchunkcounter = xchunkcounter + 1
- end
- else
- print("Invalid arguements")
- end
- elseif command == "reset" then
- if #tArgs == 7 then
- fillrectangle(0, 0, 0, 16 * xtotal_chunks, 16 * ztotal_chunks, block_type)
- elseif #tArgs == 6 then
- fillrectangle(0, 0, 0, 16 * xtotal_chunks, 16 * ztotal_chunks, "grass")
- else
- print("Invalid arguements")
- end
- else
- print("Invalid command")
- end
- blocklog:write("Finished command".."\n\n")
- blocklog:close()
- chunklog:write("Finished command".."\n\n")
- chunklog:close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement