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

attempt to call table error

Started by koyetsu, 14 August 2015 - 06:05 PM
koyetsu #1
Posted 14 August 2015 - 08:05 PM
Aim of the program:
I am attempting to monitor a capacitor bank and based on it's energy levels activate or deactivate multible turbines/reactors.

First I check the state of the capacitor bank (posting basic info to the terminal) next I pull the turbines, check their speed and based on that turn on the turbines, then based on the state passed from the capacitors it either activates or deactivates the inductor coils. after this step i check the reactors and if the turbine is active or the inductors are on the reactor gets turned on.

Problem:
first time through the program does EXACTLY what i want. on the second loop it errors out with the error

turbine:106: attempt to call table

code:
http://pastebin.com/sPgFqDT5

Ive reset the terminal with ctrl-r and changed variable and function names as the 2 possible problems i saw were overwritten variable and possible variable corruption in the vm.

what i don't understand is why it works once but then errors out.

i'm using the FTB Infinity 1.10.1 pack which include computercraft 1.74 and BigReactors 0.4.3A
and yes i know my code is ugly
Anavrins #2
Posted 14 August 2015 - 11:29 PM
You have to change your variables name, you have both a function and a table named "reactor".
Edited on 14 August 2015 - 09:30 PM
Bomb Bloke #3
Posted 15 August 2015 - 12:53 AM
what i don't understand is why it works once but then errors out.

Because the "reactor" function itself is what's overwriting the "reactor" variable with a table pointer, instead of a function pointer. There isn't a problem until you've executed that function at least once.
koyetsu #4
Posted 15 August 2015 - 02:27 AM
Thanks guys something simple stupid that's me! fixed it and it's working perfectly now