It just hangs and dies, right? (Too long without yielding). It's because
main doesn't ever yield, and
ComputerCraft doesn't like that. I see you misunderstand how coroutines work.
LBPHacker, on 11 July 2014 - 03:18 PM, said:
It's important to know that when SCCH is waiting for user input, so is main.
There's no way to actually run more than one functions parallelly in CC. You can manage coroutines (get event data, pass the data to the first coroutine, wait until it yields, pass the data to the second coroutine, etc.) but you can't make more than one run at a time.
Here's how coroutines work.
That settled, you might now that main should look something like this:
function main()
--[[ I wasn't sure about the code in this block
--Screen choice chk
--Power system checks/screen
--Server Checks/Screen
chksvr(1,1,2)
chksvr(3,2,2)
chksvr(5,3,2)
--loop refresh pause
--]]
-- do initialization here
while true do
local eventData = {os.pullEvent()}
if eventData[1] == "stop_main" then
return
-- elseif eventData[1] == "..." then
end
-- process eventData
-- do things here you want to be done every time an event fires
end
end
EDIT: *sigh* These "awesome" code blocks don't like comments. For some reason, they think that we're posting BASIC code snippets and everything that begins with an apostrophe is a comment.
Edited by LBPHacker, 11 July 2014 - 03:52 PM.