osmarks

basenet lens of the miner controller

May 8th, 2020
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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 reconstructor_side = settings.get "basenet.reconstructor_side"
  4. local recon = peripheral.wrap(reconstructor_side)
  5. local cell = settings.get "basenet.energy_cell" or "main_energy_cell"
  6.  
  7. local energy_low
  8. basenet.listen(function(data)
  9.     energy_low = data.low
  10. end, cell)
  11.  
  12. local function pulse(side)
  13.     rs.setOutput(side, true)
  14.     sleep(0.1)
  15.     rs.setOutput(side, false)
  16. end
  17.  
  18. basenet.run_task(function()
  19.     while true do
  20.         if not energy_low and (recon.getEnergyStored() / recon.getEnergyCapacity() > 0.8) then
  21.             pulse(reconstructor_side)
  22.         end
  23.         sleep(0.1)
  24.     end
  25. end)
  26.  
  27. basenet.run()
Add Comment
Please, Sign In to add comment