Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Receiver Program for Quarry Turtle
- -- Usage: startup <monitor_side> <modem_side>
- local args = {...}
- if #args < 2 then
- print("Usage: startup <monitor_side> <modem_side>")
- return
- end
- local monitorSide = args[1]
- local modemSide = args[2]
- local monitor = peripheral.wrap(monitorSide)
- local modem = peripheral.wrap(modemSide)
- if not monitor or not modem then
- print("Error: Make sure you have the monitor and modem correctly connected.")
- return
- end
- rednet.open(modemSide)
- -- Function to handle incoming data
- local function handleData(senderId, message, protocol)
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Data from Turtle ID " .. senderId .. ": " .. message)
- end
- -- Main loop to receive messages
- local function main()
- while true do
- local senderId, message, protocol = rednet.receive()
- handleData(senderId, message, protocol)
- end
- end
- -- Run the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement