Advertisement
GauHelldragon

TreeSorter2 v0.1

May 1st, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input, unsort = colors.white, colors.black
  2.  
  3.  
  4. analyzer = peripheral.wrap("top")
  5.  
  6. function sendPulse(color)
  7.   local startColor = rs.getBundledOutput("back")
  8.   rs.setBundledOutput("back",color+startColor)
  9.   os.sleep(0.25)
  10.   rs.setBundledOutput("back",startColor)
  11. end
  12.  
  13. function setColor(color)
  14.   rs.setBundledOutput("back",color)
  15. end
  16.  
  17. function readySapling()
  18.   while ( not analyzer.isTree() ) do
  19.     sendPulse(input)
  20.     os.sleep(5)
  21.   end
  22. end
  23.  
  24.  
  25. function processSapling()
  26.   if ( not analyzer.isTree() ) then return end
  27.  
  28.   local treeData = analyzer.analyze()
  29.   local species = treeData["speciesPrimary"]
  30.  
  31.   if      ( species == "Hill Cherry" ) then setColor(colors.cyan)
  32.   else if ( species == "Silver Lime" ) then setColor(colors.orange)
  33.   else setColor(unsort) end
  34.  
  35. end
  36.  
  37. while true do
  38.   readySapling()
  39.   processSapling()
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement