Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 and #tArgs ~= 6 then
- print("citygen <Command> <Corner X> <Height> <Corner Z> <Chunks X> <Chunks Y>")
- print("Command can be gen or reset")
- print("The corner is the southwest corner")
- return
- end
- 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 generateGround()
- blockx = 0
- chunkx = 0
- while chunkx*16 + blockx < 16*tArgs[5] do
- blockz = 0
- chunkz = 0
- while chunkz*16 + blockz < 16*tArgs[6] do
- if blockx == 0 or blockz == 0 or blockx == 15 or blockz == 15 then
- csetblock(chunkx*16 + blockx, 0, chunkz*16 + blockz, "stone")
- else
- csetblock(chunkx*16 + blockx, 0, chunkz*16 + blockz, "grass")
- end
- if blockz == 15 then
- chunkz = chunkz + 1
- blockz = 0
- else
- blockz = blockz + 1
- end
- end
- if blockx == 15 then
- chunkx = chunkx + 1
- blockx = 0
- else
- blockx = blockx + 1
- end
- end
- end
- function generateBuildings()
- chunkx = 0
- while chunkx < 1*tArgs[5] do
- chunkz = 0
- while chunkz < 1*tArgs[6] do
- --start of building
- grass = math.random(3) + 1
- start = grass
- length = 16 - grass
- blockx = grass
- while blockx < length do
- blockz = grass
- while blockz < length do
- csetblock(chunkx*16 + blockx, 0, chunkz*16 + blockz, "stone")
- blockz = blockz + 1
- end
- blockx = blockx + 1
- end
- height = math.random(3, 8)
- blocky = 1
- floor = 0
- while floor*4+blocky < height*4+1 do
- blockx = start
- while blockx < length do
- blockz = start
- while blockz < length do
- if blocky == 0 then
- csetblock(chunkx*16 + blockx, floor*4 + blocky, chunkz*16 + blockz, "stone")
- else
- if blockx == grass or blockz == grass or blockx == 15 - grass or blockz == 15 - grass then
- if (blockx == grass or blockx == 15-grass) and (blockz == grass or blockz == 15-grass) then
- csetblock(chunkx*16 + blockx, floor*4 + blocky, chunkz*16 + blockz, "stone")
- else
- csetblock(chunkx*16 + blockx, floor*4 + blocky, chunkz*16 + blockz, "glass")
- end
- else
- csetblock(chunkx*16 + blockx, floor*4 + blocky, chunkz*16 + blockz, "air")
- end
- end
- blockz = blockz + 1
- end
- blockx = blockx + 1
- end
- if blocky == 3 then
- floor = floor + 1
- blocky = 0
- else
- blocky = blocky + 1
- end
- end
- --end of building
- chunkz = chunkz + 1
- end
- chunkx = chunkx + 1
- end
- end
- if tArgs[1] == "gen" then
- print("Ground generating...")
- generateGround()
- print("Ground generated!")
- sleep(2)
- print("Buildings generating...")
- generateBuildings()
- print("Buildings generated!")
- --=============================================================================================
- --Reset code
- elseif tArgs[1] == "build" then
- generateBuildings()
- elseif tArgs[1] == "reset" then
- blocky = 0
- while blocky + tArgs[3] < 255 do
- blockx = 0
- if blocky < 1 then
- while blockx < 16*tArgs[5] do
- blockz = 0
- while blockz < 16*tArgs[6] do
- csetblock(blockx, 0, blockz, "grass")
- blockz = blockz + 1
- end
- blockx = blockx + 1
- end
- else
- while blockx < 16*tArgs[5] do
- blockz = 0
- while blockz < 16*tArgs[6] do
- csetblock(blockx, blocky, blockz, "air")
- blockz = blockz + 1
- end
- blockx = blockx + 1
- end
- end
- blocky = blocky + 1
- end
- else
- print("Error: Invalid Command")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement