[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: LUA Shell inside my application
- From: Andreas Volz <lists@...>
- Date: Thu, 10 Jun 2004 15:13:11 +0200
Hi,
I've currently an C++ application in which I plan to embed LUA. I've two
threads, one recieves data from network with 25 fps and the other is
currently a _very_ primitive shell to change values. Here is the code:
...
fgets (parser_string, 1024, stdin);
commands = sscanf(parser_string, "%s %s %s %s",
parser_key, parser_value, parser_value2, parser_value3);
if (init)
{
cmutex.Lock ();
switch (commands)
{
case -1:
break;
case 1: // commands with one keyword
if (!strcmp (parser_key, "quit"))
{
quit = true;
}
if (!strcmp (parser_key, "stop"))
{
for (int i = 0; i < (int)
robotlist.GetRobotNumber(popt->team); i++)
{
if (!robotlist.GetRobot (popt->team, i, robot))
{
cout << "couldn't register robot " << i << endl;
}
br1 = brc1->getRobotByID (robot.ID);
br1->setAction (BenderRobot::ACTION_STOP);
}
}
break;
case 2: // commands with two keywords
...
I played with some tutorials with LUA and I like the language. What I
need is a LUA shell that has everytime I pressed <Return> in the shell a
copy (or Reference; is this possible) of brc1 and can change the values
like you see it above (and give it back).
Another reason I like to embed LUA is because I want to give users the
ability to write LUA scripts which are executed every frame, give data
to LUA, do some "things" and give them back to C++. Is LUA fast enough
to so this (25fps)? It's not much data, only 5-10 objects with some
x/y/z/angle data. Perhaps LUA has the ability to precompile scripts or
cache them if they're used very often?
regards
Andreas