[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Game oriented usage of Lua?
- From: "Vincent PENQUERC'H" <vpenquerch@...>
- Date: Wed, 26 May 1999 16:37:40 +0100
> do you call several lua scripts & functions from C/C++ when entering a
> specific gamestate? (thus C/C++ contains you "main-game-loop")
> or do you call a lua script that implements a
> "main-game-loop" (calling Lua
> & C/C++ functions in the progress when entering a gamestate)
Personnaly (since I had an already working base), I have a C++ main
loop that calls Lua functions at defined times (when a character (in the
sense of a person) has to 'think' for example). The Lua function is
part of a table representing the character along with other functions
and data (like a C++ object). This tables has a few entry points: think,
call_me_when_someone_talks_to_me, call_me_when_i_am_attacked, etc.
These functions then have a set of C functions they can call as basic
blocks (find a path to there, say that to this person, etc...).
The only concern left is the problem of memory: This approach does not
use the nice 'I load a 'dialog' data file, search it to know what to
answer the player, then free it when it's over).
Lua people: The docs say that functions are considered data, as integers
for example. This means if I write something like:
and then write a.b=nil, will the function be garbage collected ?