Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------------------------------
- -- Name: RCreceive
- -- Version: 1.1.4
- -- Author: Dustin Rosebery
- -- Setup: install on a wireless mining turtle. Requires latest version of
- -- RCmaster installed on a computer with a 4x4 advanced monitor
- -- Description: Receiver program that controls turtle movement and sends
- -- inventory information to the master program
- -----------------------------------------------------------------------------
- rednet.open("left")
- t = turtle
- -- checks for empty inventory and returns name and amount of item in slot i
- function checkInventory(i)
- t.select(i)
- amount = t.getItemCount()
- data = t.getItemDetail()
- sleepTime = 0
- os.sleep(sleepTime)
- if amount == 0 then
- rednet.broadcast("empty")
- else
- rednet.broadcast(data.name)
- rednet.broadcast(data.count)
- end
- listen()
- end
- -- listens for broadcasts from master
- function listen()
- senderID, message, protocol = rednet.receive()
- write("Received: " .. message .. "\n")
- if message == "forward" then
- t.forward()
- elseif message == "back" then
- t.back()
- elseif message == "left" then
- t.turnLeft()
- elseif message == "right" then
- t.turnRight()
- elseif message == "up" then
- t.up()
- elseif message == "down" then
- t.down()
- elseif message == "place" then
- t.place()
- sID, i, proto = rednet.receive()
- checkInventory(i)
- elseif message == "dig" then
- t.dig()
- elseif message >= 1 and message <= 16 then
- checkInventory(message)
- else
- listen()
- end
- end
- while(true) do
- listen()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement