This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
camadas's profile picture

Problem on peripheral.find

Started by camadas, 20 January 2016 - 06:30 AM
camadas #1
Posted 20 January 2016 - 07:30 AM
Hey guys the code is this:


capa = peripheral.find("tile_blockcapacitorbank_name")
reactor = peripheral.find("BigReactors-Reactor")

-- Num of capacitors
local maxCapacitor = 15
-- Max energy stored by Capacitors
local maxEnergy = capa.getMaxEnergyStored() * maxCapacitor

-- Turn on at
local turnOnAt = 50
-- Turn off at (Not use 100)
local turnOffAt = 90

local manual = false

while true do
  energyStored = capa.getEnergyStored() * maxCapacitor
  energyPerc = math.floor((energyStored / maxEnergy) * 100)
  print(energyPerc)
  if energyPerc <= turnOnAt then
    reactor.setActive(true)
    print("Activating the reactor")
  elseif energyPerc >= turnOffAt then
    if reactor.getActive() then   
	  print("Deactivating the reactor")
	  reactor.setActive(false)
    end
  end
  sleep(10)
end

It was working properly whitout any problem, until by mistake I did destroy the Capacitor modem that is attached to the openperipheral, so the name did go from "tile_blockcapacitorbank_name_0" to "tile_blockcapacitorbank_name_1" now I get an error every time on the line 7 ?!

Rly don't understand the problem here :/
Bomb Bloke #2
Posted 20 January 2016 - 08:35 AM
And the error is…?

Double check that you correctly reconnected the cabling between the computer and the capacitor.
Lupus590 #3
Posted 20 January 2016 - 09:09 AM
Double check that you correctly reconnected the cabling between the computer and the capacitor.

the modem on the capacitor should have a red ring square light