View difference between Paste ID: yn8XWLg6 and KjwASAn2
SHOW: | | - or go back to the newest paste.
1-
-- Reaktor- und Turbinenprogramm von Thor_s_Crafter --
1+
-- Reaktorprogramm (ohne Turbinen) --
2-
-- Version 2.3 --
2+
-- von Thor_s_Crafter --
3-
-- Reaktorkontrolle --
3+
4
local rodLevel = 0
5-
shell.run("cp /reactor-turbine-program/config/touchpoint.lua /touchpoint")
5+
local enPer = 0
6-
os.loadAPI("touchpoint")
6+
local enPerR = 0
7-
shell.run("rm touchpoint")
7+
local fuel = 0
8
local fuelPer = 0
9-
shell.run("cp /reactor-turbine-program/config/input.lua /input")
9+
local enOut = 0
10-
os.loadAPI("input")
10+
local fuelCons = 0
11-
shell.run("rm input")
11+
local isOn = false
12
local mon
13-
local page = touchpoint.new(touchpointLocation)
13+
local enCell
14-
local rodLevel
14+
local reactor
15-
local enPer
15+
16-
local fuel
16+
17-
local fuelPer
17+
function initPeripherals()
18-
local rfGen
18+
	local perList = peripheral.getNames()
19-
local fuelCons
19+
	for i=1,#perList,1 do
20-
local isOn
20+
		if peripheral.getType(perList[i]) == "monitor" then
21-
local enPerR
21+
			mon = peripheral.wrap(perList[i])
22-
local rOn
22+
		end
23-
local rOff
23+
		if peripheral.getType(perList[i]) == "tile_blockcapacitorbank_name" or peripheral.getType(perList[i]) == "tile_thermalexpansion_cell_basic_name" or peripheral.getType(perList[i]) == "tile_thermalexpansion_cell_hardened_name" or peripheral.getType(perList[i]) == "tile_thermalexpansion_cell_reinforced_name" or peripheral.getType(perList[i]) == "tile_thermalexpansion_cell_resonant_name" then
24-
local modeA
24+
			enCell = peripheral.wrap(perList[i])
25-
local modeM
25+
		end
26
		if peripheral.getType(perList[i]) == "BigReactors-Reactor" then
27-
function createButtons()
27+
			reactor = peripheral.wrap(perList[i])
28-
  if lang == "de" then
28+
  			--print("Reaktor gefunden!")
29-
    modeA = {" Automatisch ",label = "modeSwitch"}
29+
		end
30-
    modeM = {"  Manuell   ",label = "modeSwitch"}
30+
	end
31-
  elseif lang == "en" then
31+
32-
    modeA = {" Automatic ",label = "modeSwitch"}
32+
33-
    modeM = {"  Manual   ",label = "modeSwitch"}
33+
34-
  end
34+
	local en = enCell.getEnergyStored()
35
	local enMax = enCell.getMaxEnergyStored()
36-
  page:add("modeSwitch",switchMode,19,22,33,22)
36+
	return math.floor(en/enMax*100)
37-
  if overallMode == "auto" then
37+
38-
    page:rename("modeSwitch",modeA,true)
38+
39-
  elseif overallMode == "manual" then
39+
40-
    page:rename("modeSwitch",modeM,true)
40+
	rodLevel = reactor.getControlRodLevel(1)
41-
  end
41+
	enPer = getEnergy()
42-
  --In Deutsch
42+
	enPerR = reactor.getEnergyStored()
43-
  if lang == "de" then
43+
	fuel = reactor.getFuelAmount()
44-
    page:add("Neu starten",restart,2,18,17,18)
44+
	local fuelMax = reactor.getFuelAmountMax()
45-
    page:add("Optionen",function() run("/reactor-turbine-program/program/editOptions.lua") end,2,20,17,20)
45+
	fuelPer = math.floor(fuel/fuelMax*100)
46-
    page:add("Hauptmenue",function() run("/reactor-turbine-program/start/menu.lua") end,2,22,17,22)
46+
	enOut = reactor.getEnergyProducedLastTick()
47-
    --In Englisch
47+
	fuelCons = reactor.getFuelConsumedLastTick()
48-
  elseif lang == "en" then
48+
	isOn = reactor.getActive()
49-
    page:add("Reboot",restart,2,18,17,18)
49+
50-
    page:add("Options",function() run("/reactor-turbine-program/program/editOptions.lua") end,2,20,17,20)
50+
51-
    page:add("Main Menu",function() run("/reactor-turbine-program/start/menu.lua") end,2,22,17,22)
51+
function displayData()
52-
  end
52+
	term.clear()
53-
  page:draw()
