Advertisement
sasaa86

Sky Factory 2.4 - Computercraft Solar script

Aug 22nd, 2017
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.18 KB | None | 0 0
  1. -- Script i used in minecraft modpack Skyfactory 2.4
  2. -- simply place 4 solar generator from extra utilities around a pc en start the script
  3. -- when the solars are full of power the pc wil apply a redstone signal to the corrensponding side
  4. -- to enable the discharging mode. and when empty will begin to fill up again.
  5. -- working on a sensor on the top of the pc to drain the solars when its night time.
  6.  
  7. local debug = false -- will turn on debug feedback on screen
  8.  
  9. while true do
  10.     for a,v in pairs(rs.getSides()) do
  11.         if debug  then
  12.             print("found ".. peripheral.getType(v) .. "on the " .. v)   -- easy for new types of machines
  13.         end
  14.         if peripheral.getType(v) == "extrautils_generatorsolar" then
  15.             local solar = peripheral.wrap(v)
  16.             if solar.getEnergyStored() == solar.getMaxEnergyStored() then   -- when full enable redstone signal
  17.                 if debug then
  18.                     print(v.." solar = discharging")        -- Display debug info
  19.                 end
  20.                 rs.setOutput(v, true)
  21.             end
  22.             if solar.getEnergyStored() == 0 then                -- when empty disable redstone signal
  23.                 if debug then
  24.                     print(v.." solar = charging")           -- Display debug info
  25.                 end
  26.                 rs.setOutput(v, false)
  27.             end
  28.         end
  29.     end
  30.     sleep(1)
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement