Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ###########
- Turtle: (put this as a separate program for easiness of use, just put the move commands before the rednet command)
- ###########
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- rednet.open("right")
- local serverId = 3 -- Change to your server ID --
- -- Do not change anything below this point --
- local name = os.getComputerLabel()
- local done = false
- local myId = os.computerID()
- while done == false do
- rednet.send(serverId,name)
- senderId,message,distance = rednet.receive(5)
- if senderId == serverId then
- if message == "Valid" then
- print("Accepted")
- rednet.close("right")
- shell.run ("shutdown")
- else
- print("ID / Name Mismatch")
- shell.run ("shutdown")
- end
- end
- end
- ##############
- Computer:
- ##############
- local myid = os.computerID()
- local turtlelist = { 0, 5, 6 } -- Enter the ID of all your Mining Turtles Here --
- local turtlename = { "DIGGE01", "DIGGE02", "DIGGE03" } -- Enter the Name/ Label you have given your turtle here --
- mon=peripheral.wrap("left")
- print("Turtle Monitor Terminal")
- rednet.open("top") -- Edit to what ever side you modem is on --
- print("Computer id for Monitor Terminal is "..tostring(myid))
- function findIndexForId(id)
- for i,v in ipairs(turtlelist) do
- if id == v then
- return i
- end
- end
- return 0
- end
- function checkTurtleForName(id,tlabel)
- local i = findIndexForId(id)
- if i == 0 then
- return -1
- end
- if turtlename == tlabel then
- return 1
- else
- return 0
- end
- end
- local isValid = 0
- while true do
- local timeString = textutils.formatTime(os.time(),false)
- senderId, message, distance = rednet.receive()
- isValid = checkTurtleForName(senderId, message)
- if isValid == -1 then
- print("A Turtle"..senderId.." sent us a request but is not in our list")
- elseif isValid == 1 then
- rednet.send(senderId, "Valid")
- mon.scroll(1)
- mon.setCursorPos(1,5)
- mon.write("Mining Complete: "..senderId.." "..message.." at "..timeString)
- else
- rednet.send(senderId, "Not Valid")
- mon.scroll(1)
- mon.setCursorPos(1,5)
- mon.write("Error from "..senderId.." "..message.." at "..timeString)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement