endminecraffter

reactorcontroll

Aug 9th, 2018 (edited)
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.03 KB | None | 0 0
  1. --##################--
  2. -- Programm von endminecraffter
  3. -- https://pastebin.com/u/endminecraffter
  4. -- Server: MyFTB.de Deutsches Minecraft modded Netzwerk
  5. -- Benoetigte Mods/Apis: API Button(uhw8NuF3)
  6. --##################--
  7.    
  8. function wrapPs(peripheralName)
  9. periTab={}
  10. sideTab={}
  11. if peripheralName==nil then
  12. print("Fehler")
  13. end
  14. local peripherals = peripheral.getNames()
  15. local i2 = 1
  16. for i =1, #peripherals do
  17. if peripheral.getType(peripherals[i])==peripheralName then
  18. periTab[i2]=peripheral.wrap(peripherals[i])
  19. sideTab[i2]=peripherals[i]
  20. i2=i2+1
  21. end
  22. end
  23. if periTab~={} then
  24. return periTab,sideTab
  25. else
  26. return nil
  27. end
  28. end
  29.                  
  30. r = wrapPs("BigReactors-Reactor")[1]
  31. os.loadAPI("Button")
  32. local t = Button.new("back")
  33. mon = peripheral.wrap("back")
  34.  
  35.  
  36. function buttons()
  37. local active = r.getActive()
  38. if active == true then
  39. t:add("off/on",nil,5,5,12,7,colors.lime,colors.red)
  40. else if active == false then
  41. t:add("off/on",nil,5,5,12,7,colors.red,colors.lime)
  42. end
  43. end
  44. t:add("-5",nil,36,5,40,7,colors.red,colors.red)
  45. t:add("+5",nil,42,5,46,7,colors.lime,colors.lime)
  46. t:draw()
  47.  
  48. end
  49.  
  50. function monitor()
  51. mon.setBackgroundColor(colors.black)
  52. mon.setTextScale(1.2)
  53. mon.setCursorPos(16,1)
  54. mon.write("endreactorControll")
  55. mon.setTextScale(1)
  56. mon.setCursorPos(40,4)
  57. mon.write("Rods")
  58. end
  59.  
  60. function eventActive()
  61. local active = r.getActive()
  62. if active == false then
  63. activateR(true)
  64. else if active == true then
  65. activateR(false)
  66. end
  67. end
  68. end
  69.  
  70. function eventRodh(zahl)
  71. local rods = r.getControlRodLevel(1)
  72. local plusrod = r.getControlRodLevel(1)+zahl
  73. if rods == 100 then
  74. write("Rods auf 100!")
  75. else
  76. r.setAllControlRodLevels(plusrod)
  77. end
  78. end
  79.  
  80.  
  81.  
  82. function getFuel()
  83. local fuel = r.getFuelAmount()
  84. local maxfuel = r.getFuelAmountMax()
  85. return math.floor((fuel/maxfuel)*100)
  86. end
  87.  
  88. function getEnergy()
  89. local amount = r.getEnergyStored()
  90. return math.floor((amount/10000000)*100)
  91. end
  92.  
  93. function getRodLevel()
  94. local rod = r.getControlRodLevel(1)
  95. return rod
  96. end
  97.  
  98. function getRActive()
  99.  
  100. local active = r.getActive()
  101. if active == false then
  102. return "Nein"
  103. else
  104. return "ja"
  105. end
  106. end
  107.  
  108. function eventRodr(zahl)
  109. local rods = r.getControlRodLevel(1)
  110. local minusrod = r.getControlRodLevel(1)-zahl
  111. if rods == 0 then
  112. write("Rods auf 0!")
  113. else
  114. r.setAllControlRodLevels(minusrod)
  115. end
  116. end
  117.  
  118. function activateR(bool)
  119. if bool == false then
  120. r.setActive(false)
  121. else if bool == true then
  122. r.setActive(true)
  123. else
  124. write("activeR(bool) bool muss ein Boolean sein(true,false)")
  125. end
  126. end
  127. end
  128.  
  129. buttons()
  130. monitor()
  131.  
  132. while true do
  133.     local event, p1 = t:handleEvents(os.pullEvent())
  134.         if event == "button_click" then
  135.            if p1 == "off/on" then
  136.         t:toggleButton(p1)
  137.         eventActive()
  138.         monitor()
  139.            else if p1 == "-5" then
  140.            monitor()
  141.            t:flash(p1)
  142.            eventRodr(5)
  143.            monitor()
  144.            else if p1 == "+5" then
  145.            monitor()
  146.            t:flash(p1)
  147.            eventRodh(5)
  148.            monitor()
  149.     end
  150. end
  151. end
  152. end
  153. end
Add Comment
Please, Sign In to add comment