I took a look at the Lua scripting engine. I read the documentation to the toLua, but i still don;t know how can i use the Lue scripts in my game. When i create some bindings using toLua how i'm supposed to run Lua script based on this bindings in engine? What if i want to call them every n frames. Is this possible? I suppose that this is possible. But how about preserving data by this scrupts, do i have to call some update everytime i want to make a call to lua script? I saw that some of You was using lua in their own projects so this is why i'm asking this question right here.
I also took a look at the angelscript. It seems quite interesting to me - but i susspose that Lua or maybe python (i saw that it also have a bindings to c++) have more features.
I would be very gratefull for the every answer.
--
Marius
Lua/toLua
Well, if you read the long thread of discussion we had in the Tools forum, I believe, we listed most of the merits of scripting.
The best way to think of scripting is like an extension class of your code.
The class can be used to call functions that are coded in your C++ classes and exists as part of the class. I use LUA in an in-line manner. The C++ function calls a LUA function, LUA returns, and C++ continues on.
Others takes a more complex route and do stuff like allocating time and multi-tasking around the LUA script so that it runs side-by side with the rest of the application execution.
The best way to think of scripting is like an extension class of your code.
The class can be used to call functions that are coded in your C++ classes and exists as part of the class. I use LUA in an in-line manner. The C++ function calls a LUA function, LUA returns, and C++ continues on.
Others takes a more complex route and do stuff like allocating time and multi-tasking around the LUA script so that it runs side-by side with the rest of the application execution.
Crud, how do I do this again?
-
Guest
hmmm, i know what the script language and the scripting engine is used for. I'v even wrote some simple vm and scripting language. But rught now i need something really powerfull and fast. And i need it now. I don't have time to sit and make my own scripting language, and my old one is useless right now - it's just to simple.
My question was: how can i use Lua in my game, but 'how' meaned what funkcjion should i use to load and run scripts. I would be very gratefull for code samples.
btw: lua scrips are precompiled or compiled at runtime?
anyway, thanx for the answer Saigumi.
one more thing. Can i create new object in Lua? I mean is Lua capable of creating new objects using it's methods or do i have to export operator new/malloc from c?
My question was: how can i use Lua in my game, but 'how' meaned what funkcjion should i use to load and run scripts. I would be very gratefull for code samples.
btw: lua scrips are precompiled or compiled at runtime?
anyway, thanx for the answer Saigumi.
one more thing. Can i create new object in Lua? I mean is Lua capable of creating new objects using it's methods or do i have to export operator new/malloc from c?
I don't know about all the object creation since from what I've seen, they do not share memory space. The examples that I have seen have the LUA function call a creation function in the C++ application.
http://www.saigumi.net/calua-irrlicht.zip
http://www.saigumi.net/calua-irrlicht.zip
Crud, how do I do this again?