Posted 15 March 2013 - 02:44 AM
Hello there,
i'm using computercraft and lua for about a week now and i'm starting to use coroutines.
a simple version of the problem i encountered:
mylib
runMe
Now the problem i got is a not working Job Function.
The uplink perfectly fine uses his method every second, but the turtle only turns left once.
Well i did seek for an answer before and apartently turtle.turnLeft() does wait for an event to happen - obviously to determine if it turned or not.
Passing TEvents to the coroutine didnt work aswell, altough it looked like it worked in a forumpost for basically the same problem.
Any suggestions what i'm doing wrong?
i'm using computercraft and lua for about a week now and i'm starting to use coroutines.
a simple version of the problem i encountered:
mylib
function setup(job)
-- do stuff
work = coroutine.create(job)
--do more stuff
while true do
local TEvents = {os.pullEvent() }
coroutine.resume(work, unpack (TEvents) )
Uplink() --a funktion working perfectly fine
sleep(1)
end
end
runMe
os.loadAPI(mylib)
function job()
while true do
sleep(0.1)
turtle.turnLeft()
end
end
lib.setup(job)
Now the problem i got is a not working Job Function.
The uplink perfectly fine uses his method every second, but the turtle only turns left once.
Well i did seek for an answer before and apartently turtle.turnLeft() does wait for an event to happen - obviously to determine if it turned or not.
Passing TEvents to the coroutine didnt work aswell, altough it looked like it worked in a forumpost for basically the same problem.
Any suggestions what i'm doing wrong?