Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Load the Rednet API
- rednet.open("back")
- print("Enter the ID of the turtle:")
- local turtle_id = tonumber(read())
- print("Enter the size of the excavation area:")
- local size = tonumber(read())
- -- Sending the excavate command to the specified turtle
- rednet.send(turtle_id, "excavate " .. size)
- print("Excavation command sent to turtle " .. turtle_id .. " for a size of " .. size)
- -- Function to receive messages from the turtle
- function receiveMessages()
- while true do
- local id, message = rednet.receive()
- if id == turtle_id then
- print("Turtle " .. id .. ": " .. message)
- end
- end
- end
- -- Run the receiveMessages function in parallel
- parallel.waitForAny(receiveMessages, function()
- print("Press any key to stop receiving messages.")
- os.pullEvent("key") -- Wait for a key press
- error("Stopped by user") -- Force the parallel loop to terminate
- end)
- -- Close the Rednet API
- rednet.close("back")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement