Posted 01 March 2013 - 06:45 PM
I'm trying to create a mining program. when I was using turtle function within a coroutine function, I found that the turtle function is not working.
Then I create a simple code to test it:
The output is:
If I comment turtle functions. the output will be "1 2 3 4" as what I expected.
Is that means I cannot use turtle functions inside coroutine?
Then I create a simple code to test it:
local func = coroutine.create(function()
print("1")
turtle.turnRight()
print("2")
coroutine.yield()
print("3")
turtle.up()
print("4")
coroutine.yield()
print("5")
turtle.down()
end)
local function s()
print(coroutine.status(func))
coroutine.resume(func)
print(coroutine.status(func))
coroutine.resume(func)
print(coroutine.status(func))
coroutine.resume(func)
print(coroutine.status(func))
end
s()
The output is:
1
suspended
suspended
suspended
dead
If I comment turtle functions. the output will be "1 2 3 4" as what I expected.
Is that means I cannot use turtle functions inside coroutine?