Im trying to make an window-based OS and this is the start
This gonna hava a lot of more features
Edit: read belowIm having an error when i run my program PASTEBIN it gives me that error
shell.run("pastebin", "get", "SUW8cq9j", "goroutine")
shell.run("pastebin", "get", "fU9Kj9zr", "redirect")
if not fs.exists("goroutine") then
shell.run("pastebin", "get", "SUW8cq9j", "goroutine")
shell.run("pastebin", "get", "fU9Kj9zr", "redirect")
end
os.loadAPI("goroutine")
os.loadAPI("redirect")
That way you're handling the API stuff all at once.shell.run does not work as if you were typing something into the shell, it takes arguments.
shell.run does not work as if you were typing something into the shell, it takes arguments.
Yes, it does. It did not do so previously, but it does now.
local function _spawn(name,method,redirect,parent,args)
if activeRoutines[name] then
return nil, "Couldn't spawn; a coroutine with that name already exists!"
end
local routine={name=name,co=coroutine.create(method),redirect={redirect}, parent=parent,children={}}
if routine.co==nil then
error("Failed to create coroutine '"..name.."'!")
end
parent.children[#parent.children+1]=routine --this is 182
activeRoutines[name]=routine
os.queueEvent("coroutine_start",name)
numActiveCoroutines=numActiveCoroutines+1
--run it a bit..
sendEventTo(routine,args)
return routine
end
function spawnWithRedirect(name,method,redirect,...)
return _spawn(name,method,redirect,running(),{...})
end
local function findCoroutine(co)
for _,routine in pairs(activeRoutines) do
if routine.co==co then
return routine
end
end
return nil
end
function findNamedCoroutine(name)
return activeRoutines[name]
end
function running()
return findCoroutine(coroutine.running())
end
As you can see, it is possible for running to return nil, and thus it is possible that parent is nil, and thus parent.children[letAloneThisNonesense] is an attempt to index a nil.Gopher….Your program calls goroutine.spawnWithRedirect("Desktop", desktopf, desktop)
The relevant code from goroutine is:local function _spawn(name,method,redirect,parent,args) if activeRoutines[name] then return nil, "Couldn't spawn; a coroutine with that name already exists!" end local routine={name=name,co=coroutine.create(method),redirect={redirect}, parent=parent,children={}} if routine.co==nil then error("Failed to create coroutine '"..name.."'!") end parent.children[#parent.children+1]=routine --this is 182 activeRoutines[name]=routine os.queueEvent("coroutine_start",name) numActiveCoroutines=numActiveCoroutines+1 --run it a bit.. sendEventTo(routine,args) return routine end function spawnWithRedirect(name,method,redirect,...) return _spawn(name,method,redirect,running(),{...}) end
The table parent is supposed to be provided by running(), which is this:As you can see, it is possible for running to return nil, and thus it is possible that parent is nil, and thus parent.children[letAloneThisNonesense] is an attempt to index a nil.local function findCoroutine(co) for _,routine in pairs(activeRoutines) do if routine.co==co then return routine end end return nil end function findNamedCoroutine(name) return activeRoutines[name] end function running() return findCoroutine(coroutine.running()) end
Actually, looking over this more closely it seems a bit screwy. Who wrote this goroutines API?
I have asked if he could add supprot for this on goroutine and he said me that i can use goroutine.spanwWithRedirect(its like pararell but you redirect to the window object(created with redirect) every time you resume the coroutine)Hmm…I'm not entirely certain, but I think that you cannot use goroutine.spawnWithRedirect until after you've used goroutine.spawn at least once. You'd need to ask the API creator or someone fairly experienced with it to be sure how to do that properly…I'm not sure what the intended usage is.