WillaRL_

Example script for Mekanism Fusion Reactor

Dec 9th, 2020
1,100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.66 KB | None | 0 0
  1. --By Willa_/WillaRL_
  2.  
  3. local statsDisp = require("statisticDisplayAPI")
  4. local buttonAPI = require("buttonAPI")
  5. local component = require("component")
  6. local event = require("event")
  7. local thread = require("thread")
  8. local gpuAPI = require("gpuAPI")
  9. local gpu = component.gpu
  10. local reac = component.reactor_logic_adapter
  11.  
  12.  
  13. local barDisplays = statsDisp()
  14. local buttons = buttonAPI()
  15.  
  16.  
  17. function energyOut()
  18.   return (reac.getProducing()*0.4/1000000)
  19. end
  20.  
  21.  
  22. function injectRate()
  23.   return reac.getInjectionRate()
  24. end
  25.  
  26. function internalBuffer()
  27.   return (reac.getEnergy()*0.4)/1000000
  28. end
  29.  
  30. function minusInjRate()
  31.   reac.setInjectionRate(reac.getInjectionRate() - 1)
  32.   return true
  33. end
  34.  
  35. function addInjRate()
  36.   reac.setInjectionRate(reac.getInjectionRate() + 1)
  37.   return true
  38. end
  39.  
  40. function deutAmount()
  41.   return reac.getDeuterium()
  42. end
  43.  
  44. function tritAmount()
  45.   return reac.getTritium()
  46. end
  47.  
  48. function plasmaHeat()
  49.   return reac.getPlasmaHeat()/1000000000
  50. end
  51.  
  52. function caseHeat()
  53.   return reac.getCaseHeat()/1000000000
  54. end
  55.  
  56. function injectRateStr()
  57.   local rate = tostring(reac.getInjectionRate())
  58.   return rate
  59. end
  60.  
  61.  
  62.  
  63.  
  64. gpuAPI.clear(0x0F0F0F)
  65. gpuAPI.write(69, 5, 0x006D00, "Energy Production")
  66. gpuAPI.write(70, 15, 0x006D00, "Injection Rate")
  67. gpuAPI.fill(22,16,46,7, 0x878787)
  68. gpuAPI.write(16, 6, 0x990000, "Buffer")
  69. gpuAPI.write(41, 21, 0xFF2480, "Deuterium")
  70. gpuAPI.write(41,24, 0x00FF00, "Tritium")
  71. gpuAPI.write(54, 29, 0xFF6D00, "Plasma Heat")
  72. gpuAPI.write(90, 29, 0xFF6D00, "Case Heat")
  73. gpuAPI.fill(88,87,21,16, 0xFF0000)
  74.  
  75.  
  76.  
  77. barDisplays:addGraph(0, 114, 41, 10, 7, 0x000000, 0x009900, energyOut, 0, 18)
  78. barDisplays:addGraph(0, 114, 41, 20, 17, 0x000000, 0x009900, injectRate, 0, 150)
  79. barDisplays:addGraph(1, 21, 17, 45, 8, 0x000000, 0x009900, internalBuffer, 0, 400)
  80. barDisplays:addGraph(0, 114, 41, 23, 22, 0x000000, 0xFF2480, deutAmount, 0, 1000)
  81. barDisplays:addGraph(0, 114, 41, 26, 25, 0x000000, 0x00FF00, tritAmount, 0, 1000)
  82. barDisplays:addGraph(1, 61, 59, 44, 31, 0x000000, 0xFF6D00, plasmaHeat, 0, 15)
  83. barDisplays:addGraph(1, 96, 94, 44, 31, 0x000000, 0xFF6D00, caseHeat, 0, 10)
  84. barDisplays:addText(75, 16, 0x006D00, injectRateStr)
  85.  
  86.  
  87. buttons:add("-", 0, 39, 34, 20, 17, 0x696969, 0xB4B4B4, 0.1, minusInjRate)
  88. buttons:add("+", 0, 121, 116, 20, 17, 0x696969, 0xB4B4B4, 0.1, addInjRate)
  89.  
  90. --[[
  91. function temp()
  92. while true do
  93.   local _, _, x, y = event.pull("touch")
  94.   gpu.fill(x,y, 1, 1, "X")
  95.   print(x,y)
  96. end
  97. end
  98. thread.create(temp)
  99. --]]
  100.  
  101.  
  102. function buttonListener()
  103.   while true do
  104.     local _, _, x, y = event.pull("touch")
  105.     buttons:click(x,y)
  106.   end
  107. end
  108.  
  109. thread.create(buttonListener)
  110.  
  111.  
  112. barDisplays:start(1)
Advertisement
Add Comment
Please, Sign In to add comment