yeeeeeeeeeeeee

nzjslg;u

Nov 5th, 2025
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. term.setBackgroundColor(colors.black)
  2. term.clear()
  3.  
  4. local w, h = term.getSize()
  5. local grid = {}
  6.  
  7. -- initialize grid
  8. for y = 1, h do
  9. grid[y] = {}
  10. for x = 1, w do
  11. grid[y][x] = false -- false = closed ▣, true = open []
  12. end
  13. end
  14.  
  15. local function drawGrid()
  16. for y = 1, h do
  17. term.setCursorPos(1, y)
  18. for x = 1, w do
  19. if grid[y][x] then
  20. term.write("[]") -- open
  21. else
  22. term.write("▣ ") -- closed
  23. end
  24. end
  25. end
  26. end
  27.  
  28. -- carve a random sweeping path
  29. local function carve()
  30. local col = math.random(1, w)
  31. for row = 1, h do
  32. grid[row][col] = true
  33. local r = math.random(3)
  34. if r == 1 and col > 1 then
  35. col = col - 1
  36. elseif r == 3 and col < w then
  37. col = col + 1
  38. end
  39. end
  40. end
  41.  
  42. -- randomly re-close cells
  43. local function fade()
  44. for y = 1, h do
  45. for x = 1, w do
  46. if math.random(120) < 2 then
  47. grid[y][x] = false
  48. end
  49. end
  50. end
  51. end
  52.  
  53. while true do
  54. carve()
  55. fade()
  56. drawGrid()
  57. sleep(0.07)
  58. end
  59.  
Advertisement
Add Comment
Please, Sign In to add comment