View difference between Paste ID: t8JqE1S9 and JQyHApH8
SHOW: | | - or go back to the newest paste.
1
local basenet;do local function b()local c,d=http.get"https://pastebin.com/raw/QnFKq9pE"if not c then return false,d end;local e=c.readAll()local f,d=load(e)if not f then return false,d end;return pcall(f)end;for g=0,8 do local h,i=b()if not h then printError(i)sleep(math.pow(2,g))else basenet=i;break end end end
2
3-
local reactor_side = settings.get "basenet.reactor_side"
3+
local reconstructor_side = settings.get "basenet.reconstructor_side"
4-
local reactor = peripheral.wrap(reactor_side)
4+
local recon = peripheral.wrap(reconstructor_side)
5
local cell = settings.get "basenet.energy_cell" or "main_energy_cell"
6-
local low_threshold = settings.get "basenet.low_threshold"
6+
7
local energy_low
8-
local low
8+
9
	energy_low = data.low
10-
	low = data.low
10+
11-
	if low == nil then low = data.level < 0.9 end
11+
12-
	if low_threshold then low = data.level < low_threshold end
12+
local function pulse(side)
13-
	print(low, data.level)
13+
	rs.setOutput(side, true)
14-
	rs.setOutput(reactor_side, low)
14+
	sleep(0.1)
15
	rs.setOutput(side, false)
16
end
17-
basenet.interval(function()
17+
18-
	local item = reactor.getItemMeta(1)
18+
basenet.run_task(function()
19-
	local fcount, ftype = 0, nil
19+
	while true do
20-
	if item then fcount = item.count ftype = item.displayName end
20+
		if not energy_low and (recon.getEnergyStored() / recon.getEnergyCapacity() > 0.8) then
21-
	basenet.update { running = low, fuel_available = fcount, fuel_type = ftype }
21+
			pulse(reconstructor_side)
22-
end, 1)
22+
		end
23
		sleep(0.1)
24
	end
25
end)
26
27
basenet.run()