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

Coroutine and os.run

Started by Pinkishu, 13 August 2012 - 02:19 AM
Pinkishu #1
Posted 13 August 2012 - 04:19 AM
Hi there, ran into a little problem with coroutines:



local function host(path,...)
print("S")
local p1,p2=os.run( _G, path, unpack(arg))
print("E")
end

local co = coroutine.create(host)
coroutine.resume(co,"mtshell")
print(coroutine.status(co))

this does not run the file. the "S" gets printed the "E" does not and the coroutine status winds up being "dead".
Any ideas?
BigSHinyToys #2
Posted 13 August 2012 - 05:04 AM
you cant run it in _G environment make a new one for the running program example

local function host(path,...)
    print("S")
    local p1,p2=os.run( {}, path, unpack(arg))
    print("E")
end
local co = coroutine.create(host)
coroutine.resume(co,"mtshell")
print(coroutine.status(co))
Pinkishu #3
Posted 13 August 2012 - 01:21 PM
Ah ok :> thanks