KaychenHH

FarmCon6

Feb 18th, 2025
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.93 KB | Gaming | 0 0
  1.  
  2. --Farmcontrol V6.01
  3. --written in 07/2021 by Kay Michaelsen
  4. --updated in 02/2025
  5. --
  6. --vardef
  7. --
  8. monitor1 = peripheral.wrap("monitor_1")
  9. monitor2 = peripheral.wrap("monitor_4")
  10. monitor3 = peripheral.wrap("monitor_7")
  11. --monitor4 = peripheral.wrap("monitor_56")
  12. rss = peripheral.wrap("meBridge_0")
  13. --
  14. obergrenze = 50000
  15. aSeeds = 0
  16. aPro = 0
  17. myst = "mysticalagriculture:"
  18. imm = "immersiveengineering:"
  19. automat = true
  20. dPage = 1
  21. dMax = 0
  22.  
  23. seeds = {}
  24. seeds[1] = myst.."inferium_seeds"
  25. seeds[2] = myst.."osmium_seeds"
  26. seeds[3] = myst.."uranium_seeds"
  27. seeds[4] = myst.."nether_star_seeds"
  28. seeds[5] = myst.."nether_quartz_seeds"
  29. seeds[6] = myst.."lead_seeds"
  30. seeds[7] = myst.."glowstone_seeds"
  31. seeds[8] = myst.."enderman_seeds"
  32. seeds[9] = myst.."emerald_seeds"
  33. seeds[10] = myst.."diamond_seeds"
  34. seeds[11] = myst.."redstone_seeds"
  35. seeds[12] = myst.."copper_seeds"
  36. seeds[13] = myst.."wither_skeleton_seeds"
  37. seeds[14] = myst.."netherite_seeds"
  38. seeds[15] = myst.."lapis_lazuli_seeds"
  39. seeds[16] = myst.."ghast_seeds"
  40. seeds[17] = myst.."certus_quartz_seeds"
  41. seeds[18] = myst.."gold_seeds"
  42. seeds[19] = myst.."blaze_seeds"
  43. seeds[20] = myst.."platinum_seeds"
  44. seeds[21] = myst.."dye_seeds"
  45. seeds[22] = myst.."cobalt_seeds"
  46. seeds[23] = myst.."creeper_seeds"
  47. seeds[24] = myst.."nature_seeds"
  48. seeds[25] = imm.."seeds"
  49. seeds[26] = myst.."coal_seeds"
  50. seeds[27] = myst.."chicken_seeds"
  51. seeds[28] = myst.."iron_seeds"
  52. seeds[29] = myst.."silver_seeds"
  53. seeds[30] = myst.."dirt_seeds"
  54. seeds[31] = myst.."honey_seeds"
  55. seeds[32] = myst.."rabbit_seeds"
  56. seeds[33] = myst.."allthemodium_seeds"
  57. seeds[34] = myst.."vibranium_seeds"
  58. seeds[35] = myst.."unobtainium_seeds"
  59.  
  60. aSeeds = 35
  61.  
  62. pName = {}
  63. pDN = {}
  64. pLine = {}
  65. pStat = {}
  66. pByte = {}
  67. pFound = {}
  68. pStored = {}
  69. pSide = {}
  70. pMax = {}
  71. aPro = 35
  72. dMax = math.floor(aPro / 18) +1
  73.  
  74. for zahl = 1, aPro do
  75.     pMax[zahl] = obergrenze
  76. end
  77. for lauf = 1,14 do
  78.     pSide[lauf] = 1
  79. end
  80. for lauf = 1, aPro do
  81.     pStored[lauf] = 0
  82. end
  83.  
  84.  
  85. pName[1] = "minecraft:glowstone_dust"
  86. pDN[1] = "GlowStone"
  87. pLine[1] = "green"
  88. pStat[1] = false
  89. pByte[1] = colors.green
  90. pSide[1] = 1
  91. pMax[1] = 100000
  92.  
  93. pName[2] = "minecraft:white_wool"
  94. pDN[2] = "White Wool"
  95. pLine[2] = "brown"
  96. pStat[2] = false
  97. pByte[2] = colors.brown
  98. pSide[2] = 1
  99. pMax[2] = 50000
  100.  
  101. pName[3] = "minecraft:iron_ingot"
  102. pDN[3] = "Iron"
  103. pLine[3] = "blue"
  104. pStat[3] = false
  105. pByte[3] = colors.blue
  106. pSide[3] = 1
  107. pMax[3] = 100000
  108.  
  109. pName[4] = myst.."inferium_essence"
  110. pDN[4] = "Inferium"
  111. pLine[4] = "purple"
  112. pStat[4] = true
  113. pByte[4] = colors.purple
  114. pSide[4] = 1
  115. pMax[4] = 150000
  116.  
  117. pName[5] = "minecraft:quartz"
  118. pDN[5] = "Neth.Quartz"
  119. pLine[5] = "cyan"
  120. pStat[5] = false
  121. pByte[5] = colors.cyan
  122. pSide[5] = 1
  123. pMax[5] = 100000
  124.  
  125. pName[6] = "minecraft:redstone"
  126. pDN[6] = "Redstone"
  127. pLine[6] = "lightGray"
  128. pStat[6] = false
  129. pByte[6] = colors.lightGray
  130. pSide[6] = 1
  131. pMax[6] = 100000
  132.  
  133. pName[7] = "ae2:certus_quartz_crystal"
  134. pDN[7] = "Certus"
  135. pLine[7] = "gray"
  136. pStat[7] = true
  137. pByte[7] = colors.gray
  138. pSide[7] = 1
  139.  
  140. pName[8] = "minecraft:coal"
  141. pDN[8] = "Coal"
  142. pLine[8] = "pink"
  143. pStat[8] = true
  144. pByte[8] = colors.pink
  145. pSide[8] = 1
  146.  
  147. pName[9] ="minecraft:blaze_rod"
  148. pDN[9] = "Blaze Rod"
  149. pLine[9] = "lime"
  150. pStat[9] = false
  151. pByte[9] = colors.lime
  152. pSide[9] = 1
  153.  
  154. pName[10] = "minecraft:gold_ingot"
  155. pDN[10] = "Gold"
  156. pLine[10] = "lightBlue"
  157. pStat[10] = false
  158. pByte[10] = colors.lightBlue
  159. pSide[10] = 1
  160.  
  161. pName[11] = "minecraft:bone_meal"
  162. pDN[11] = "Bone meal"
  163. pLine[11] = "orange"
  164. pStat[11] = false
  165. pByte[11] = colors.orange
  166. pSide[11] = 1
  167.  
  168. pName[12] = "minecraft:ender_pearl"
  169. pDN[12] = "Ender Pearl"
  170. pLine[12] = "white"
  171. pStat[12] = false
  172. pByte[12] = colors.white
  173. pSide[12] = 2
  174.  
  175. pName[13] = "allthemodium:vibranium_ingot"
  176. pDN[13] = "Vibranium"
  177. pLine[13] = "green"
  178. pStat[13] = true
  179. pByte[13] = colors.green
  180. pSide[13] = 2
  181.  
  182. pName[14] = "minecraft:ghast_tear"
  183. pDN[14] = "Ghast Tear"
  184. pLine[14] = "black"
  185. pStat[14] = true
  186. pByte[14] = colors.black
  187. pMax[14] = 10000
  188. pSide[14] = 1
  189.  
  190. pName[15] = "allthemodium:unobtainium_ingot"
  191. pDN[15] = "Unobtainium"
  192. pLine[15] = "brown"
  193. pStat[15] = true
  194. pByte[15] = colors.brown
  195. pSide[15] = 2
  196. pMax[15] = 10000
  197.  
  198. pName[16] = "minecraft:netherite_ingot"
  199. pDN[16] = "Netherite"
  200. pLine[16] = "purple"
  201. pStat[16] = true
  202. pByte[16] = colors.purple
  203. pSide[16] = 2
  204. pMax[16] = 10000
  205.  
  206. pName[17] = "alltheores:enderium_ingot"
  207. pDN[17] = "Enderium"
  208. pLine[17] = "cyan"
  209. pStat[17] = true
  210. pByte[17] = colors.cyan
  211. pSide[17] = 2
  212. pMax[17] = 30000
  213.  
  214. pName[18] = "minecraft:nether_star"
  215. pDN[18] = "Nether Star"
  216. pLine[18] = "lightGray"
  217. pStat[18] = true
  218. pByte[18] = colors.lightGray
  219. pSide[18] = 2
  220. pMax[18] = 20000
  221.  
  222. pName[19] = "allthemodium:allthemodium_ingot"
  223. pDN[19] = "Allthemodium"
  224. pLine[19] = "gray"
  225. pStat[19] = true
  226. pByte[19] = colors.gray
  227. pSide[19] = 2
  228. pMax[19] = 20000
  229.  
  230. pName[20] = "minecraft:diamond"
  231. pDN[20] = "Diamond"
  232. pLine[20] = "pink"
  233. pStat[20] = true
  234. pByte[20] = colors.pink
  235. pSide[20] = 2
  236. pMax[20] = 30000
  237.  
  238. pName[21] = "minecraft:emerald"
  239. pDN[21] = "Emerald"
  240. pLine[21] = "lime"
  241. pStat[21] = true
  242. pByte[21] = colors.lime
  243. pSide[21] = 2
  244. pMax[21] = 30000
  245.  
  246. pName[22] = "minecraft:obsidian"
  247. pDN[22] = "Obsidian"
  248. pLine[22] = "yellow"
  249. pStat[22] = true
  250. pByte[22] = colors.yellow
  251. pSide[22] = 2
  252. pMax[22] = 50000
  253.  
  254. pName[23] = "mekanism:ingot_refined_obsidian"
  255. pDN[23] = "Ref.Obsidian"
  256. pLine[23] = "magenta"
  257. pStat[23] = true
  258. pByte[23] = colors.magenta
  259. pSide[23] = 1
  260. pMax[23] = 30000
  261.  
  262. pName[24] = "alltheores:osmium_ingot"
  263. pDN[24] = "Osmium"
  264. pLine[24] = "yellow"
  265. pStat[24] = true
  266. pByte[24] = colors.yellow
  267. pSide[24] = 1
  268. pMax[24] = 30000
  269.  
  270. pName[25] = "alltheores:tin_ingot"
  271. pDN[25] = "Tin"
  272. pLine[25] = "green"
  273. pStat[25] = true
  274. pByte[25] = colors.green
  275. pSide[25] = 3
  276. pMax[25] = 50000
  277.  
  278. pName[26] = "alltheores:bronze_ingot"
  279. pDN[26] = "Bronze"
  280. pLine[26] = "brown"
  281. pStat[26] = true
  282. pByte[26] = colors.brown
  283. pSide[26] = 3
  284. pMax[26] = 30000
  285.  
  286. pName[27] = "alltheores:zinc_ingot"
  287. pDN[27] = "Zinc"
  288. pLine[27] = "blue"
  289. pStat[27] = true
  290. pByte[27] = colors.blue
  291. pSide[27] = 3
  292. pMax[27] = 50000
  293.  
  294. pName[28] = "alltheores:aluminum_ingot"
  295. pDN[28] = "Aluminum"
  296. pLine[28] = "purple"
  297. pStat[28] = true
  298. pByte[28] = colors.purple
  299. pSide[28] = 3
  300. pMax[28] = 50000
  301.  
  302. pName[29] = "alltheores:steel_ingot"
  303. pDN[29] = "Steel"
  304. pLine[29] = "cyan"
  305. pStat[29] = true
  306. pByte[29] = colors.cyan
  307. pSide[29] = 3
  308. pMax[29] = 50000
  309.  
  310. pName[30] = "alltheores:silver_ingot"
  311. pDN[30] = "Silver"
  312. pLine[30] = "gray"
  313. pStat[30] = true
  314. pByte[30] = colors.gray
  315. pSide[30] = 3
  316. pMax[30] = 50000
  317.  
  318. pName[31] = "alltheores:lead_ingot"
  319. pDN[31] = "Lead"
  320. pLine[31] = "lightGray"
  321. pStat[31] = true
  322. pByte[31] = colors.lightGray
  323. pSide[31] = 3
  324. pMax[31] = 50000
  325.  
  326. pName[32] = "minecraft:copper_ingot"
  327. pDN[32] = "Copper"
  328. pLine[32] = "pink"
  329. pStat[32] = true
  330. pByte[32] = colors.pink
  331. pSide[32] = 3
  332. pMax[32] = 100000
  333.  
  334. pName[33] = "alltheores:brass_ingot"
  335. pDN[33] = "Brass"
  336. pLine[33] = "lime"
  337. pStat[33] = true
  338. pByte[33] = colors.lime
  339. pSide[33] = 3
  340. pMax[33] = 30000
  341.  
  342. pName[34] = "alltheores:sapphire"
  343. pDN[34] = "Sapphire"
  344. pLine[34] = "white"
  345. pStat[34] = true
  346. pByte[34] = colors.white
  347. pSide[34] = 1
  348. pMax[34] = 10000
  349.  
  350. pName[35] = "alltheores:nickel_ingot"
  351. pDN[35] = "Nickel"
  352. pLine[35] = "yellow"
  353. pStat[35] = true
  354. pByte[35] = colors.yellow
  355. pSide[35] = 3
  356. pMax[35] = 30000
  357.  
  358.  
  359. function UserCommand( xpos, ypos)
  360.  
  361.     local bunt = {}
  362.  
  363.     print("UC" ,xpos ,ypos)
  364.     if ypos == 23 then
  365.         if (xpos>42) and (xpos<54) then
  366.             if automat == true then
  367.                 automat = false
  368.             else
  369.                 automat = true
  370.             end
  371.         end
  372.     elseif ypos == 1 then
  373.         if (xpos<6) then
  374.             --prev page
  375.             if dPage > 1 then
  376.                 dPage = dPage -1
  377.             end
  378.         elseif (xpos>52) then
  379.             if dPage < dMax then
  380.                 dPage = dPage +1
  381.             end
  382.         end
  383.     elseif (ypos == 4) or (ypos == 7) or (ypos == 10) or (ypos == 13) or (ypos == 16) or (ypos == 19) then
  384.         npos = (ypos-1) / 3 - 1
  385.         mpos = 0
  386.         if (xpos>9) and (xpos<16) then
  387.             mpos = 1
  388.         elseif (xpos>28) and (xpos<35) then
  389.             mpos = 2
  390.         elseif (xpos>47) and (xpos<54) then
  391.             mpos = 3
  392.         end
  393.         if not(mpos == 0) then
  394.             proNr = (dPage - 1) * 18 + npos * 3 + mpos
  395.             print(proNr)
  396.             if pStat[proNr] == false then
  397.                 pStat[proNr] = true
  398.             else
  399.                 pStat[proNr] = false
  400.             end
  401.             bunt[1] = 0
  402.             bunt[2] = 0
  403.             bunt[3] = 0
  404.             for mpos = 1, aPro do
  405.                 if pStat[mpos] == true then
  406.                     bunt[pSide[mpos]] = bunt[pSide[mpos]] + pByte[mpos]
  407.                 end
  408.             end
  409.  
  410.             redstone.setBundledOutput("back", bunt[1])
  411.             redstone.setBundledOutput("right", bunt[2])
  412.             redstone.setBundledOutput("bottom", bunt[3])
  413.             print(bunt[1], bunt[2], bunt[3])
  414.         end
  415.     end
  416. end
  417.  
  418.  
  419. function CheckInferiumReihe(lesen)
  420.  
  421.  
  422.     for i = 1,aPro do
  423.         pFound[i] = false
  424.     end
  425.  
  426.     such = {}
  427.     such.name = "mysticalagriculture"
  428.  
  429.     rs = rss.listItems()
  430.  
  431.     if not(rs == nil) then
  432.         for slot, item in pairs(rs) do
  433.             for i = 1, aPro do
  434.                 if item.name == pName[i] then
  435.                     found = true
  436.                     pStored[i] = item.amount
  437.                     pFound[i] = true
  438.                     if automat == true then
  439.                         if item.amount > pMax[i] then
  440.                             pStat[i] = false
  441.                         else
  442.                             pStat[i] = true
  443.                         end
  444.                     end
  445.                 end
  446.  
  447.             end
  448.         end
  449.  
  450.         for I = 1, aPro do
  451.             if pFound[i] == false then
  452.                 print(pName[i].." not found!")
  453.             end
  454.         end
  455.     end
  456.  
  457.     rs = rss.listfluid()
  458.  
  459.     if not(rs == nil) then
  460.         for slot, item in pairs(rs) do
  461.             for i = 1, aPro do
  462.                 if item.name == pName[i] then
  463.                     found = true
  464.                     pStored[i] = item.amount
  465.                     pFound[i] = true
  466.                     if automat == true then
  467.                         if item.amount > pMax[i] then
  468.                             pStat[i] = false
  469.                         else
  470.                             pStat[i] = true
  471.                         end
  472.                     end
  473.                 end
  474.  
  475.             end
  476.         end
  477.     end
  478.  
  479.  
  480.     local bunt = {}
  481.     bunt[1] = 0
  482.     bunt[2] = 0
  483.     bunt[3] = 0
  484.     for i = 1, aPro do
  485.         if pStat[i] == true then
  486.             bunt[pSide[i]] = bunt[pSide[i]] + pByte[i]
  487.         end
  488.     end
  489.     redstone.setBundledOutput("left", bunt[1])
  490.     redstone.setBundledOutput("right", bunt[2])
  491.     redstone.setBundledOutput("bottom", bunt[3])
  492.  
  493. end
  494.  
  495. function MonAufbau(moni)
  496.  
  497.     if not(moni == nil) then
  498.         moni.setTextScale(0.5)
  499.         moni.setBackgroundColor(colors.black)
  500.         moni.clear()
  501.         moni.setBackgroundColor(colors.green)
  502.         moni.setTextColor(colors.black)
  503.         moni.setCursorPos(10,1)
  504.         moni.write(" *** Wuffelz Ressource Farm Control *** ")
  505.  
  506.         moni.setCursorPos(2,1)
  507.         if dPage > 1 then
  508.             moni.setBackgroundColor(colors.orange)
  509.         else
  510.             moni.setBackgroundColor(colors.black)
  511.             moni.setTextColor(colors.orange)
  512.         end
  513.         moni.write(" << ")
  514.  
  515.         moni.setCursorPos(7,1)
  516.         moni.setBackgroundColor(colors.black)
  517.         moni.setTextColor(colors.orange)
  518.         moni.write(string.format("%1d", dPage))
  519.  
  520.         moni.setCursorPos(53,1)
  521.         if dPage < dMax then
  522.             moni.setBackgroundColor(colors.orange)
  523.             moni.setTextColor(colors.black)
  524.         else
  525.             moni.setBackgroundColor(colors.black)
  526.             moni.setTextColor(colors.orange)
  527.         end
  528.         moni.write(" >> ")
  529.  
  530.         for i = 1,6 do
  531.             k = (i-1) * 3 + 1
  532.             for j = 0,2 do
  533.                 moni.setBackgroundColor(colors.black)
  534.                 moni.setTextColor(colors.blue)
  535.                 if j == 1 then
  536.                     moni.setTextColor(colors.orange)
  537.                 end
  538.                 px = j * 19
  539.                 py = (i-1) * 3 + 3
  540.                 moni.setCursorPos(px + 1, py)
  541.                 pr = k + j + ((dPage - 1) * 18)
  542.                 if pr <= aPro then
  543.                     moni.write(pDN[pr])
  544.                     moni.setCursorPos(px+13, py)
  545.                     moni.write(string.format("%6d", pStored[pr]))
  546.                     moni.setCursorPos(px + 1, py + 1)
  547.                     if pStat[pr] == true then
  548.                         moni.setTextColor(colors.lime)
  549.                         moni.write("online")
  550.                         moni.setTextColor(colors.white)
  551.                         moni.setBackgroundColor(colors.red)
  552.                         moni.setCursorPos(px + 10, py + 1)
  553.                         moni.write("-> off")
  554.                     else
  555.                         moni.setTextColor(colors.red)
  556.                         moni.write("offline")
  557.                         moni.setTextColor(colors.white)
  558.                         moni.setBackgroundColor(colors.lime)
  559.                         moni.setCursorPos(px + 10, py + 1)
  560.                         moni.write("-> on ")
  561.                     end
  562.                 end
  563.             end
  564.         end
  565.         moni.setBackgroundColor(colors.black)
  566.         moni.setTextColor(colors.blue)
  567.         moni.setCursorPos(5,23)
  568.         moni.write("Automatic limit control is ")
  569.         moni.setCursorPos(33,23)
  570.         if automat then
  571.             moni.setTextColor(colors.lime)
  572.             moni.write("enabled ")
  573.             moni.setCursorPos(43,23)
  574.             moni.setBackgroundColor(colors.red)
  575.             moni.setTextColor(colors.white)
  576.             moni.write("-> disable ")
  577.         else
  578.             moni.setTextColor(colors.red)
  579.             moni.write("disabled ")
  580.             moni.setCursorPos(43,23)
  581.             moni.setBackgroundColor(colors.lime)
  582.             moni.setTextColor(colors.white)
  583.             moni.write("-> enable ")
  584.         end
  585.  
  586.  
  587.     end
  588.  
  589. end
  590.  
  591.  
  592. while true do
  593.  
  594.     CheckInferiumReihe(lesen)
  595.  
  596.     MonAufbau(monitor1)
  597.     MonAufbau(monitor2)
  598.     MonAufbau(monitor3)
  599.     --MonAufbau(monitor4)
  600.  
  601.     event, button, x, y = os.pullEventRaw()
  602.  
  603.     if event == "terminate" then
  604.         break
  605.     elseif event == "redstone" then
  606.         --neuer Durchlauf
  607.     elseif (event == "monitor_touch") and (button == "monitor_4") then
  608.         UserCommand( x, y)
  609.     elseif (event == "monitor_touch") and (button == "monitor_1") then
  610.         UserCommand( x, y)
  611.     elseif (event == "monitor_touch") and (button == "monitor_7") then
  612.         UserCommand( x, y)
  613.     elseif (event == "monitor_touch") and (button == "monitor_55") then
  614.         UserCommand( x, y)
  615.     else
  616.         print(event, button, x, y)
  617.     end
  618.  
  619. end
  620.  
  621.  
  622.  
Tags: minecraft
Advertisement
Add Comment
Please, Sign In to add comment