9 posts
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.htmlhttp://pastebin.com/JG7vSE8v – this scrip uses FC_API
FC_API –
http://pastebin.com/A9hcbZWeI 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.
235 posts
Location
Germany
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.
1852 posts
Location
Sweden
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
9 posts
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.
9 posts
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.htmlThe error is : Test:2: Invalid argument 0,expected Number
Any Idea on how to fix this?
108 posts
Posted 11 August 2014 - 08:30 AM
Did you define 'i' anywhere?
9 posts
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.
8543 posts
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.
9 posts
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!