Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- shell.run("clear")
- term.setTextColor(colors.blue)
- print("Type in a command you want to run or type 'help' for a list of commands.")
- function prefix(write)
- term.setTextColor(colors.yellow)
- term.write(write)
- term.setTextColor(colors.white)
- end
- while true do
- prefix(": ")
- input = read()
- if input == "help" then
- term.setTextColor(colors.lightBlue)
- print("list - will list available turtles to connect with")
- term.setTextColor(colors.blue)
- print("connect - will connect to a turtle")
- term.setTextColor(colors.lightBlue)
- print("exit - will exit the program")
- elseif input == "exit" then
- shell.run("clear")
- break
- elseif input == "list" then
- rednet.broadcast("list")
- term.setTextColor(colors.blue)
- print("id: description")
- while true do
- sendID, msg = rednet.receive(1)
- if sendID == nil then break end
- term.setTextColor(colors.lightBlue)
- print(sendID .. ": " .. msg)
- end
- elseif input == "connect" then
- term.setTextColor(colors.blue)
- print("type in the id of the turtle you want to connect with")
- prefix(": ")
- turtleID = read()
- if not tonumber(turtleID) then
- term.setTextColor(colors.lightBlue)
- print("make sure not to use letters!")
- else
- turtleID = tonumber(turtleID)
- rednet.send(turtleID, "connect")
- connectID, msg = rednet.receive(1)
- if connectID == nil then
- term.setTextColor(colors.lightBlue)
- print("invalid ID")
- else
- term.setTextColor(colors.green)
- print(msg)
- while true do
- prefix(connectID .. ": ")
- command = read()
- commandTable = {}
- for word in command:gmatch("%S+") do
- table.insert(commandTable, word)
- end
- if commandTable[1] == "exit" then
- rednet.send(connectID, "exit")
- break
- else
- rednet.send(connectID, commandTable)
- ID, message = rednet.receive(1)
- term.setTextColor(colors.green)
- print(message)
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment