EnnekPL

kontroler 1.5.2

Jan 3rd, 2014
540
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.45 KB | None | 0 0
  1. -- supported: macerator,electric furnace,extractor,compressor,
  2. -- supported: plate bending machine,assembling machine,industrial grinder,industrial blast furnace
  3. -- supported: recycler,powered furnace,pulverizer,sawmill, induction smelter
  4. -- supported: batbox,mfe,cesu,mfsu,capacitor bank
  5. -- supported: RC tanks, OpenBlocks tanks(W.I.P.)
  6. -- supported: me controller
  7.  
  8. -- bitowa paleta kolorow.
  9. local palette = {["white"] = 1, ["orange"] = 2, ["magenta"] = 4, ["lightBlue"] = 8, ["yellow"] = 16,
  10. ["lime"] = 32, ["pink"] = 64, ["gray"] = 128, ["lightGray"] = 256, ["cyan"] = 512, ["purple"] = 1024,
  11. ["blue"] = 2048, ["brown"] = 4096, ["green"] = 8192, ["red"] = 16384, ["black"] = 32768}
  12.  
  13. -- *** CONFIG **
  14. -- zmienne
  15. local version = "0.5.5"
  16.  
  17. local activeMsg, inactiveMsg, pendingMsg = "USING", "IDLE", "PENDI"
  18. local textSize = 1
  19. local name_mfsu = "BatBox"
  20. -- Monitory
  21. local powerMon = "monitor_9" -- pierwszy monitor "ENERGIA i MASZYNY"
  22. local tankMon = "monitor_8" -- drugi monitor "Tanki RC"
  23. local AEMon = "monitor_10" -- monitor AE
  24. local machMon = "monitor_11"
  25. local mon = peripheral.wrap(powerMon)
  26. local mon2 = peripheral.wrap(tankMon)
  27. local mon3 = peripheral.wrap(AEMon)
  28. local mon4 = peripheral.wrap(machMon)
  29. mon.clear()
  30. mon2.clear()
  31. mon3.clear()
  32. mon4.clear()
  33. mon.setTextScale(textSize)
  34. mon2.setTextScale(textSize)
  35. mon3.setTextScale(textSize)
  36. mon4.setTextScale(textSize)
  37. -- Maszyny --
  38. -- IC2
  39. local name_comp = "COMPRESSOR"
  40. local name_furnace = "E.FURNACE"
  41. local name_ext = "EXTRCTOR"
  42. local name_mace = "MACERTOR"
  43. local name_recycler = "RECYCLR"
  44. local name_canning = "CAN_MCHINE"
  45. -- GT
  46. local name_pbm = "PLATE BEND.M."
  47. local name_asseM = "ASSEMBL M."
  48. local name_ind_grin = "IND.GRINDER"
  49. local name_ind_BF = "BLAST.FURN."
  50.  
  51. -- TE
  52. local name_REC = "R.E.C."
  53. local name_pow_furnance = "POW.FURNANCE"
  54. local name_pulverizer = "PULVERIZER"
  55. local name_sawmill = "SAWMILL"
  56. local name_ind_smel = "IND.SMELTER"
  57.  
  58. -- Kolory
  59. local hc = palette.lightBlue -- domyslny kolor nag��wka
  60. local tc = palette.white -- domyslny kolor textu
  61. local color_reading = palette.lime
  62. local color_inactive = palette.gray
  63. local color_active = palette.lime
  64. local color_machines = palette.orange
  65. local color_ores = palette.pink
  66. -- Pozycje tekst�w
  67. local pwrX_Reading = 25
  68. local machineDisplayXPos = 14
  69. local offsetPos = 2
  70. local mStatusPos = 18
  71. local orePos = 26
  72. -- SPECIAL CHARACTERS
  73. local separator = " | "
  74. local spacer = " : "
  75. -- Inne ustawienia
  76. local waitTime = {9,13}
  77. local timer = {0,0,0,0,0,0,0,0,0,0,0}
  78. local supported_Power = {"mfsu","mfe","batbox", "redstone_energy_cell"}
  79. local supported_Machines = {"automatic_macerator","electric_furnace", "automatic_extractor", "automatic_compressor", "plate_bending_machine", "assembling_machine", "industrial_grinder", "industrial_blast_furnace", "canning", "recycler", "powered_furnace", "pulverizer", "sawmill", "induction_smelter"}
  80. local sleepTime = 2
  81. local numFormat = 1
  82. -- sloty maszyn --
  83. local ic2ItemUsed = 6
  84. local ic2ItemCreated = 1
  85. local gtItemInput = 2
  86. local gtItemInd = 0
  87. local teItemInput = 0
  88. -- Load API ---
  89. if fs.exists("enu") then else shell.run("pastebin get AyU03Gk8 enu") end
  90.  
  91.  
  92. os.loadAPI("enu")
  93. ---------------
  94.  
  95. term.clear()
  96.  
  97. function upMachines(mnitPeri)
  98. term.clear()
  99. term.setCursorPos(1,1)
  100. machines = peripheral.getNames()
  101. table.sort(machines)
  102. if mnitPeri then
  103. for k, v in pairs(machines) do
  104. print(tostring(k)..": "..tostring(v))
  105. end
  106. end
  107. end
  108. function procenty(capa, stor)
  109. if capa and stor ~= 0 then
  110. local proc = 100 / capa * stor
  111. local a = math.floor(proc*1000 + 0.5)/ 1000
  112. tempProc = string.format("%.2f",a)
  113. else
  114. tempProc = 0
  115. end
  116. return tempProc
  117. end
  118. function advList(getPeriph) -- lista dostepnych funkcji dla perip.
  119. uused = getPeriph["getAdvancedMethodsData"]()
  120. for key, value in pairs(uused) do
  121. print(value.name)
  122. sleep(1)
  123. end
  124. end
  125.  
  126. machines = peripheral.getNames()
  127. table.sort(machines)
  128.  
  129. -- MONITOR 1 x,y Pos
  130. local machinesInfoCol = 1
  131.  
  132. -- MONITOR 2 x,y Pos
  133. local tankPosStart = 1
  134.  
  135. -- *** FUNKCJE ***
  136. function pFormat(pName) -- formatowanie nazwy
  137.  
  138. if string.find(pName, "automatic_compressor") then pName = name_comp
  139. elseif string.find(pName, "electric_furnace") then pName = name_furnace
  140. elseif string.find(pName, "automatic_extractor") then pName = name_ext
  141. elseif string.find(pName, "automatic_macerator") then pName = name_mace
  142. elseif string.find(pName, "canning") then pName = name_canning
  143. elseif string.find(pName, "recycler") then pName = name_recycler
  144. elseif string.find(pName, "former") then pName = name_former
  145. elseif string.find(pName, "batbox") then pName = name_mfsu
  146. elseif string.find(pName, "redstone_energy_cell") then pName = name_REC
  147. elseif string.find(pName, "powered_furnace") then pName = name_pow_furnance
  148. elseif string.find(pName, "pulverizer") then pName = name_pulverizer
  149. elseif string.find(pName, "sawmill") then pName = name_sawmill
  150. elseif string.find(pName, "induction_smelter") then pName = name_ind_smel
  151. elseif string.find(pName, "plate_bending_machine") then pName = name_pbm
  152. elseif string.find(pName, "assembling_machine") then pName = name_asseM
  153. elseif string.find(pName, "industrial_grinder") then pName = name_ind_grin
  154. elseif string.find(pName, "industrial_blast_furnace") then pName = name_ind_BF
  155. end
  156. return pName
  157. end
  158.  
  159. function dispAE()
  160. mon3.setCursorPos(offsetPos,2)
  161. for j=1, #machines do
  162. -- AE
  163. AEperiph = peripheral.wrap(machines[j])
  164. if string.find(machines[j], "me_controller") then
  165. local AEener = AEperiph.provideCellWithFilter("STORED") -- All, STORED
  166.  
  167. local storedAE = AEener.usedBytes
  168. local capacityAE = AEener.totalBytes
  169. local itemCountAE = AEener.storedItemCount
  170. local itemSTypeAE = AEener.storedItemTypes
  171. local itemTTypeAE = AEener.totalItemTypes
  172. --print(AEperiph)
  173. enu.appendString(AEMon, tc, " Memory Stored " .. separator, true, offsetPos, 3)
  174. enu.appendString(AEMon, color_reading, (enu.dot(storedAE)), false, pwrX_Reading, 3)
  175. enu.appendString(AEMon, tc, " Memory State " .. separator, true, offsetPos, 5)
  176. enu.appendString(AEMon, palette.cyan, procenty(capacityAE,storedAE).."%", false, pwrX_Reading, 5)
  177. enu.appendString(AEMon, tc, " Memory Capacity " .. separator, true, offsetPos, 4)
  178. enu.appendString(AEMon, color_reading, (enu.dot(capacityAE)), false, pwrX_Reading,4 )
  179.  
  180. enu.appendString(AEMon, tc, " Items " .. separator, true, offsetPos, 7)
  181. enu.appendString(AEMon, color_reading, (enu.dot(itemCountAE)), false, pwrX_Reading,7 )
  182.  
  183. enu.appendString(AEMon, tc, " Stored Types " .. separator, true, offsetPos, 9)
  184. enu.appendString(AEMon, color_reading, (enu.dot(itemSTypeAE)), false, pwrX_Reading,9 )
  185. enu.appendString(AEMon, tc, " Stored Types State " .. separator, true, offsetPos, 11)
  186. enu.appendString(AEMon, palette.cyan, procenty(itemTTypeAE,itemSTypeAE).."%", false, pwrX_Reading,11)
  187. enu.appendString(AEMon, tc, " Total Types " .. separator, true, offsetPos, 10)
  188. enu.appendString(AEMon, color_reading, (enu.dot(itemTTypeAE)), false, pwrX_Reading,10)
  189. end
  190. end
  191. end
  192.  
  193. function dispTanks()
  194. mon2.setCursorPos(offsetPos,2)
  195. for i=1, #machines do
  196. -- RC Tanks
  197. if string.find(machines[i], "iron_tank_valve") or string.find(machines[i], "steel_tank_valve") or string.find(machines[i], "tank") then
  198. -- print(machines[i])
  199. if peripheral.isPresent(machines[i]) then
  200. periph = peripheral.wrap(machines[i])
  201.  
  202. fluidRaw, fluidName, fluidAmount, fluidCapacity, fluidID = enu.getTank(periph)
  203.  
  204. if fluidName == nil then
  205. -- brak fluidu nie wyswietli tanka
  206. elseif fluidName ~= nil then
  207. mon2.setTextColor(tc)
  208. x,y = mon2.getCursorPos()
  209. mon2.setCursorPos(offsetPos, (y+1))
  210. mon2.clearLine()
  211. mon2.write(" (" .. fluidName .. ") : " ..enu.dot(fluidAmount) .. " / " ..enu.dot(fluidCapacity) .. " mb (" ..procenty(fluidCapacity,fluidAmount).."%)")
  212. end
  213. end
  214. end
  215. end
  216. end
  217.  
  218. function dispPower()
  219. local couMJM = 0
  220. local couEUM = 0
  221. local totalStorage = 0
  222. local totalCapacity = 0
  223. local totalStoredMJ = 0
  224. local totalCapacityMJ = 0
  225. for i=1, #machines do
  226. if string.find(machines[i], "batbox") then -- IC2 Power
  227. periph = peripheral.wrap(machines[i])
  228. local storedEU = periph.getStored()
  229. local capacity = periph.getCapacity()
  230.  
  231. totalStorage = totalStorage + storedEU
  232. totalCapacity = capacity + totalCapacity
  233. couEUM = couEUM + 1
  234. end
  235. if string.find(machines[i], "redstone_energy_cell") or string.find(machines[i], "capacitor_bank") then -- TE Power
  236. periph = peripheral.wrap(machines[i])
  237. local storedMJ = periph.getEnergyStored()
  238. local capacityMJ = periph.getMaxEnergyStored()
  239.  
  240. totalStoredMJ = storedMJ + totalStoredMJ
  241. totalStoredMJ = math.floor(totalStoredMJ)
  242. totalCapacityMJ = capacityMJ + totalCapacityMJ
  243.  
  244. couMJM = couMJM +1
  245. end
  246. end
  247. -- EU
  248. enu.cString(offsetPos, 3, palette.lime, powerMon, " * EU - "..procenty(totalCapacity,totalStorage).."%")
  249. enu.appendString(powerMon, tc, " Stored EU " .. separator, true, offsetPos, 4)
  250. enu.appendString(powerMon, color_reading, (enu.dot(totalStorage)), false, pwrX_Reading, 4)
  251. enu.appendString(powerMon, tc, " Total EU Capacity " .. separator, true, offsetPos, 5)
  252. enu.appendString(powerMon, color_reading, (enu.dot(totalCapacity)), false, pwrX_Reading,5 )
  253. enu.appendString(powerMon, tc, " Liczba Box " .. separator, true, offsetPos, 6)
  254. enu.appendString(powerMon, color_reading, (enu.dot(couEUM)), false, pwrX_Reading, 6)
  255. -- MJ
  256. enu.cString(offsetPos, 8, palette.lime, powerMon, " * MJ - "..procenty(totalCapacityMJ,totalStoredMJ).."%")
  257. enu.appendString(powerMon, tc, " Stored MJ " .. separator, true, offsetPos, 9)
  258. enu.appendString(powerMon, color_reading, enu.dot(totalStoredMJ), false, pwrX_Reading, 9)
  259. enu.appendString(powerMon, tc, " Total MJ Capacity " .. separator, true, offsetPos, 10)
  260. enu.appendString(powerMon, color_reading, (enu.dot(totalCapacityMJ)), false, pwrX_Reading, 10)
  261. enu.appendString(powerMon, tc, " Liczba E.C & C.B " .. separator, true, offsetPos, 11)
  262. enu.appendString(powerMon, color_reading, (enu.dot(couMJM)), false, pwrX_Reading, 11)
  263.  
  264. end
  265.  
  266. function dispMach()
  267. machineDispStart = 2 -- machineDisplayXPos
  268. for i=1, #machines do
  269. local m
  270. for m=1, #supported_Machines do
  271. if string.find(machines[i], supported_Machines[m]) then
  272. periph = peripheral.wrap(machines[i])
  273. if string.find(machines[i], "powered_furnace") or string.find(machines[i], "pulverizer") or string.find(machines[i], "sawmill") or string.find(machines[i], "induction_smelter") then
  274. itemStackUsed = periph.getStackInSlot(teItemInput)
  275. elseif string.find(machines[i], "automatic_macerator") or string.find(machines[i], "automatic_compressor") or string.find(machines[i], "automatic_extractor") or string.find(machines[i], "plate_bending_machine") or string.find(machines[i], "assembling_machine") then
  276. itemStackUsed = periph.getStackInSlot(gtItemInput)
  277. elseif string.find(machines[i], "industrial_grinder") or string.find(machines[i], "industrial_blast_furnace")then
  278. itemStackUsed = periph.getStackInSlot(gtItemInd)
  279. else
  280. itemStackUsed = periph.getStackInSlot(ic2ItemUsed)
  281. end
  282. machineDispStart = machineDispStart + 1
  283.  
  284. if itemStackUsed ~= nil then
  285. itemName = enu.itemRename(itemStackUsed.name)
  286. -- timer[2] = os.clock()
  287. enu.appendString(machMon, color_ores, itemName, true, orePos, machineDispStart)
  288. str = (pFormat(peripheral.getType(machines[i])))
  289. enu.appendString(machMon, tc, str, false, offsetPos, machineDispStart)
  290. enu.appendString(machMon, color_active, activeMsg, false, mStatusPos, machineDispStart)
  291.  
  292. elseif itemStackUsed == nil then
  293. enu.appendString(machMon, color_inactive, inactiveMsg, true, mStatusPos, machineDispStart)
  294. str = (pFormat(peripheral.getType(machines[i])))
  295. enu.appendString(machMon, tc, str, false, offsetPos, machineDispStart)
  296. else
  297.  
  298. end
  299. end
  300. end
  301. end
  302. end
  303. enu.cString(offsetPos, 1, hc, tankMon, "-- RailCraft Tank Info --")
  304. enu.cString(offsetPos, 1, hc, AEMon, "-- AE INFO --")
  305. enu.cString(offsetPos, 1, hc, powerMon, "-- POWER INFO--")
  306. -- Start
  307. while true do
  308. mon4.clear()
  309. enu.cString(offsetPos, machinesInfoCol, hc, machMon, "-- MASZYNY INFO --")
  310. upMachines(false)
  311.  
  312. dispAE()
  313. dispTanks()
  314. dispPower()
  315. dispMach()
  316. sleep(sleepTime)
  317. end
Advertisement
Add Comment
Please, Sign In to add comment