Script Coroutines
by Bill "Black Manatee" Pomidor · in Torque Game Engine · 11/07/2004 (10:54 am) · 9 replies
I was wondering if there is any way for the script engine to support the concept of coroutines, similar to the Lua scripting language. I want to be able to have numerous script threads that can persist as seperate threads for the duration of a mission. A script thread must be able to release to the engine, and then resume at that same point in the script thread later with all stack data etc. for that thread intact.
For the purposes of saving games, is would also be necessary to save and restore the stack states of the scrip threads. Tall order I know.
For the purposes of saving games, is would also be necessary to save and restore the stack states of the scrip threads. Tall order I know.
#2
11/07/2004 (2:14 pm)
You can also emulate coroutines if you need to. It'll take a little more work, but if you gotta have it, you gotta have it... You could break things up into FSMs, which would be the most direct approach for this sort of thing.
#3
Has anyone done anything with co-routines since this was discussed? If so, I'd love to hear about it. I'm taking Tom's and Ben's advice and adjusting my thinking--but it would be nice to adapt TGE to be more campaign/mission/single-player functional via scripting. If you know of any resources tailored to this kind of approach, please let me know. Thanks--
~~Bill
01/12/2006 (7:30 am)
Bump...Has anyone done anything with co-routines since this was discussed? If so, I'd love to hear about it. I'm taking Tom's and Ben's advice and adjusting my thinking--but it would be nice to adapt TGE to be more campaign/mission/single-player functional via scripting. If you know of any resources tailored to this kind of approach, please let me know. Thanks--
~~Bill
#4
01/13/2006 (9:41 am)
What the heck is a coroutine?
#5
-Josh RItter
Prairie Games, Inc
01/13/2006 (12:14 pm)
Basically, a coroutine is a resumeable function. I use Python generators in MoM which are kind of a coroutine. Coroutines can GREATLY simplify certain types of logic (spells, custom macros, almost anything that is time based,etc). -Josh RItter
Prairie Games, Inc
#6
we were tracking down the (various) python/torque projects a year ago or so and it seemed like they'd all dead-ended.
.. just DL'd the MoM demo - very nice!
01/13/2006 (12:56 pm)
Ot: Python and Torque finally work together ? is that in-house to MoM or public ?we were tracking down the (various) python/torque projects a year ago or so and it seemed like they'd all dead-ended.
.. just DL'd the MoM demo - very nice!
#7
-Josh Ritter
Prairie Games, Inc
01/13/2006 (1:15 pm)
I compile Torque into a standard Python extension. This is based on TGEPython which is available here as a resource. -Josh Ritter
Prairie Games, Inc
#8
01/13/2006 (1:16 pm)
Huh, cool. thanks.
#9
~~Bill
01/14/2006 (12:57 pm)
Thank you, Josh! I will definitely look into it--and I appreciate your work on Python.~~Bill
Torque 3D Owner Tom Bampton
That said, you dont really need coroutines. If you think that what you're doing requires them, then you just need to adjust your thinking. Torque is not Lua, and it does not act like Lua, so it's a different way of working which may take some getting used to.
You might be able to hack coroutines in. It would be hard but theoretically doable. It's less effort to just learn what's there and maybe wait for me to get Lua into TGE.
T.