Lua and c++ co-routines
Moderator: Coders of Rage
Lua and c++ co-routines
This is at the moment a theoretical for me, but I remember in an AiGD Falco said something about having a continuous script running through the game with its only infinite loop. My question is, was this achieved with co-routines or is there a need for a sneaky alternative
- M_D_K
- Chaos Rift Demigod
- Posts: 1087
- Joined: Tue Oct 28, 2008 10:33 am
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C/++
- Location: UK
Re: Lua and c++ co-routines
it was done with co-routines. At the end of every iteration in the loop (in the script) it calls a yield function which returns control back to the C++ side of things.
Gyro Sheen wrote:you pour their inventory onto my life
IRC wrote: <sparda> The routine had a stack overflow, sorry.
<sparda> Apparently the stack was full of shit.
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Lua and c++ co-routines
^ HOW DO YOU KNOW THIS!?M_D_K wrote:it was done with co-routines. At the end of every iteration in the loop (in the script) it calls a yield function which returns control back to the C++ side of things.
owait...
I don't recommend that approach, though. That stuff was way back when I was first learning Lua. Simply load a script with luaL_dofile() and manually invoke an update() function within the script from your C/++ main loop (as you would any normal function). There's no need to use coroutines.
Re: Lua and c++ co-routines
that's cool But doesn't that mean no globals for scripts? or is that a good thing as its more OO?
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Lua and c++ co-routines
Nope. Any variable you declare without explicitly using the "local" keyword is global. And any global logic (outside of a function) executes once upon loading of the script (for initialization/consruction, etc).sk1v3r wrote:that's cool But doesn't that mean no globals for scripts? or is that a good thing as its more OO?
Re: Lua and c++ co-routines
I meant like persisting globals between scripts, or is that what you were saying ?
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Lua and c++ co-routines
It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
Re: Lua and c++ co-routines
okay, thanks
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Lua and c++ co-routines
Invokation Edukation?GyroVorbis wrote:It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Lua and c++ co-routines
Already planned. That's nothing. We planned to show our entire implementation, which is 1000x deeper than our old, shitty "heartbeat" implementation previously.dandymcgee wrote:Invokation Edukation?GyroVorbis wrote:It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
Re: Lua and c++ co-routines
I'm all ways 1 step behindGyroVorbis wrote:Already planned. That's nothing. We planned to show our entire implementation, which is 1000x deeper than our old, shitty "heartbeat" implementation previously.dandymcgee wrote:Invokation Edukation?GyroVorbis wrote:It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
Re: Lua and c++ co-routines
No ES is just one step ahead... maybe you should try researching other things? which reminds me... I have to research ruby as a scripting language....N64vSNES wrote:I'm all ways 1 step behindGyroVorbis wrote:Already planned. That's nothing. We planned to show our entire implementation, which is 1000x deeper than our old, shitty "heartbeat" implementation previously.dandymcgee wrote:Invokation Edukation?GyroVorbis wrote:It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
- dandymcgee
- ES Beta Backer
- Posts: 4709
- Joined: Tue Apr 29, 2008 3:24 pm
- Current Project: https://github.com/dbechrd/RicoTech
- Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
- Programming Language of Choice: C
- Location: San Francisco
- Contact:
Re: Lua and c++ co-routines
Actually I was just being a smart ass and making fun of the spelling, but that works too.GyroVorbis wrote:Already planned. That's nothing. We planned to show our entire implementation, which is 1000x deeper than our old, shitty "heartbeat" implementation previously.dandymcgee wrote:Invokation Edukation?GyroVorbis wrote:It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
- Falco Girgis
- Elysian Shadows Team
- Posts: 10294
- Joined: Thu May 20, 2004 2:04 pm
- Current Project: Elysian Shadows
- Favorite Gaming Platforms: Dreamcast, SNES, NES
- Programming Language of Choice: C/++
- Location: Studio Vorbis, AL
- Contact:
Re: Lua and c++ co-routines
Don't bother. Unless you wish to embed one of the heaviest-weight, slowest scripting languages around.eatcomics wrote:No ES is just one step ahead... maybe you should try researching other things? which reminds me... I have to research ruby as a scripting language....N64vSNES wrote:I'm all ways 1 step behindGyroVorbis wrote:Already planned. That's nothing. We planned to show our entire implementation, which is 1000x deeper than our old, shitty "heartbeat" implementation previously.dandymcgee wrote:Invokation Edukation?GyroVorbis wrote:It was a matter of "persisting globals between INVOKATION of a single script" that was the issue addressed by that Adventures in Game Development video. To share globals between actual scripts (lua_States), you'd have to push and pop them into each other...sk1v3r wrote:I meant like persisting globals between scripts, or is that what you were saying ?
Ruby is great, but it is NOT great as an embedded, real-time scripting language.
Re: Lua and c++ co-routines
Ah, I see. I always liked Ruby... So I figured I might look into using it with my engine, but I believe the words you are speaking.