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

Big Reactor Control + Monitor?

Started by Thrisk, 07 August 2014 - 03:30 AM
Thrisk #1
Posted 07 August 2014 - 05:30 AM
I have been working on these scrips I found online to get them working but i keep getting this error (peripheral:74:Too long without yielding)
I am using the big reactors mod with this – http://big-reactors.com/cc_api.html

http://pastebin.com/JG7vSE8v – this scrip uses FC_API

FC_API – http://pastebin.com/A9hcbZWe

I know the problem is that i have infinite loops but i cant seem to fix this… I have tried adding sleep(0) but i cant seem to do this right. The current links have little changes I made but this is as far as I could get. I am fairly new to computercraft and lua that is why i figured I could find help here.I would really appreciate any help.
kornichen #2
Posted 08 August 2014 - 08:42 PM
Did you tried to use sleep(0.1) instead of sleep(0)?
Another problem might be an emulator. I was once using an emulator which broke loops every time I ran programs.
TheOddByte #3
Posted 09 August 2014 - 12:21 AM
Did you tried to use sleep(0.1) instead of sleep(0)?
Can't see how that would change anything, when putting in 0 the time will be changed to 0.015 which is the minium.

Another problem might be an emulator. I was once using an emulator which broke loops every time I ran programs.
I don't think there are any emulators that support peripherals atm.


Now onto the error, I believe this may be your problem but I'm not entirely sure

function main()
    while not finished do
        FC_API.clearMonitor("Reactor Control")
        reactorStatus()
        if reactor.getConnected() then
            if reactor.getActive() then
                calculateEfficiency()
                calculateFuelDuration()
            end
            displayBars()
            Options()
            save()
            sleep(loopTime)
        end
    end
end
As I said, I'm not sure but there is a chance that you put the sleep in the wrong place there, since it will only sleep if reactor.getConnected() returns true.
So I suggest you try moving it out of the if statement and see if that fixes anything
Thrisk #4
Posted 11 August 2014 - 04:46 AM

function main()
	while not finished do
		FC_API.clearMonitor("Reactor Control")
		reactorStatus()
		if reactor.getConnected() then
			if reactor.getActive() then
				calculateEfficiency()
				calculateFuelDuration()
			end
			displayBars()
			Options()
			save()
			sleep(loopTime)
		end
	end
end
As I said, I'm not sure but there is a chance that you put the sleep in the wrong place there, since it will only sleep if reactor.getConnected() returns true.
So I suggest you try moving it out of the if statement and see if that fixes anything


I have been working to get a better understanding of lua but i will try this. The reactor.getConnected does come back true so I don't think this is the problem.
Every time i run the program it prints "Online" thus telling me its connected.
Thrisk #5
Posted 11 August 2014 - 06:04 AM
I have started working on my own little project.I am testing out the Big Reactor methods.
At the moment I am stuck on the "getControlRodName".. I don't understand how to get this working.I have this down but it wont work.

local r = peripheral.warp("BigReactors-Reactor_1")
r.getControlRodName(i)
print(i)

This method can be found here : http://big-reactors.com/cc_api.html

The error is : Test:2: Invalid argument 0,expected Number
Any Idea on how to fix this?
natedogith1 #6
Posted 11 August 2014 - 08:30 AM
Did you define 'i' anywhere?
Thrisk #7
Posted 11 August 2014 - 04:39 PM
Did you define 'i' anywhere?

I expected i to be defined then printed after it got the control rod name.
I have 24 control rods and I'm trying to get a name of 1 of them. I have named one "check" but i cannot get the computer to find a certain rod.. and i think im diong something wrong.
Lyqyd #8
Posted 11 August 2014 - 04:45 PM
Things don't magically become defined. You have to set a value to i in order for it to have a value. In this case, you probably want to use a for loop to iterate over the number of rods and check their names against the rod you're looking for, then set a variable with the number of that rod and break the loop if you find it.
Thrisk #9
Posted 11 August 2014 - 05:19 PM
Things don't magically become defined. You have to set a value to i in order for it to have a value. In this case, you probably want to use a for loop to iterate over the number of rods and check their names against the rod you're looking for, then set a variable with the number of that rod and break the loop if you find it.

I have found the value of "i"…Thanks!