Jump to content




Error: startup:5: attempt to call nil


  • You cannot reply to this topic
1 reply to this topic

#1 Miiscakes

  • New Members
  • 1 posts

Posted 18 March 2015 - 08:04 PM

Hi, i copied a program that i saw on youtube, but when im trying to start the program it said this error : "startup:5: attempt to call nil", in the movie, it's exactly the same program but it works ! Help me please :(

reactor = peripheral.wrap("back")
cell = peripheral.wrap("left")

actif = reactor.getActive()
maxCell = cube.getMaxEnergy()

while true do

energystore = cell.getStored()
level = (energystore*100)/maxCell

if actif then
if level >= 75 then reactor.setActive(false) end
else
if level <= 25 then reactor.setActive(true) end
end

sleep(1)

end

#2 HPWebcamAble

  • Members
  • 933 posts
  • LocationWeb Development

Posted 18 March 2015 - 11:08 PM

First, use code tags to make code look nicer:
[.code] [./code] (without the periods)

Now, line 5 is this:
maxCell = cube.getMaxEnergy()

'cube' is nil, so the line errors.

Above, I noticed you wrap a few peripherals
reactor = peripheral.wrap("back")
cell = peripheral.wrap("left")

Judging from the rest of the program, 'cube' should be 'cell'
maxCell = cell.getMaxEnergy() --# Just change cube to cell

Also, make sure you actually have the reactor on the back and the cell on the left
You can change the side name if need to move them





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users