lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello all....
I'm a student making an internship, in a firm that asks me to build 
a script interface for a video Game... That's why I'm dealing 

with LUA... I'd have several questions that I will try to present 
properly... Thank you by advance for any piece of answer you'll
provide, as I'm in desperate need of info... Of course, I have read 
the documentation for both LUA and LUABIND, at least three 

times :)

Here are my questions....

-Is there a proper way to pass arguments/info/data from C to LUA, 
I'm thinking of making some globals in LUA, who would be 

assigned by functions I would call in C, before launching the real 
script? But it is still very dim to me.

-How could I really launch my script, I mean, there are two steps... 
The first step would be to initialize my globals in LUA, 

globals that provide info for my script (p.e. if i'm scripting a 
monster, variables as Is_Attacked, Is_Dead, Ennemy_on_Range...) 

This info are necessary for the second step, which is to launch the 
behaviour of the object, and react to the variables... Do I 

have to make a big script, with functions for step 1, and a function 
for step 2?

-A last step would be to return a behaviour... I don't see really 
how to return something really clear to my C code, something 

other than a simple string that I would have to analyse in return... 
What would be perfect would be to return a C++ class, that's 

why I thought of LUABIND, which leads to my next question...

-What does LUABIND help to? I mean, I think I understood that you 
can use C++ classes in LUA with it, but I don't know if you can 

neither take an already existing instanciation of a class from C++ 
(which could really help to pass arguments to LUA), I explain 

myself : having a class arguments in C++, building arg, of type 
argument, and then passing it to LUA/LUABIND, who would only have 

to access the fields for the script.... 
And I thought LUABIND could also help me to return a behaviour, 
calling directly C++ methods... But my problem is that LUABIND 

seems to clone objects before doing anything, and if there is a 
method to call, I'd need to call it for an already instanciated in 

C++ class... 
Finally, I thought of returning a class from LUA to C++, to solve 
that last point, but I did not find how to do it either....

-My last question : as I always developped under Unix, and I've been 
told to make it under Visual C++ 6, could you explain to me 

how to use LUA and/or LUABIND under it? I tried to open the project 
given into LUA tarball, and I deleted all other things that 

lualib and lualiblib, and then added my files (I don't know how to 
make and link libs under VC++ 6). Is that correct?


Well, that's all.. I'm sorry if I'm asking questions that have been 
answered a lot or where the answer is in the doc (in that 

case, I swear I have read it at least three times before coming 
here)... I would really appreciate if someone could help me, and, 

best of the best, if you could provide me some really basic example 
code... For example, a example of a very simple script that 

takes 2 arguments, and return 2 different things in each case, and 
the C++ code associated who  launchs the script, gives the 

arguments to LUA, and retrieves the return value..... And even 
better, if you could help me with LUABIND, giving the same kind of 

example code : C++ code who instantiates a simple class (1 
attribute, for exemple) , passes it to a script, script who reacts 
to 

how the class is filled and returns another class, or fills another 
field of the initial class (that would be the best...)

I hope my English is ok, or all this will really be funny ... Thanks 
again for any kind of help you could provide...
---------------------------------------------
Trop de Virus dans votre boite aux lettres ? Découvrez les offres Premium d'Alinto ! A partir de 0.29?/mois ! http://www.alinto.com