Advertisement
Clorith

Untitled

Mar 16th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 KB | None | 0 0
  1. -- Make sure this is an accurate number
  2. local enderChest = peripheral.wrap( "right" )
  3. local localChest = peripheral.wrap( "bottom" )
  4. local rsLocation = "top"
  5.  
  6. -- Check for items in our "Ender Controller"
  7. -- If items are found, the system is active
  8. function checkState()
  9.     enderChest.condenseItems()
  10.     if enderChest.getStackInSlot(1) ~= NIL then
  11.         return true
  12.     else
  13.         return false
  14.     end
  15. end
  16.  
  17. -- Check the status of the chest under us, is it full, empty, what?
  18. function checkDig()
  19.     local itemFound = false
  20.  
  21.     -- Loop over every inventory slot
  22.     for i = 1, localChest.getInventorySize() do
  23.         -- If an item is found in a slot, it won't be NIL (empty/NULL)
  24.         -- As that is the case, set item found to be true
  25.         if localChest.getStackInSlot(i) ~= NIL then
  26.             itemFound = true
  27.         end
  28.     end
  29.  
  30.     return itemFound
  31. end
  32.  
  33. -- Move chunk loaders and primary rig unit
  34. function moveSingle()
  35.     rs.setBundledOutput( rsLocation, colors.white )
  36.     sleep( 1 )
  37.     rs.setBundledOutput( rsLocation, 0 )
  38. end
  39.  
  40. -- Move Everythign except primary rig unit and backup chunk loaders
  41. function moveAll()
  42.     rs.setBundledOutput( rsLocation, colors.orange )
  43.     sleep( 1 )
  44.     rs.setBundledOutput( rsLocation, 0 )
  45. end
  46.  
  47. -- Check if we're enabled or not, if not wait 5 seconds then try again
  48. while not checkState() do
  49.     sleep( 5 )
  50. end
  51.  
  52. print( 'Moving controller and single chunk loader' )
  53. moveSingle()
  54.  
  55. -- Wait a little bit so everything moves into place
  56. sleep( 15 )
  57.  
  58. while checkDig() do
  59.     sleep( 5 )
  60. end
  61.  
  62. -- Turtles done, move the rig!
  63. print( 'Moving the entire rig' )
  64. moveAll()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement