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

BigReactors Turbine 1.7.10

Started by AceScottie, 09 June 2016 - 05:41 PM
AceScottie #1
Posted 09 June 2016 - 07:41 PM
Hey, im having a problem and i have no idea why, From looking at the reference http://ftbwiki.org/Turbine_Computer_Port along with some examples i found online i wanted to make a really simple and automated script.

I ran into a problem with getRotorSpeed

Current Code

t= peripheral.find("BigReactors-Turbine")
active = getActive
if active == True then
    print("is active")
else
    print("not active)
end
tRPM = getRotorSpeed
print(tRPM)

I keep getting an error with print(tRPM) not printing anything and with any of the below trials being a nil value

I have tried t.getRotorSpeed, t.getRotorSpeed, t.getRotorSpeed() and getRotorSpeed()

Additionally, using "getActive" works fine, using getActive() or t.getActive errors.
Dog #2
Posted 09 June 2016 - 08:04 PM
Once you've wrapped a peripheral, you need to reference it when making your calls, like so…

local t = peripheral.find("BigReactors-Turbine")
local active = t.getActive()

Note the t. (tee dot) so you're referencing your wrapped peripheral and the brackets at the end so you're calling the function for that peripheral. Without fixing that, your variable active will always be false since getActive, on its own, is not defined anywhere.

The same thing needs to be fixed with your attempt to call getRotorSpeed. It should be…

local tRPM = t.getRotorSpeed()

You'll also notice that I localized your variables - this keeps the values within the scope of your program. Local variables are faster and don't pollute the global environment which can lead to problems down the line. You can read about and scope here and here.

If you continue to get errors when calling t.getActive() or t.getRotorSpeed() then post the exact error message you're getting. The problem will probably be that either your turbine isn't being found or that one or both of those methods aren't available for calling with the version you're using.
Edited on 09 June 2016 - 06:09 PM
AceScottie #3
Posted 09 June 2016 - 09:20 PM
Hi Thanks for the info, i realised i made a few mistakes when watching a tutorial. I didnt rightclick the modems first (that got glossed over somewhere). But once i did that and used local variables i managed to get it up and running :)/>

im native to python where you have to specify global variables and not local ones :)/>