-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoutput.lua
More file actions
36 lines (27 loc) · 818 Bytes
/
output.lua
File metadata and controls
36 lines (27 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- output.lua
local M = {} -- Create a table to hold the functions
function M.displayMessagesOnMonitor()
rednet.open("bottom")
local monitor = peripheral.find("monitor")
if not monitor then
print("Monitor not found.")
return
end
monitor.clear()
monitor.setCursorPos(1, 1)
while true do
local senderID, message = rednet.receive()
monitor.clear()
monitor.setCursorPos(1, 1)
local lines = {}
for line in message:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
for _, line in ipairs(lines) do
monitor.write(line)
monitor.setCursorPos(1, select(2, monitor.getCursorPos()) + 1)
end
end
rednet.close("bottom")
end
return M