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

Should Be Yeilding Plenty , But Still Complains

Started by etopsirhc, 23 January 2013 - 06:18 PM
etopsirhc #1
Posted 23 January 2013 - 07:18 PM
ok so i've got this program that reads from a massive file and places a block as the coords ( line seporated ) every 50 times though the main loop the program sleeps for 5 seconds . it also uses an api / metatable i made to go to the positions as well as every 100 moves it will stop and take 5 again. so how am i supposed to fix this?

build: http://pastebin.com/7775XCcd
move: http://pastebin.com/phvtGG88

incase you want to test it with the file used in the build
https://dl.dropbox.com/u/47442169/ragnarok.coords
Doyle3694 #2
Posted 23 January 2013 - 09:14 PM
make all os.sleep() sleep(), and check if the same problem still exists.

Why does people even use term.write(), os.sleep(), and io.read()?
LBPHacker #3
Posted 23 January 2013 - 09:21 PM
First of all:


function writeLine()
  lw = fs.open("line.presist","w")
  lw.write(lineNum)
  lw.flush()
  lw.close()
end

"attempt to index ? (a nil value)" ? That's because lw does not have a .flush method. (This is not io, this is fs.)


And use the "local" keyword sometimes - It's not in Lua for decoration.
ChunLing #4
Posted 23 January 2013 - 10:44 PM
Where did you put the move API? If you have it loaded in your rom/apis folder, then it's probably being loaded before the turtle API loads. This causes your move API to use the java versions of the turtle functions, which do not yield.

Nearly all turtle functions (except the getters, which return instantly) are supposed to yield.
etopsirhc #5
Posted 23 January 2013 - 11:07 PM
@ chung
its in the root directory right next to the build program.

@LPB
i would if i ever planned on distributing as a finished product , but as is its just a tool for me to use :P/>

@doyle
ok , changed that and am testing it now. as i'm gonna crash soon i'll let that run over night and see how far it got
ChunLing #6
Posted 24 January 2013 - 08:50 AM
Okay, is the turtle moving about and placing prior to stopping for failure to yield? Or is it just sitting there, not moving or turning or placing or doing anything visible (outside the console) for the twenty seconds prior to being stopped?
etopsirhc #7
Posted 24 January 2013 - 10:22 AM
well so far no hang ups with the newest version
but even after removing the flush statement i cant get the writeLine() to work XP

added a clause to attack a mob if its in the way , and a shorter limit to start a break. between the 2 it seems fixed