View difference between Paste ID: BjWs4s0C and zExpUjiu
SHOW: | | - or go back to the newest paste.
1
local capacitor = peripheral.wrap("front")
2
local maxEnergy = capacitor.getMaxEnergyStored()
3
local startLimit = 0.10
4
local endLimit = 0.90
5
6
local function power_less(amount)
7
  local currentEnergy = capacitor.getEnergyStored()
8
  local percent = currentEnergy / maxEnergy
9
10-
  print(percent, " < ", amount, " == ", percent < amount)
10+
  --print(percent, " < ", amount, " == ", percent < amount)
11
12
  return percent < amount
13
end
14
15
while true do
16
  if power_less(startLimit) then
17
    rs.setOutput("bottom", true)
18-
    print("on")
18+
    print("Regulator ENABLED, charging Capacitor Bank")
19
20
    while power_less(endLimit) do
21
        sleep(1)
22-
        print("stuck at while")
22+
23
24
    rs.setOutput("bottom", false)
25
    print("Regulator DISABLED, entering Sleep Mode")
26-
    print("off")
26+
27
28
  sleep(1)
29
end