Advertisement
acool

Untitled

Jul 30th, 2023 (edited)
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.58 KB | None | 0 0
  1. --pastebin run qm2QnS6y
  2. local currentY = 1
  3. local modem = peripheral.find("modem") or error("No modem attached", 0)
  4. local IP = math.random(1, 10)
  5. local monitor = peripheral.find("monitor")
  6. local printer = peripheral.find("printer")
  7. monitor.setCursorBlink(true)
  8.  
  9. printer.newPage()
  10. modem.open(IP) -- Open 43 so we can receive replies
  11. monitor.setCursorPos(1, 1)
  12.  
  13. monitor.clear()
  14. print("success!")
  15. print(IP)
  16. monitor.write("IP: " ..IP)
  17.  
  18. -- Initialize an empty table to store the letters
  19. local letterList = {}
  20.  
  21. -- Function to add a letter to the list
  22. function addLetter(letter)
  23.     table.insert(letterList, letter)
  24. end
  25.  
  26. -- Function to concatenate the letters into a single string
  27. function concatenateLetters()
  28.     return table.concat(letterList)
  29. end
  30.  
  31. -- Example usage:
  32.  
  33. -- Concatenate the letters and print the result
  34. local result = concatenateLetters()
  35.  
  36. local function giggity()
  37.  
  38. print("changing lines")
  39. local ball = currentY + 1
  40. currentY = currentY + 1
  41. monitor.setCursorPos(1, ball)
  42. end
  43. while true do
  44.  local event, key, is_held = os.pullEvent("key")
  45. print(("%s held=%s"):format(keys.getName(key), is_held))
  46. monitor.write(keys.getName(key))
  47. addLetter(keys.getName(key))
  48.  
  49. print("balls")
  50. print(monitor.getCursorPos(x))
  51. print(monitor.getCursorPos(y))
  52.  
  53. local event, ga = os.pullEvent("key_up")
  54. if ga == keys.x then
  55. giggity()
  56. end
  57. if key == keys.z then
  58. monitor.clear()
  59.  
  60. local result = concatenateLetters()
  61. print(result)
  62. printer.write(result)
  63. printer.endPage()
  64. printer.newPage()
  65. modem.transmit(IP, IP, result)
  66. monitor.setCursorPos(1, 1)
  67. currentY = 1
  68. end
  69.  
  70. end
  71.  
  72.  
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement