Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.setBackgroundColor(colors.black)
- term.clear()
- local w, h = term.getSize()
- local grid = {}
- -- initialize grid
- for y = 1, h do
- grid[y] = {}
- for x = 1, w do
- grid[y][x] = false -- false = closed O, true = open o
- end
- end
- local function drawGrid()
- for y = 1, h do
- term.setCursorPos(1, y)
- for x = 1, w do
- if grid[y][x] then
- term.write("o")
- else
- term.write("O")
- end
- end
- end
- end
- -- carve a random wiggly path
- local function carve()
- local col = math.random(1, w)
- for row = 1, h do
- grid[row][col] = true
- local r = math.random(3)
- if r == 1 and col > 1 then
- col = col - 1
- elseif r == 3 and col < w then
- col = col + 1
- end
- end
- end
- -- slowly close cells again
- local function fade()
- for y = 1, h do
- for x = 1, w do
- if math.random(140) < 2 then
- grid[y][x] = false
- end
- end
- end
- end
- while true do
- carve()
- fade()
- drawGrid()
- sleep(0.07)
- end
Advertisement
Add Comment
Please, Sign In to add comment