PtokaX forum

Archive => HOW-TO's => Archived 5.1 boards => Old HOW-TO's => Topic started by: NightLitch on 06 March, 2005, 21:52:01

Title: Simple Corountine handle
Post by: NightLitch on 06 March, 2005, 21:52:01
this is a simple corountine handle that I have made hope it might come in handy or can be extended.

-- your function to call it with
theFunction = function(str_data)
--// the corountine function name
corofunc = coroutine.create(function()
table = {}
-- your code here

-- return your table what you want
return table
end)
local c, err = coroutine.resume(corofunc) -- execute your corountine
if type(err) ~= "table" then -- check if the returning value is what you wanted else value is sent to Error message
SendToOps(frmHub:GetHubBotName(), "Corountine error: "..(err or "none") ) -- error message sent to where you like...
else
return err -- return your table, string what it is now to the calling function
end
end

-- calling the function
if cmd == "command" then
local Table = theFunction() -- return the table to your location you want
end

please put in mode code here about corountine if you have some good ways handling it.

// NightLitch