lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I don't think I will ever want to call another script from another, we are
talking about have
a high level language here, and the fancier you make it, the more harder the
learning curve is.  Which makes me wonder how lua is going to work out for
me, the more deeper you go
into lua, the harder it becomes for people to digest, I'm starting to hate
lua actually, I see
some stuff on coroutines, but it really doesn't help me to get them working,
honestly I don't
really know where to begin with them, you can read all you want, but I want
to see someone implement them in something besides a lua script, see how c++
and lua work with
them together, why are all the damn samples in scripts?  The best help I
found was from sample programs from like gamsutra, and the likes.  I can see
how they use lua and intergrate with c++, except they stop short of what I
want.  I can see the power in lua for loading level assets and other stuff
for configurations and all sorts of init stuff.  I have failed to see it
work for what I want.  I know it can be done, and I has been done, but I'm
running out of time to mess with this stuff, I have so much other stuff to
do, I didn't want to spend my time banging my head against the wall, looking
through piles of docs, and messages, only to get nothing, why is something
so seemly easy to want, seem so difficult to implement?  I don't know, I
guess I have better thangs to do, like re-invent the wheel or something.
I'll leave you with this sample..


Simple usage
To create a coroutine we must have function which represents it, e.g.,

> function foo()
>>   print("foo", 1)
>>   coroutine.yield()
>>   print("foo", 2)
>> end
>
We create a coroutine using the coroutine.create(fn) function. We pass it an
entry point for the thread which is a Lua function. The object returned by
Lua is a thread:

> co = coroutine.create(foo) -- create a coroutine with foo as the entry
> = type(co)                 -- display the type of object "co"
thread
We can find out what state the thread is in using the coroutine.status()
function, e.g.,


> = coroutine.status(co)
suspended

wtf is co? this isn't surely called from c, it's called within lua right?
is co? lua_State * co?  I hate to be so down on this, but It is so
frustrating to work on something that has so much promise, and investsome
hard hours to get nothing yet.I do appreciate all your help, I know you owe
nothing to me, and you have answered my emails over the weekend, I
appreciateall the support.Tim Ryness