Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pastebin run qm2QnS6y
- local currentY = 1
- local modem = peripheral.find("modem") or error("No modem attached", 0)
- local IP = math.random(1, 10)
- local monitor = peripheral.find("monitor")
- local printer = peripheral.find("printer")
- monitor.setCursorBlink(true)
- printer.newPage()
- modem.open(IP) -- Open 43 so we can receive replies
- monitor.setCursorPos(1, 1)
- monitor.clear()
- print("success!")
- print(IP)
- monitor.write("IP: " ..IP)
- -- Initialize an empty table to store the letters
- local letterList = {}
- -- Function to add a letter to the list
- function addLetter(letter)
- table.insert(letterList, letter)
- end
- -- Function to concatenate the letters into a single string
- function concatenateLetters()
- return table.concat(letterList)
- end
- -- Example usage:
- -- Concatenate the letters and print the result
- local result = concatenateLetters()
- local function giggity()
- print("changing lines")
- local ball = currentY + 1
- currentY = currentY + 1
- monitor.setCursorPos(1, ball)
- end
- while true do
- local event, key, is_held = os.pullEvent("key")
- print(("%s held=%s"):format(keys.getName(key), is_held))
- monitor.write(keys.getName(key))
- addLetter(keys.getName(key))
- print("balls")
- print(monitor.getCursorPos(x))
- print(monitor.getCursorPos(y))
- local event, ga = os.pullEvent("key_up")
- if ga == keys.x then
- giggity()
- end
- if key == keys.z then
- monitor.clear()
- local result = concatenateLetters()
- print(result)
- printer.write(result)
- printer.endPage()
- printer.newPage()
- modem.transmit(IP, IP, result)
- monitor.setCursorPos(1, 1)
- currentY = 1
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement