SHOW:
|
|
- or go back to the newest paste.
| 1 | ----------------------------------------------------------------------------- | |
| 2 | -- Name: RCreceive | |
| 3 | - | -- Version: 1.1.2 |
| 3 | + | -- Version: 1.1.3 |
| 4 | -- Author: Dustin Rosebery | |
| 5 | -- Setup: install on a wireless mining turtle. Requires latest version of | |
| 6 | -- RCmaster installed on a computer with a 4x4 advanced monitor | |
| 7 | -- Description: Receiver program that controls turtle movement and sends | |
| 8 | -- inventory information to the master program | |
| 9 | ----------------------------------------------------------------------------- | |
| 10 | ||
| 11 | rednet.open("right")
| |
| 12 | t = turtle | |
| 13 | ||
| 14 | -- checks for empty inventory and returns name and amount of item in slot i | |
| 15 | function checkInventory(i) | |
| 16 | t.select(i) | |
| 17 | data = t.getItemDetail() | |
| 18 | ||
| 19 | if data.count == 0 then | |
| 20 | rednet.broadcast("empty")
| |
| 21 | else | |
| 22 | result = data.name .. " " .. data.count | |
| 23 | rednet.broadcast(result) | |
| 24 | end | |
| 25 | end | |
| 26 | ||
| 27 | -- listens for broadcasts from master | |
| 28 | function listen() | |
| 29 | senderID, message, protocol = rednet.receive() | |
| 30 | write("Received: " .. message .. "\n")
| |
| 31 | ||
| 32 | if message == "forward" then | |
| 33 | t.forward() | |
| 34 | elseif message == "back" then | |
| 35 | t.back() | |
| 36 | elseif message == "left" then | |
| 37 | t.turnLeft() | |
| 38 | elseif message == "right" then | |
| 39 | t.turnRight() | |
| 40 | elseif message == "up" then | |
| 41 | t.up() | |
| 42 | elseif message == "down" then | |
| 43 | t.down() | |
| 44 | - | elseif message >= 1 and message <= 16 |
| 44 | + | elseif message >= 1 and message <= 16 then |
| 45 | checkInventory(message) | |
| 46 | else | |
| 47 | listen() | |
| 48 | end | |
| 49 | end | |
| 50 | ||
| 51 | while(true) do | |
| 52 | listen() | |
| 53 | end |