Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- turtle_client
- rednet.open("back") -- Adjust as needed
- print("Turtle Controller (Pocket Computer)")
- print("Enter turtle ID (or 'scan' to search):")
- local idInput = read()
- local turtleID
- if idInput == "scan" then
- print("Scanning for turtle...")
- local id = rednet.lookup("turtle", nil)
- if id then
- print("Found turtle with ID:", id)
- turtleID = id
- else
- print("No turtles found.")
- return
- end
- else
- turtleID = tonumber(idInput)
- end
- print("Available commands:")
- print("- Movement: forward, back, left, right, up, down (movement amount)")
- print("- dig, place (up/down/forward)")
- print("- select/slot <1-15>")
- print("- exit")
- while true do
- term.write("> ")
- local input = read()
- if input ~= "disconnect" then rednet.send(turtleID, input) end
- if input == "exit" then
- print("Sent shutdown command.")
- break
- end
- if input == "disconnect" then
- print("Disconnecting")
- break
- end
- local sender, response = rednet.receive(2) -- wait up to 2 seconds for reply
- if response then
- print("< " .. response)
- else
- print("< No Response.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment