Advertisement
yeeeeeeeeeeeee

e

Mar 20th, 2025
174
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.23 KB | None | 0 0
  1. local width, height = 20, 10 -- Size of the drawing grid
  2. local grid = {}
  3. for y = 1, height do
  4.     grid[y] = {}
  5.     for x = 1, width do
  6.         grid[y][x] = " " -- Empty cell
  7.     end
  8. end
  9. local cursorX, cursorY = 1, 1 -- Starting cursor position
  10. local function drawGrid()
  11.     term.clear()
  12.     term.setCursorPos(1, 1)
  13.     for y = 1, height do
  14.         for x = 1, width do
  15.             if x == cursorX and y == cursorY then
  16.                 term.write("X")
  17.             else
  18.                 term.write(grid[y][x])
  19.             end
  20.         end
  21.         print()
  22.     end
  23. end
  24. local function saveArt(filename)
  25.     local file = fs.open(filename, "w")
  26.     for y = 1, height do
  27.         file.writeLine(table.concat(grid[y]))
  28.     end
  29.     file.close()
  30.     print("Drawing saved as " .. filename)
  31. end
  32. local function loadArt(filename)
  33.     if not fs.exists(filename) then
  34.         print("File not found.")
  35.         return
  36.     end
  37.     local file = fs.open(filename, "r")
  38.     for y = 1, height do
  39.         local line = file.readLine()
  40.         for x = 1, #line do
  41.             grid[y][x] = line:sub(x, x)
  42.         end
  43.     end
  44.     file.close()
  45.     print("Drawing loaded!")
  46. end
  47. while true do
  48.     drawGrid()
  49.     print("Controls: WASD to move, Space to draw, C to clear, Save, Load, Exit")
  50.     write("Command: ")
  51.     local input = read()
  52.     if input == "w" and cursorY > 1 then
  53.         cursorY = cursorY - 1
  54.     elseif input == "s" and cursorY < height then
  55.         cursorY = cursorY + 1
  56.     elseif input == "a" and cursorX > 1 then
  57.         cursorX = cursorX - 1
  58.     elseif input == "d" and cursorX < width then
  59.         cursorX = cursorX + 1
  60.     elseif input == " " then
  61.         grid[cursorY][cursorX] = "#"
  62.     elseif input == "c" then
  63.         for y = 1, height do
  64.             for x = 1, width do
  65.                 grid[y][x] = " "
  66.             end
  67.         end
  68.         print("Canvas cleared.")
  69.     elseif input == "save" then
  70.         write("Enter filename: ")
  71.         local filename = read()
  72.         saveArt(filename)
  73.     elseif input == "load" then
  74.         write("Enter filename: ")
  75.         local filename = read()
  76.         loadArt(filename)
  77.     elseif input == "exit" then
  78.         break
  79.     else
  80.         print("Unknown command.")
  81.     end
  82. end
  83.  
Advertisement
Comments
  • responsive02
    15 hours
    # text 1.64 KB | 0 0
    1. https://bigwarp.io/7txvvw88j47z
    2.  
    3. https://bigwarp.io/37cal9qxtkfd
    4.  
    5. https://bigwarp.io/yojwi7en1pvq
    6.  
    7. https://bigwarp.io/qijd9p456n3q
    8.  
    9. https://bigwarp.io/8q8rweiy8jbr
    10.  
    11. https://bigwarp.io/twu7014koab0
    12.  
    13. https://bigwarp.io/a52gx3me2yb6
    14.  
    15. https://bigwarp.io/vbg8tr63zpg7
    16.  
    17. https://bigwarp.io/0buj2xybbiya
    18.  
    19. https://bigwarp.io/bpkjblxxvcne
    20.  
    21. https://bigwarp.io/2uybz9tn4ylx
    22.  
    23. https://bigwarp.io/zgj5po6pvxzi
    24.  
    25. https://bigwarp.io/mku1zg635c3p
    26.  
    27. https://bigwarp.io/ehrx7oehy8dz
    28.  
    29. https://bigwarp.io/sgrz07aqfp65
    30.  
    31. https://bigwarp.io/xrhv7lzwf1lg
    32.  
    33. https://bigwarp.io/lng31yy8nn5t
    34.  
    35. https://bigwarp.io/1m2pzph656py
    36.  
    37. https://bigwarp.io/qigrntkn99pb
    38.  
    39. https://bigwarp.io/8zndb2n6jiwy
    40.  
    41. https://bigwarp.io/8ekzkk952yu3
    42.  
    43. https://bigwarp.io/1u99fslfyel0
    44.  
    45. https://bigwarp.io/n6cq48ytrt2i
    46.  
    47. https://bigwarp.io/u1id0cxubkyb
    48.  
    49. https://bigwarp.io/256mpeyeztk7
    50.  
    51. https://bigwarp.io/4tj0wc77cwa6
    52.  
    53. https://bigwarp.io/smia0be9sl37
    54.  
    55. https://bigwarp.io/4ewhxoikf7h5
    56.  
    57. https://bigwarp.io/2in30egwonhl
    58.  
    59. https://bigwarp.io/tqy9xpjngixh
    60.  
    61. https://bigwarp.io/h9xehnci6u8h
    62.  
    63. https://bigwarp.io/qwpzfxbpgu4g
    64.  
    65. https://bigwarp.io/l3cf70paqezn
    66.  
    67. https://bigwarp.io/d0t4fi81l11u
    68.  
    69. https://bigwarp.io/0gzjnnvnrtu3
    70.  
    71. https://bigwarp.io/aak8g4hw082r
    72.  
    73. https://bigwarp.io/if31zbaew096
    74.  
    75. https://bigwarp.io/afpl9j47wc3p
    76.  
    77. https://bigwarp.io/fphgzk153qxu
    78.  
    79. https://bigwarp.io/c16cno5bjc4e
    80.  
    81. https://bigwarp.io/x6xtle3ba6u0
    82.  
    83. https://bigwarp.io/aav4uxfa6vy4
    84.  
    85. https://bigwarp.io/rxzo4cgcquty
    86.  
    87. https://bigwarp.io/tga6z9h6iblh
    88.  
    89. https://bigwarp.io/mux73oomlrk4
    90.  
    91. https://bigwarp.io/ojso2y0iiqla
    92.  
    93. https://bigwarp.io/r2x3ww3buw4q
    94.  
    95. https://bigwarp.io/43a823em4m6g
    96.  
Add Comment
Please, Sign In to add comment
Advertisement