Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RCslave()
- while true do
- local scrap, message = rednet.receive()
- if scrap == cid then
- if message == "TS Forward" then
- print("Forward")
- if turtle.detect() == true then
- turtle.dig()
- end
- turtle.forward()
- elseif message == "TS Backward" then
- print("Backward")
- turtle.back()
- elseif message == "TS TurnLeft" then
- print("Turn Left")
- turtle.turnLeft()
- elseif message == "TS TurnRight" then
- print("Turn Right")
- turtle.turnRight()
- elseif message == "TS PlaceBlock" then
- if turtle.detect() == true then
- print("Block Present")
- else
- print("Place Block")
- turtle.place()
- end
- elseif message == "TS Up" then
- print("Up")
- if turtle.detectUp() == true then
- turtle.digUp()
- end
- turtle.up()
- elseif message == "TS Down" then
- print("Down")
- if turtle.detectDown() == true then
- turtle.digDown()
- end
- turtle.down()
- elseif message == "TS PlaceBlockUp" then
- if turtle.detect() == true then
- print("Block Present")
- else
- print("Place Block Up")
- end
- turtle.placeUp()
- elseif message == "TS PlaceBlockDown" then
- if turtle.detect() == true then
- print("Block Present")
- else
- print("Place Block Down")
- end
- turtle.placeDown()
- elseif message == "TS NextSlot" then
- local scrap, message = rednet.receive()
- s = tonumber(message)
- print("Now using slot " ..s)
- turtle.select(s)
- elseif message == "TS PreviousSlot" then
- local scrap, message = rednet.receive()
- s = tonumber(message)
- print("Now using slot " ..s)
- turtle.select(s)
- elseif message == "TS Redstone" then
- rs.setOutput("front", true)
- rs.setOutput("top", true)
- rs.setOutput("bottom", true)
- rs.setOutput("right", true)
- rs.setOutput("left", true)
- rs.setOutput("back", true)
- sleep(.1)
- rs.setOutput("front", false)
- rs.setOutput("top", false)
- rs.setOutput("bottom", false)
- rs.setOutput("right", false)
- rs.setOutput("left", false)
- rs.setOutput("back", false)
- print("Redstone")
- elseif message == "TS Refuel" then
- print("Refuelling")
- rfs=1
- turtle.select(rfs)
- while true do
- turtle.refuel()
- if turtle.getItemCount(rfs)==0 then
- rfs=rfs+1
- turtle.select(rfs)
- if turtle.getItemCount(tonumber(rfs)) < 1 then
- rfs=s
- turtle.select(s)
- break
- end
- end
- end
- elseif message == "TS Attack" then
- print("Attack")
- turtle.attack()
- turtle.attackUp()
- turtle.attackDown()
- elseif message == "TS Mine" then
- print("Mine")
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- elseif message == "TS Program" then
- local scrap, message = rednet.receive()
- program = message
- print("Running "..program)
- shell.run(program)
- elseif message == "TS GetPos" then
- local x, y, z = gps.locate(1)
- sleep(.1)
- if x ~= nil then
- rednet.send(cid, "X: "..tostring(x)..", Y: "..tostring(y)..", Z:"..tostring(z))
- else
- rednet.send(cid, "Unable to reach cluster")
- end
- elseif message == "TS GetFuel" then
- local fuel = turtle.getFuelLevel()
- sleep(.1)
- if fuel ~= nil then
- rednet.send(cid, tostring(fuel))
- else
- rednet.send(cid, "Unable to get fuel level")
- end
- end
- end
- end
- end
- function startup()
- s=1
- turtle.select(s)
- term.clear()
- term.setCursorPos(1,1)
- rednet.open("right")
- textutils.slowPrint("TurtleReceive V "..version.." Initiated.")
- sleep(2)
- print("What is my controler's ID?")
- cid = tonumber(read())
- term.clear()
- term.setCursorPos(1,1)
- print("TurtleReceive V "..version.." Initiated.")
- print("My ID is: "..os.getComputerID())
- RCslave()
- end
- version=1.0
- startup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement