View difference between Paste ID: QwfhDHmE and yqeLEAwi
SHOW: | | - or go back to the newest paste.
1
local component, computer = component, computer
2
if require then component = require "component" computer = require "computer" end
3
local wlan = component.proxy(component.list "modem"())
4
local computer_peripheral = component.proxy(component.list "computer"())
5
local reactor = component.proxy(component.list "nc_fusion_reactor"())
6
local gpu = component.proxy(component.list "gpu"())
7
local screen = component.list "screen"()
8
gpu.bind(screen)
9
wlan.setWakeMessage("poweron", true)
10
11
local function display(txt)
12-
local function try_power_on(comp)
12+
	local w, h = gpu.getResolution()
13-
	local p = component.proxy(comp)
13+
	gpu.set(1, 1, txt .. (" "):rep(w - #txt))
14-
	if p.isOn and p.turnOn then
14+
15-
		if not p.isOn() then
15+
16-
			p.turnOn()
16+
17-
			computer_peripheral.beep(440)
17+
18-
		end
18+
19
		computer.pullSignal(deadline - computer.uptime())
20-
	if p.isRunning and p.start then
20+
21-
		if not p.isRunning() then
21+
22-
			p.start()
22+
23-
			computer_peripheral.beep(800)
23+
computer_peripheral.beep(400)
24-
		end
24+
display "Initialized"
25
26
local NC_HEAT_CONSTANT = 1218.76
27
28
local last = nil
29-
	for addr in component.list "turtle" do try_power_on(addr) end
29+
30-
	for addr in component.list "computer" do try_power_on(addr) end
30+
31-
	sleep(1)
31+
	local target_temp = reactor.getFusionComboHeatVariable() * NC_HEAT_CONSTANT * 1000
32
	local temp = reactor.getTemperature()
33
	display(("%f %f"):format(temp / target_temp, reactor.getEfficiency()))
34
	local too_high = temp > target_temp
35
	if too_high then
36
		if too_high ~= last then computer_peripheral.beep(800) end
37
		reactor.deactivate()
38
	else
39
		if too_high ~= last then computer_peripheral.beep(500) end
40
		reactor.activate()
41
	end
42
	last = too_high
43
	wlan.broadcast(1111, "poweron")
44
	sleep(0.5)
45
end