53+
	term.setCursorPos(1,1)
54
	getReactorData()
55
	print("RodLevel: "..rodLevel)
56-
function createButtonsMan()
56+
	print("Energie: "..enPer.."%")
57-
  createButtons()
57+
	print("Energie (Reaktor): "..enPerR.."RF")
58-
  if lang == "de" then
58+
	print("Fuel: "..fuel.."mb")
59-
    rOn = {" Ein ",label = "reactorOn"}
59+
	print("Fuel: "..fuelPer.."%")
60-
    rOff = {" Aus ",label = "reactorOn"}
60+
	print("Energie-Produktion: "..enOut.."RF/t")
61-
  elseif lang == "en" then
61+
	print("Verbrauch: "..fuelCons.."mb/t")
62-
    rOn = {" On ",label = "reactorOn"}
62+
	write("Reaktor an: ")
63-
    rOff = {" Off ",label = "reactorOn"}
63+
  if isOn == true then print("ja")
64-
  end
64+
  else print("nein") end
65-
  page:add("reactorOn",toggleReactor,11,10,15,10)
65+
	--sleep(1)
66-
  if r.getActive() then
66+
67-
    page:rename("reactorOn",rOn,true)
67+
68-
    page:toggleButton("reactorOn")
68+
function displayDataOnScreen()
69-
  else
69+
	--mon.clear()
70-
    page:rename("reactorOn",rOff,true)
70+
	mon.setCursorPos(1,1)
71-
  end
71+
	mon.write("Energie: "..enPer.."%   ")
72-
  page:draw()
72+
	mon.setCursorPos(1,2)
73
	mon.write("Energie (Reaktor): "..enPerR.."RF   ")
74
	mon.setCursorPos(1,4)
75-
function checkPeripherals()
75+
	mon.write("Reaktor an: ")
76-
  mon.setBackgroundColor(colors.black)
76+
   if isOn == true then mon.write("ja    ")
77-
  mon.clear()
77+
   else mon.write("nein   ") end
78-
  mon.setCursorPos(1,1)
78+
   mon.setCursorPos(1,5)
79-
  mon.setTextColor(colors.red)
79+
	mon.write("Fuel: "..fuel.."mb   ")
80-
  term.clear()
80+
	mon.setCursorPos(1,6)
81-
  term.setCursorPos(1,1)
81+
	mon.write("in Prozent: "..fuelPer.."%")
82-
  term.setTextColor(colors.red)
82+
	mon.setCursorPos(1,8)
83-
  if r == "" then
83+
	mon.write("Energie-Produktion: "..math.floor(enOut).."RF/t    ")
84-
    if lang == "de" then
84+
	mon.setCursorPos(1,9)
85-
      mon.write("Reaktor nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
85+
	mon.write("Verbrauch: ")
86-
      error("Reaktor nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
86+
	local fuelCons2 = tostring(fuelCons)
87-
    elseif lang == "en" then
87+
	local fuelCons3 = string.sub(fuelCons2,0,4)
88-
      mon.write("Reactor not found! Please check and reboot the computer (Press and hold Ctrl+R)")
88+
	mon.write(fuelCons3)
89-
      error("Reactor not found! Please check and reboot the computer (Press and hold Ctrl+R)")
89+
	mon.write("mb/t    ")
90-
    end
90+
91-
  end
91+
92-
  if v == "" then
92+
93-
    if lang == "de" then
93+
initPeripherals()
94-
      mon.write("Energiezelle nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
94+
mon.setBackgroundColor(colors.blue)
95-
      error("Energiezelle nicht gefunden! Bitte pruefen und den Computer neu starten (Strg+R gedrueckt halten)")
95+
96-
    elseif lang == "en" then
96+
97-
      mon.write("Energy Cell not found! Please check and reboot the computer (Press and hold Ctrl+R)")
97+
	getReactorData()
98-
      error("Energy Cell not found! Please check and reboot the computer (Press and hold Ctrl+R)")
98+
	displayData()
99-
    end
99+
	displayDataOnScreen()
100-
  end
100+
	if fuelPer <= 30 then
101
		reactor.setActive(false)
102
	else
103-
--Schaltet den Reaktor um
103+
		if enPer <= 50 then
104-
function toggleReactor()
104+
			reactor.setActive(true)
105-
  r.setActive(not r.getActive())
105+
		elseif enPer > 90 then
106-
  page:toggleButton("reactorOn")
106+
			reactor.setActive(false)
107-
  if r.getActive() then
107+
		end
108-
    page:rename("reactorOn",rOn,true)
108+
	end
109-
  else
109+
	sleep(1)
110-
    page:rename("reactorOn",rOff,true)
110+