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

Thermal Expansion - Bigs Reactor

Started by LordSoft, 29 March 2015 - 09:48 AM
LordSoft #1
Posted 29 March 2015 - 11:48 AM
Hi

I use ComputerCraft to enable or disable my Reactor when my energy is full but there is always a problem.

The Error :reactor:9: attempt to perform arithmetic__div on nil and nil
The Program: http://pastebin.com/npnHPn02

waiting for a answer,
LordSoft
Bomb Bloke #2
Posted 29 March 2015 - 11:20 PM
Quite simply, on the ninth line you're trying to divide an undefined value by an undefined value. The Lua interpreter therefore goes "huh?" and errors at you.

  level = cellOneEnergyStored/CellOneMaxEnergy*100

"cellOneEnergyStored" is never referenced anywhere else in the script. You probably meant to use something along the lines of cellOne.getEnergyStored(), or whatever the function is…

"CellOneMaxEnergy" is likely supposed to refer to "cellOneMaxEnergy", which you defined on line 5. Capitalisation matters, and so the two different labels are not the same.