Jump to content




Lua any way of late binding?


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

#1 Kouksi44

  • Members
  • 89 posts
  • LocationMunich, Germany

Posted 11 November 2014 - 05:47 PM

Hey everybody,

I am currently working with coroutines and the "run code in background" code from the tutorials section!

My problem is that I am creating the coroutine first when a specific function is called but in the overwritten os.pullEventRaw() he checks if my coroutine is suspended like this:
 if coroutine.status( coFoo ) == "suspended" 
. If any event occurs before the coroutine is created this will just error because the program can´t find "coFoo" .

I don´t really know how to check if a variable does even exist or(as the title says) there is some kind of late binding ?

Maybe some of you know anything that helps me :)

Thank you in advance !

mfG Kouksi44

#2 ElvishJerricco

  • Members
  • 803 posts

Posted 11 November 2014 - 06:07 PM

local coFoo
...
if not coFoo then
    coFoo = makeMyCoroutine()
end

if coroutine.status(coFoo) == "suspended" then
...


#3 Kouksi44

  • Members
  • 89 posts
  • LocationMunich, Germany

Posted 11 November 2014 - 06:27 PM

well.... I am feeling pretty damn stupid right now xD thank you !





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users