Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.find("monitor")
- if not mon then
- print("No monitor found!")
- return
- end
- mon.setTextScale(0.5)
- mon.setBackgroundColor(colors.white)
- mon.clear()
- local w, h = mon.getSize()
- local tiles = {}
- local function initTiles()
- for y = 1, h do
- tiles[y] = {}
- for x = 1, w do
- tiles[y][x] = false
- end
- end
- end
- local function drawTiles()
- for y = 1, h do
- mon.setCursorPos(1, y)
- for x = 1, w do
- if tiles[y][x] then
- mon.setBackgroundColor(colors.gray)
- else
- mon.setBackgroundColor(colors.lightGray)
- end
- mon.write(" ")
- end
- end
- end
- local function carveWave()
- local col = math.random(1, w)
- for row = 1, h do
- tiles[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
- local function fadeTiles()
- for y = 1, h do
- for x = 1, w do
- if math.random(100) < 2 then
- tiles[y][x] = false
- end
- end
- end
- end
- initTiles()
- while true do
- carveWave()
- fadeTiles()
- drawTiles()
- sleep(0.05)
- end
Advertisement
Add Comment
Please, Sign In to add comment