Advertisement
GauHelldragon

TreeSorter v0.2

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