View difference between Paste ID: zExpUjiu and GkRW3RxM
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)
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")
19
20
    while power_less(endLimit) do
21
        sleep(1)
22
        print("stuck at while")
23
    end
24
25
    rs.setOutput("bottom", false)
26
    print("off")
27
  end
28
29
  sleep(1)
30
end