Mittell Buurman Posted November 2, 2013 Share Posted November 2, 2013 attempt to yield across metamethod/c-call boundary Where am I possible calling a C code? function getGateInfo(ply, hasCoroutine) if (hasCoroutine==nil) then hasCoroutine = false end theGate = getGateDistance(ply) if theGate then for k in pairs(theGate) do if (theGate[k]) then coroutine.yield() end if (openState == false) then openState = true moveObject(theGate[k], mTime, mx, my, mz, rx, ry, rz) setTimer( function() moveObject(theGate[k], mTime, mx, my, mz, -rx, -ry, -rz) setTimer( function() gate[k].openState = false end, mTime, 1) end, rTime, 1) end end end end local chgates = { } function resumethread() for key, value in ipairs(chgate) do coroutine.resume(value) end end function useGate(ply, cmd) getGateInfo(ply, false) if (theGate) then local gids = {} local counter = 0 for index,value in pairs(theGate)do gids[tonumber( theGate[index] ) ] = true counter = counter+1 end for id in pairs( gids ) do local co = coroutine.create(getGateInfo) coroutine.resume(co, id, true) table.insert(chgate, co) end setTimer(resumethread, 1000, 1) end end addCommandHandler('gate', useGate) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now