Jump to content




YieldIfNeeded

utility

  • You cannot reply to this topic
No replies to this topic

#1 Thefdjurt

  • Members
  • 45 posts
  • LocationMy house

Posted 27 April 2016 - 04:20 AM

Whenever I am working on programs that involve several iterations across tables I often forget about CC's "too long without yielding" error. In order to avoid having to go back and fix this I wrote this little utility

The code is available at: pastebin get Tpr5iUAH

Q: Is this loaded with os.loadAPI?
- A: To load use
dofile("yin.lua",[override pullEventRaw| true]) --os.loadAP? pffff ha

Q: Why are you overriding os.pullEventRaw?
- A: CC's has a coroutine based event system, meaning that when run os.pullEventRaw it is effectively the same thing as running coroutine.yield.

Q: How do I use this?
- A: It is very simple and only one function:
--Example case
while x<=str do
  c=str:sub(x,x)
  --Tokenization stuff...
  lc,x=c,x+1
  YIN()
end

Credit, while appreciated, is not necessary for this.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users