Advertisement
Guest User

farmcontrol

a guest
Feb 24th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.87 KB | None | 0 0
  1. --Farm Control
  2.  
  3. --Vars
  4. pipe = peripheral.wrap("back")
  5. mon = peripheral.wrap("right")
  6. farmSize = 80
  7. essMin = 10
  8. essMax = 200000
  9.  
  10. --Table/Arrays
  11. local itemMap = {
  12. [1] = {"Air Shard",8535,8536},
  13. [2] = {"Blaze",8457,8419},
  14. [3] = {"Certus Quartz",8481,8482},
  15. [4] = {"Chicken",8465,8427},
  16. [5] = {"Dye",8441,8402},
  17. [6] = {"Emerald",8456,8418},
  18. [7] = {"Enderium",8515,8516},
  19. [8] = {"Enderman",8459,8421},
  20. [9] = {"Fluix",8517,8518},
  21. [10] = {"Ghast",8460,8422},
  22. [11] = {"Gold",8451,8413},
  23. [12] = {"Manasteel",8523,8524},
  24. [13] = {"Platinum",8495,8496},
  25. [14] = {"Quartz",8454,8416},
  26. [15] = {"Spider",8463,8425},
  27. [16] = {"Wither",8464,8426},
  28. [17] = {"Terrasteel",8533,8534},
  29. [18] = {"Diamond",8455,8417},
  30. [19] = {"Cow",8466,8428},
  31. [20] = {"Wheat",296,295},
  32. [21] = {"Minico",8433,8405},
  33. [22] = {"Redstone",8446,8408},
  34. [23] = {"Glowstone",8447,8409},
  35. [24] = {"Iron",8450,8412},
  36. [25] = {"Skeleton",8461,8423},
  37. [26] = {"Nature",8444,8406},
  38. [27] = {"Creeper",8458,8420},
  39. [28] = {"Lapis",8452,8414},
  40. [29] = {"Nether",8449,8411},
  41. [30] = {"Earth",8442,8403},
  42. [31] = {"Water",8445,8407},
  43. [32] = {"Steel",8531,8532},
  44. [33] = {"Copper",8479,8480}
  45. }
  46.  
  47. --Functions
  48.  
  49. function redOn()
  50. --turns on the redstone signal
  51.   redstone.setOutput("bottom",true)
  52. end
  53.  
  54. function redOff()
  55. --turns off the redstone signal
  56.   redstone.setOutput("bottom",false)
  57. end
  58.  
  59. function redTog(time)
  60. --turns on the redstone signal for var time in
  61. --seconds
  62. redOn()
  63. sleep(time)
  64. redOff()
  65. end
  66.  
  67. function callItem(ident,amt)
  68. --calls the item with id ident and from the ME system
  69. --the number of items called is amt
  70.   lp = pipe.getLP()
  71.   builder = lp.getItemIdentifierBuilder()
  72.   builder.setItemID(ident)
  73.   item = builder.build()
  74.   pipe.makeRequest(item,amt)
  75. end
  76.  
  77. function quaryAmt(ident)
  78.   lp = pipe.getLP()
  79.   builder = lp.getItemIdentifierBuilder()
  80.   builder.setItemID(ident)
  81.   item = builder.build()
  82.   itemAmt = pipe.getItemAmount(item)
  83. --  print(itemAmt)
  84. end
  85.  
  86. function amtLoop(time)
  87.   a = itemMap
  88.   for i = 1, #itemMap do
  89. --  print(tostring(a[i][2]))
  90.     quaryAmt(a[i][2])
  91.       if itemAmt < essMax then
  92.         print("Planting "..a[i][1].."seeds")
  93.         quaryAmt(a[i][3])
  94.         amt = itemAmt
  95.           if amt > farmSize then
  96.             amt = farmSize
  97.             print("To Many Seeds... Planting: "..amt)
  98.           else
  99.             print("Not Enough Seeds... Planting: "..amt)
  100.           end
  101.         callItem(a[i][3],amt)
  102.         quaryAmt(a[i][2])
  103.         while itemAmt < essMax do
  104.           sleep(5)
  105.           quaryAmt(a[i][2])
  106.           print(a[i][1].." Essence at: "..itemAmt)
  107.         end
  108.         print(a[i][1].." Compleate: Changeing Crop")
  109.         redTog(time)
  110.       else
  111.         print(a[i][1].. " at set cap, cycleing...")
  112.         sleep(1)
  113.       end
  114.   end
  115. end
  116.  
  117. --Script
  118.  
  119. term.clear()
  120. print("Farm Control Startup")
  121.  
  122. while true do
  123.   amtLoop(240)
  124. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement