Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- old = {}
- old.execAsync = commands.execAsync
- dangerousAmountOfQueries = 700 -- blocks
- restingTime = 0.1 -- seconds
- sandstone = "minecraft:sandstone"
- stone = "minecraft:stone"
- air = "minecraft:air"
- glass = "minecraft:stained_glass"
- wood = "minecraft:planks"
- x="x"
- y="y"
- z="z"
- function isTrue(number)
- if number == 0 then
- return false
- else
- return true
- end
- end
- function round(num, idp)
- local mult = 10^(idp or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- math.round = round
- function console(txt,line)
- if true then
- if line == nil then
- line = 1
- end
- term.setCursorPos(1,line)
- term.clearLine(line)
- term.write(txt)
- term.setCursorPos(1,line+1)
- end
- end
- function deltaT(timerID)
- if type(lastCallFromTheID) ~= "table" then
- lastCallFromTheID = {}
- end
- if lastCallFromTheID[timerID] == nil then
- lastCallFromTheID[timerID] = os.clock()
- end
- temp = os.clock()-lastCallFromTheID[timerID]
- lastCallFromTheID[timerID] = os.clock()
- return temp
- end
- function execAsync(str)
- if execAsyncQueries == nil then
- execAsyncQueries = 0
- end
- timeDiff2 = deltaT("execAsync")
- if timeDiff2 > restingTime then
- execAsyncQueries = 0 --Blast of queries was cut off. I consider this one a new one.
- else
- execAsyncQueries = execAsyncQueries+1
- end
- -- console(execAsyncQueries, 7)
- if execAsyncQueries > dangerousAmountOfQueries then
- sleep(restingTime)
- execAsyncQueries = 0 --just to be sure, manually consider the blast as done and down
- end
- return old.execAsync(str)
- end
- commands.execAsync = execAsync
- function setBlock(block,xa,ya,za,dataValue,oldBlockHandling)
- if type(dataValue) ~= "string" then
- dataValue = ""
- end
- if type(oldBlockHandling) ~= "string" then
- oldBlockHandling = ""
- end
- -- print("setblock ~" .. tostring(xa) .. " ~" .. tostring(za) .. " ~".. tostring(ya) .. " " .. tostring(block) .. " " .. tostring(dataValue) .. " " .. tostring(oldBlockHandling))
- commands.execAsync("setblock ~" .. tostring(xa) .. " ~" .. tostring(za) .. " ~".. tostring(ya) .. " " .. tostring(block) .. " " .. tostring(dataValue) .. " " .. tostring(oldBlockHandling))
- end
- function fill(block, xa, ya, za, width, length, height)
- queries = 0
- for i=xa,xa+width-1 do
- for j=ya,ya+length-1 do
- for k=za,za+height-1 do
- setBlock(block, i, j, k)
- queries = queries+1
- end
- end
- end
- return queries
- end
- function fillNicely(block, xa, ya, za, width, length, height)
- queries = fill(block, xa, ya, za, width, length, height)
- queries = queries + fill(glass, xa+1, ya+1, za, width-2, length-2, height)
- return queries
- end
- function floor(block, xa, ya, za, width, length)
- return fill(block, xa, ya, za, width, length, 1)
- end
- function walls(block, xa, ya, za, width, length, height)
- queries = fill(block, xa, ya, za, width, length, height)
- queries = queries + fill(air, xa+1, ya+1, za, width-2, length-2, height)
- return queries
- end
- function room(blockFloor, blockWalls, xa, ya, za, width, length, height)
- fill(air, xa, ya, za, width, length, height)
- floor(blockFloor, xa, ya, za, width, length)
- walls(blockWalls, xa, ya, za+1, width, length, height-2)
- floor(blockFloor, xa, ya, za+height-1, width, length)
- end
- function forEachColumnOfAWallDoMyFunc(yourFunc, xa, ya, width, length)
- column = 1
- for i=xa,width+2 do
- yourFunc(i, ya, column, true)
- yourFunc(i, ya+length-1, column, true)
- -- sleep(1)
- column = column+1
- end
- column = 1
- glass = "minecraft:glass"
- for i=ya,length+2 do
- yourFunc(xa, i, column, false)
- yourFunc(xa+width-1, i, column, false)
- -- sleep(1)
- column = column+1
- end
- end
- function roomWithWindows(blockFloor, blockWalls, xa, ya, za, width, length, height, numberOfWindowsFront, numberOfWindowsSide)
- room(blockFloor, blockWalls, xa, ya, za, width, length, height)
- if numberOfWindowsFront == nil then
- numberOfWindowsFront = math.floor(math.sqrt(width))
- print(numberOfWindowsFront)
- end
- if numberOfWindowsSide == nil then
- numberOfWindowsSide = math.floor(math.sqrt(length))
- print(numberOfWindowsSide)
- end
- frontWindowsLength = math.floor((width-numberOfWindowsFront-1)/numberOfWindowsFront)
- frontMiddleWindowLength = width-(numberOfWindowsFront+1)-((numberOfWindowsFront-1)*frontWindowsLength)
- frontMiddleWindow = math.ceil(numberOfWindowsFront/2)
- frontMiddleWindowPosition = frontMiddleWindow + (frontMiddleWindow-1)*frontWindowsLength
- sideWindowsLength = math.floor((length-numberOfWindowsSide-1)/numberOfWindowsSide)
- sideMiddleWindowLength = length-(numberOfWindowsSide+1)-((numberOfWindowsSide-1)*sideWindowsLength)
- sideMiddleWindow = math.ceil(numberOfWindowsSide/2)
- sideMiddleWindowPosition = sideMiddleWindow + (sideMiddleWindow-1)*sideWindowsLength
- -- Maintenant on a les dimensions des fenêtres. Longueurs. Positions. Tout.
- -- L'idée est de parcourir le contour du mur et de dessiner les fenêtres.
- validColumns = {}
- validColumns.front = {}
- validColumns.side = {}
- -- Murs de face et arrière
- for i=1,width do --tout en verre
- validColumns.front[i] = true
- end
- validColumns.front[1] = false --sauf le début
- validColumns.front[width] = false --et la fin
- i=1
- while i < width/2 do --puis on fait vitre après vitre depuis le début jusqu'au milieu
- validColumns.front[i] = false
- i=i+frontWindowsLength+1
- end
- i=width
- while i > width/2 do --puis de la fin jusqu'au milieu
- validColumns.front[i] = false
- i=i-frontWindowsLength-1
- end
- for i=frontMiddleWindowPosition+1,frontMiddleWindowPosition+frontMiddleWindowLength do
- validColumns.front[i] = true
- end
- -- Murs de face et arrière
- -- for i=1,width do
- -- validColumns.front[i] = true
- -- end
- -- validColumns.front[1] = false
- -- validColumns.front[width] = false
- -- i=1
- -- while i<frontMiddleWindowPosition do
- -- validColumns.front[i] = false
- -- i=i+frontWindowsLength+1
- -- end
- -- i=frontMiddleWindowPosition
- -- validColumns.front[i] = false
- -- i=frontMiddleWindowPosition+frontMiddleWindowLength+1
- -- while i<=width do
- -- validColumns.front[i] = false
- -- i=i+frontWindowsLength+1
- -- end
- -- Murs des côtés
- for i=1,length do --tout en verre
- validColumns.side[i] = true
- end
- validColumns.side[1] = false --sauf le début
- validColumns.side[length] = false --et la fin
- i=1
- while i < length/2 do --puis on fait vitre après vitre depuis le début jusqu'au milieu
- validColumns.side[i] = false
- i=i+sideWindowsLength+1
- end
- i=length
- while i > length/2 do --puis de la fin jusqu'au milieu
- validColumns.side[i] = false
- i=i-sideWindowsLength-1
- end
- center = (length/2)
- otherCenter = math.ceil(sideMiddleWindowPosition+(sideMiddleWindowLength/2))
- -- for i=sideMiddleWindowPosition+1,sideMiddleWindowPosition+sideMiddleWindowLength do
- -- validColumns.side[i] = true
- -- end
- function myFunc(xa,ya,column,isFront)
- if isFront == true then
- if validColumns.front[column] == true then
- fill(glass, xa, ya, za+1, 1, 1, height-2) --glassify column
- end
- else --if isSide
- if validColumns.side[column] == true then
- fill(glass, xa, ya, za+1, 1, 1, height-2) --glassify column
- end
- end
- end
- forEachColumnOfAWallDoMyFunc(myFunc, xa, ya, width, length)
- end
- if false then
- fill(air,3,3,3,20,20,20)
- roomWithWindows(wood, stone, 3,3,3, 9,15,5,4,4)
- else
- while true do
- fill(air,3,3,3,20,20,20)
- roomWithWindows(wood, stone, 3,3,3, math.random(4,20),math.random(4,20),5,math.random(1,7),math.random(1,7))
- sleep(2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement