osmarks

basenet reactor controller

May 8th, 2020
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.04 KB | None | 0 0
  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"
  4. local reactor = peripheral.wrap(reactor_side)
  5. local cell = settings.get "basenet.energy_cell" or "main_energy_cell"
  6. local low_threshold = settings.get "basenet.low_threshold"
  7.  
  8. local low
  9. basenet.listen(function(data)
  10.     low = data.low
  11.     if low == nil then low = data.level < 0.9 end
  12.     if low_threshold then low = data.level < low_threshold end
  13.     print(low, data.level)
  14.     rs.setOutput(reactor_side, low)
  15. end, cell)
  16.  
  17. basenet.interval(function()
  18.     local item = reactor.getItemMeta(1)
  19.     local fcount, ftype = 0, nil
  20.     if item then fcount = item.count ftype = item.displayName end
  21.     basenet.update { running = low, fuel_available = fcount, fuel_type = ftype }
  22. end, 1)
  23.  
  24. basenet.run()
Add Comment
Please, Sign In to add comment