KaychenHH

Forestry v1

May 2nd, 2025
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.42 KB | Gaming | 0 0
  1. --Forestry V1.01
  2. --written in 05/2025 by Kay Michaelsen
  3. --
  4. --vardef
  5. --
  6. monitor1 = peripheral.wrap("monitor_16")
  7. monitor2 = peripheral.wrap("monitor_0")
  8. monitor3 = peripheral.wrap("monitor_15")
  9. monitor4 = peripheral.wrap("monitor_8")
  10. monitor5 = peripheral.wrap("monitor_10")
  11. --monitor6 = peripheral.wrap("monitor_16")
  12. rss = peripheral.wrap("meBridge_0")
  13. --
  14. obergrenze = 1000
  15. aPro = 0
  16.  
  17. arsn = "ars_nouveau:"
  18. arse = "ars_elemental:"
  19. myst = "mysticalagriculture:"
  20. imm = "immersiveengineering:"
  21. minc = "minecraft:"
  22. biom = "biomesoplenty:"
  23. cau ="caupona:"
  24. dyn = "integrateddynamics:"
  25. twf = "twilightforest"
  26.  
  27. automat = true
  28. dPage = 1
  29. dMax = 0
  30.  
  31. pName = {}
  32. pDN = {}
  33. pStat = {}
  34. pByte = {}
  35. pFound = {}
  36. pStored = {}
  37. pSide = {}
  38. pMax = {}
  39. aPro = 28
  40. dMax = math.floor(aPro / 18) +1
  41.  
  42. for zahl = 1, aPro do
  43.     pMax[zahl] = obergrenze
  44. end
  45. for lauf = 1,14 do
  46.     pSide[lauf] = 1
  47.     pSide[lauf + 15] = 2
  48. end
  49. for lauf = 1, aPro do
  50.     pStored[lauf] = 0
  51. end
  52.  
  53. pName[1] = minc.."oak_log"
  54. pDN[1] = "Oak"
  55. pStat[1] = false
  56. pByte[1] = colors.green
  57. pSide[1] = 1
  58. pMax[1] = 3000
  59.  
  60. pName[2] = minc.."dark_oak_log"
  61. pDN[2] = "Dark Oak"
  62. pStat[2] = false
  63. pByte[2] = colors.brown
  64. pSide[2] = 1
  65. pMax[2] = 3000
  66.  
  67. pName[3] = minc.."bamboo"
  68. pDN[3] = "Bamboo"
  69. pStat[3] = false
  70. pByte[3] = colors.blue
  71. pSide[3] = 1
  72. pMax[3] = 1000
  73.  
  74. pName[4] = dyn.."menril_log"
  75. pDN[4] = "Menril"
  76. pStat[4] = true
  77. pByte[4] = colors.purple
  78. pSide[4] = 1
  79. pMax[4] = 1000
  80.  
  81. pName[5] = arsn.."blue_archwood_log"
  82. pDN[5] = "Cascading Ar."
  83. pStat[5] = false
  84. pByte[5] = colors.cyan
  85. pSide[5] = 1
  86. pMax[5] = 1000
  87.  
  88. pName[6] = arsn.."red_archwood_log"
  89. pDN[6] = "Blazing Ar."
  90. pStat[6] = false
  91. pByte[6] = colors.lightGray
  92. pSide[6] = 1
  93. pMax[6] = 1000
  94.  
  95. pName[7] = arsn.."green_archwood_log"
  96. pDN[7] = "FlourishAr."
  97. pStat[7] = true
  98. pByte[7] = colors.gray
  99. pSide[7] = 1
  100. pMax[7] = 1000
  101.  
  102. pName[8] = arse.."yellow_archwood_log"
  103. pDN[8] = "Flashing Ar."
  104. pStat[8] = true
  105. pByte[8] = colors.pink
  106. pSide[8] = 1
  107. pMax[8] = 1000
  108.  
  109. pName[9] =arsn.."purple_archwood_log"
  110. pDN[9] = "Vexing Ar."
  111. pStat[9] = false
  112. pByte[9] = colors.lime
  113. pSide[9] = 1
  114. pMax[9] = 1000
  115.  
  116. pName[10] = biom.."palm_log"
  117. pDN[10] = "Palm"
  118. pStat[10] = false
  119. pByte[10] = colors.yellow
  120. pSide[10] = 1
  121. pMax[10] = 1000
  122.  
  123. pName[11] = minc.."acacia_log"
  124. pDN[11] = "Acacia"
  125. pStat[11] = false
  126. pByte[11] = colors.lightBlue
  127. pSide[11] = 1
  128. pMax[11] = 1000
  129.  
  130. pName[12] = minc.."mangrove_log"
  131. pDN[12] = "Mangrove Pr."
  132. pStat[12] = false
  133. pByte[12] = colors.magenta
  134. pSide[12] = 1
  135. pMax[12] = 1000
  136.  
  137. pName[13] = twf.."mangrove_log"
  138. pDN[13] = "Mangrove"
  139. pStat[13] = true
  140. pByte[13] = colors.orange
  141. pSide[13] = 1
  142. pMax[13] = 1000
  143.  
  144. pName[14] = "blue_skies:maple_log"
  145. pDN[14] = "Maple"
  146. pStat[14] = true
  147. pByte[14] = colors.white
  148. pMax[14] = 1000
  149. pSide[14] = 1
  150.  
  151. pName[15] = "silentgear:netherwood_log"
  152. pDN[15] = "Netherwood"
  153. pStat[15] = true
  154. pByte[15] = colors.green
  155. pSide[15] = 2
  156. pMax[15] = 1000
  157.  
  158. pName[16] = minc.."birch_log"
  159. pDN[16] = "Birch"
  160. pStat[16] = true
  161. pByte[16] = colors.brown
  162. pSide[16] = 2
  163. pMax[16] = 1000
  164.  
  165. pName[17] = minc.."cherry_log"
  166. pDN[17] = "Cherry"
  167. pStat[17] = true
  168. pByte[17] = colors.blue
  169. pSide[17] = 2
  170. pMax[17] = 1000
  171.  
  172. pName[18] = biom.."mahogany_log"
  173. pDN[18] = "Mahogany"
  174. pStat[18] = true
  175. pByte[18] = colors.purple
  176. pSide[18] = 2
  177. pMax[18] = 1000
  178.  
  179. pName[19] = biom.."redwood_log"
  180. pDN[19] = "Redwood"
  181. pStat[19] = true
  182. pByte[19] = colors.cyan
  183. pSide[19] = 2
  184. pMax[19] = 1000
  185.  
  186. pName[20] = "gtceu:rubber_log"
  187. pDN[20] = "Rubber"
  188. pStat[20] = true
  189. pByte[20] = colors.lightGray
  190. pSide[20] = 2
  191. pMax[20] = 1000
  192.  
  193. pName[21] = "aether:skyroot_log"
  194. pDN[21] = "Skyroot"
  195. pStat[21] = true
  196. pByte[21] = colors.gray
  197. pSide[21] = 2
  198. pMax[21] = 1000
  199.  
  200. pName[22] = "undergarden:grongle_log"
  201. pDN[22] = "Grongle"
  202. pStat[22] = true
  203. pByte[22] = colors.pink
  204. pSide[22] = 2
  205. pMax[22] = 1000
  206.  
  207. pName[23] = "undergarden:smogstem_log"
  208. pDN[23] = "Smogstem"
  209. pStat[23] = true
  210. pByte[23] = colors.lime
  211. pSide[23] = 2
  212. pMax[23] = 1000
  213.  
  214. pName[24] = cau.."walnut_log"
  215. pDN[24] = "Walnut"
  216. pStat[24] = true
  217. pByte[24] = colors.yellow
  218. pSide[24] = 2
  219. pMax[24] = 1000
  220.  
  221. pName[25] = minc.."spruce_log"
  222. pDN[25] = "Spruce"
  223. pStat[25] = true
  224. pByte[25] = colors.lightBlue
  225. pSide[25] = 2
  226. pMax[25] = 1000
  227.  
  228. pName[26] = minc.."jungle_log"
  229. pDN[26] = "Jungle"
  230. pStat[26] = true
  231. pByte[26] = colors.magenta
  232. pSide[26] = 2
  233. pMax[26] = 1000
  234.  
  235. pName[27] = "croptopia:cinnamon_log"
  236. pDN[27] = "Cinnamon"
  237. pStat[27] = true
  238. pByte[27] = colors.orange
  239. pSide[27] = 2
  240. pMax[27] = 1000
  241.  
  242. pName[28] = biom.."jacaranda_log"
  243. pDN[28] = "Jacaranda"
  244. pStat[28] = true
  245. pByte[28] = colors.white
  246. pSide[28] = 2
  247. pMax[28] = 1000
  248.  
  249.  
  250.  
  251. function UserCommand( xpos, ypos)
  252.  
  253.     local bunt = {}
  254.  
  255.     print("UC" ,xpos ,ypos)
  256.     if ypos == 23 then
  257.         if (xpos>42) and (xpos<54) then
  258.             if automat == true then
  259.                 automat = false
  260.             else
  261.                 automat = true
  262.             end
  263.         end
  264.     elseif ypos == 1 then
  265.         if (xpos<6) then
  266.             --prev page
  267.             if dPage > 1 then
  268.                 dPage = dPage -1
  269.             end
  270.         elseif (xpos>52) then
  271.             if dPage < dMax then
  272.                 dPage = dPage +1
  273.             end
  274.         end
  275.     elseif (ypos == 4) or (ypos == 7) or (ypos == 10) or (ypos == 13) or (ypos == 16) or (ypos == 19) then
  276.         npos = (ypos-1) / 3 - 1
  277.         mpos = 0
  278.         if (xpos>9) and (xpos<16) then
  279.             mpos = 1
  280.         elseif (xpos>28) and (xpos<35) then
  281.             mpos = 2
  282.         elseif (xpos>47) and (xpos<54) then
  283.             mpos = 3
  284.         end
  285.         if not(mpos == 0) then
  286.             proNr = (dPage - 1) * 18 + npos * 3 + mpos
  287.             print(proNr)
  288.             if pStat[proNr] == false then
  289.                 pStat[proNr] = true
  290.             else
  291.                 pStat[proNr] = false
  292.             end
  293.             bunt[1] = 0
  294.             bunt[2] = 0
  295.             bunt[3] = 0
  296.             for mpos = 1, aPro do
  297.                 if pStat[mpos] == true then
  298.                     bunt[pSide[mpos]] = bunt[pSide[mpos]] + pByte[mpos]
  299.                 end
  300.             end
  301.  
  302.             redstone.setBundledOutput("right", bunt[1])
  303.             redstone.setBundledOutput("bottom", bunt[2])
  304.             --redstone.setBundledOutput("bottom", bunt[3])
  305.             print(bunt[1], bunt[2])
  306.         end
  307.     end
  308. end
  309.  
  310.  
  311. function CheckInferiumReihe(lesen)
  312.  
  313.  
  314.     for i = 1,aPro do
  315.         pFound[i] = false
  316.     end
  317.  
  318.     such = {}
  319.     such.name = "mysticalagriculture"
  320.  
  321.     rs = rss.listItems()
  322.  
  323.     if not(rs == nil) then
  324.         for slot, item in pairs(rs) do
  325.             for i = 1, aPro do
  326.                 if item.name == pName[i] then
  327.                     found = true
  328.                     pStored[i] = item.amount
  329.                     pFound[i] = true
  330.                     if automat == true then
  331.                         if item.amount > pMax[i] then
  332.                             pStat[i] = false
  333.                         else
  334.                             pStat[i] = true
  335.                         end
  336.                     end
  337.                 end
  338.  
  339.             end
  340.         end
  341.  
  342.         for I = 1, aPro do
  343.             if pFound[i] == false then
  344.                 print(pName[i].." not found!")
  345.             end
  346.         end
  347.     end
  348.  
  349.     rs = rss.listFluid()
  350.  
  351.     if not(rs == nil) then
  352.         for slot, item in pairs(rs) do
  353.             for i = 1, aPro do
  354.                 if item.name == pName[i] then
  355.                     found = true
  356.                     pStored[i] = item.amount / 1000
  357.                     pFound[i] = true
  358.                     if automat == true then
  359.                         if (item.amount / 1000) > pMax[i] then
  360.                             pStat[i] = false
  361.                         else
  362.                             pStat[i] = true
  363.                         end
  364.                     end
  365.                 end
  366.  
  367.             end
  368.         end
  369.     end
  370.  
  371.  
  372.     local bunt = {}
  373.     bunt[1] = 0
  374.     bunt[2] = 0
  375.     bunt[3] = 0
  376.     for i = 1, aPro do
  377.         if pStat[i] == true then
  378.             bunt[pSide[i]] = bunt[pSide[i]] + pByte[i]
  379.         end
  380.     end
  381.     redstone.setBundledOutput("right", bunt[1])
  382.     redstone.setBundledOutput("bottom", bunt[2])
  383.     --redstone.setBundledOutput("bottom", bunt[3])
  384.  
  385. end
  386.  
  387. function MonAufbau(moni)
  388.  
  389.     if not(moni == nil) then
  390.         moni.setTextScale(0.5)
  391.         moni.setBackgroundColor(colors.black)
  392.         moni.clear()
  393.         moni.setBackgroundColor(colors.green)
  394.         moni.setTextColor(colors.black)
  395.         moni.setCursorPos(13,1)
  396.         moni.write(" *** Wuffelz Forestry Control *** ")
  397.  
  398.         moni.setCursorPos(2,1)
  399.         if dPage > 1 then
  400.             moni.setBackgroundColor(colors.orange)
  401.         else
  402.             moni.setBackgroundColor(colors.black)
  403.             moni.setTextColor(colors.orange)
  404.         end
  405.         moni.write(" << ")
  406.  
  407.         moni.setCursorPos(7,1)
  408.         moni.setBackgroundColor(colors.black)
  409.         moni.setTextColor(colors.orange)
  410.         moni.write(string.format("%1d", dPage))
  411.  
  412.         moni.setCursorPos(53,1)
  413.         if dPage < dMax then
  414.             moni.setBackgroundColor(colors.orange)
  415.             moni.setTextColor(colors.black)
  416.         else
  417.             moni.setBackgroundColor(colors.black)
  418.             moni.setTextColor(colors.orange)
  419.         end
  420.         moni.write(" >> ")
  421.  
  422.         for i = 1,6 do
  423.             k = (i-1) * 3 + 1
  424.             for j = 0,2 do
  425.                 moni.setBackgroundColor(colors.black)
  426.                 moni.setTextColor(colors.blue)
  427.                 if j == 1 then
  428.                     moni.setTextColor(colors.orange)
  429.                 end
  430.                 px = j * 19
  431.                 py = (i-1) * 3 + 3
  432.                 moni.setCursorPos(px + 1, py)
  433.                 pr = k + j + ((dPage - 1) * 18)
  434.                 if pr <= aPro then
  435.                     moni.write(pDN[pr])
  436.                     moni.setCursorPos(px+13, py)
  437.                     moni.write(string.format("%6d", pStored[pr]))
  438.                     moni.setCursorPos(px + 1, py + 1)
  439.                     if pStat[pr] == true then
  440.                         moni.setTextColor(colors.lime)
  441.                         moni.write("online")
  442.                         moni.setTextColor(colors.white)
  443.                         moni.setBackgroundColor(colors.red)
  444.                         moni.setCursorPos(px + 10, py + 1)
  445.                         moni.write("-> off")
  446.                     else
  447.                         moni.setTextColor(colors.red)
  448.                         moni.write("offline")
  449.                         moni.setTextColor(colors.white)
  450.                         moni.setBackgroundColor(colors.lime)
  451.                         moni.setCursorPos(px + 10, py + 1)
  452.                         moni.write("-> on ")
  453.                     end
  454.                 end
  455.             end
  456.         end
  457.         moni.setBackgroundColor(colors.black)
  458.         moni.setTextColor(colors.blue)
  459.         moni.setCursorPos(5,23)
  460.         moni.write("Automatic limit control is ")
  461.         moni.setCursorPos(33,23)
  462.         if automat then
  463.             moni.setTextColor(colors.lime)
  464.             moni.write("enabled ")
  465.             moni.setCursorPos(43,23)
  466.             moni.setBackgroundColor(colors.red)
  467.             moni.setTextColor(colors.white)
  468.             moni.write("-> disable ")
  469.         else
  470.             moni.setTextColor(colors.red)
  471.             moni.write("disabled ")
  472.             moni.setCursorPos(43,23)
  473.             moni.setBackgroundColor(colors.lime)
  474.             moni.setTextColor(colors.white)
  475.             moni.write("-> enable ")
  476.         end
  477.  
  478.  
  479.     end
  480.  
  481. end
  482.  
  483.  
  484. while true do
  485.  
  486.     CheckInferiumReihe(lesen)
  487.  
  488.     MonAufbau(monitor1)
  489.     MonAufbau(monitor2)
  490.     MonAufbau(monitor3)
  491.     MonAufbau(monitor4)
  492.     MonAufbau(monitor5)
  493.     --MonAufbau(monitor6)
  494.  
  495.     event, button, x, y = os.pullEventRaw()
  496.  
  497.     if event == "terminate" then
  498.         break
  499.     elseif event == "redstone" then
  500.         --neuer Durchlauf
  501.     elseif (event == "monitor_touch") and (button == "monitor_16") then
  502.         UserCommand( x, y)
  503.     elseif (event == "monitor_touch") and (button == "monitor_0") then
  504.         UserCommand( x, y)
  505.     elseif (event == "monitor_touch") and (button == "monitor_15") then
  506.         UserCommand( x, y)
  507.     elseif (event == "monitor_touch") and (button == "monitor_8") then
  508.         UserCommand( x, y)
  509.     elseif (event == "monitor_touch") and (button == "monitor_10") then
  510.         UserCommand( x, y)
  511.     else
  512.         print(event, button, x, y)
  513.     end
  514.  
  515. end
  516.  
  517.  
  518.  
Advertisement
Add Comment
Please, Sign In to add comment