Advertisement
Satscape

ComputerCraft script for Log making machine (tree farm)

Sep 21st, 2012
657
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.71 KB | None | 0 0
  1. -- Log making machine CC script by Scott Hather (Satscape)
  2. -- Obviously you need to build the machine and wire it up the
  3. -- same as mine, otherwise this program won't work, I've shared it
  4. -- simply as an example of how to use CC to control RP2 machines.
  5. -- See my video tutorials on youtube.com/SatscapeMinecraft
  6.  
  7. -- 1=sapling (white)  2=bonemeal (orange)  4=igniter (magenta)
  8. -- 8=sand deploy (L blue)  16=break tree (yellow)
  9. -- 32=empty chest(lime)   64=piston (pink)
  10.  
  11. -- we send signals down the bundled cable a lot, so
  12. -- here's a helper function
  13. function send(bin, delay)
  14. rs.setBundledOutput("back",bin) --cable is on the back of computer
  15. os.sleep(delay)
  16. rs.setBundledOutput("back",0)
  17. os.sleep(delay)
  18. end
  19.  
  20. --another helper to display what's happening
  21. function status(t)
  22. term.clear()
  23. term.setCursorPos(3,3)
  24. term.write(t)
  25. end
  26.  
  27. -- the big infinite loop (control t to exit)
  28. while true do
  29.  
  30. status("Planting tree")
  31. send(1,0.5) -- plant sapling
  32. send(2,0.5) -- apply bonemeal
  33.  
  34. status("Harvesting tree")
  35. for x=1,9 do
  36. send(16,0.5) -- break bottom of tree
  37. send(8,0.5) -- deploy sand
  38. send(64,0.5) -- push down sand with piston
  39. end
  40.  
  41. status("Cleaning up")
  42. for x=1,10 do
  43. send(16,0.5)   -- clear away remaining sand
  44. end
  45.  
  46. status("Dispatching logs")
  47. for x=1,30 do
  48. send(32,0.1) -- empty chest of logs and sand
  49. end
  50.  
  51. status("Burning leafs")
  52. rs.setBundledOutput("back",4) -- ignite the leafs
  53. os.sleep(40)
  54. send(0,1.0)
  55. status("Resetting")
  56. os.sleep(40)
  57.  
  58. -- ask the turtle to tidy up the saplings (see turtleTidy script)
  59. status("Turtle tidying")
  60. rednet.open("left")
  61. os.sleep(1)
  62. rednet.broadcast("turtle tidy")
  63. os.sleep(1)
  64. rednet.close("left")
  65. os.sleep(10) --give the turtle enough time to tidy up
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement