Game Development Community

Script concurrent execution

by Kostya · in Technical Issues · 10/15/2005 (4:41 am) · 6 replies

Might be someone know if it is possible in TGE lunch two independent scripts that concurrent execute and exchange those data. Data exchange is easy realized through global variable but I don’t know how to do concurrent execution because console wait when one script finish in order to start next script.

About the author

Recent Threads


#1
10/15/2005 (6:35 am)
You could use the schedule function to start both functions at the same time
#2
10/17/2005 (12:02 am)
Thank you, Bruno Grieco! I find the function: Schedule(time,reference,command,), do you know is it possible to use console method as command in the function? Might be you know where it is possible to find example of the function using?
#3
10/17/2005 (12:06 am)
Schedule isn't going to start two functions running concurrently. That isn't possible, unless you mess around a lot with threads. What are you trying to do, more specifically?

Ian
#4
10/17/2005 (12:43 am)
It is not possible with threads either. Script code is always executed in the main thread, regardless of what thread it was called from. I would go into more detail, but this isnt the TGE private forums so I cant.

You only really have two choices: redesign your code such that two scripts dont need to be concurrent, or use threads and do it all in C++. Since you don't appear to be a TGE licensee, that leaves option 1 unless you buy a license :)

T.
#5
10/17/2005 (11:58 am)
Guys,

It's not possible to have two concurrent thread unless you have two processors !!

I bet he only wants to have a simple multitasking. No big deal.

@Kostya

Most console methods are functions, so all you have to do is use reference as 0.
schedule(10, 0, "foo",arg1,arg2);
schedule(11, 0, "bar",arg1,arg2);

You could also use the eval function :
schedule(10,0, "eval", "whatever you want to do" );
#6
10/18/2005 (3:35 am)
Great thanks! In general I understand the situation with concurrent execution. In principle my problem might be solved by means lunching one of parallel tasks as function of DLL in separated thread, another task might be realized as script (it mean in TGE main thread). Connection between threads through somewhat synchronization object.
But here is another problem if it is analog of Schedule function that lunch another function not through time delay but on some event or on changing global variable?

@Tom Bampton About TGE licence: sorry for off topic but it is my headache for last half year. I can not find way of payment for TGE. I live in Russia and banks of the country doesn’t work with Bank Orders. Credit cards issued in the banks rejected by international paying systems. Single way of payment that I can use now is Bank Transfer. Might be you can advise me person in GarageGames who deal with the problem.