lua-users home
lua-l archive

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


Hey again, dudes...
I'm part of a game development team, and I'd need a piece of advice, 
quite basic through...
We are developping the game in C++, and I'd like to embed LUA code 
in it (for scripting objects).

Here is my purpose :
Take for example that class :
class Monster
{
  public :
  Monster(int hp, int range) : _hp, _range{};
  void Get_Hit(int hit) {hp_ -= hit}
  void Explode() {//play explosion sound and animation
  }
  void Attack() {
  //play attack sound and animation
  }
  private :
  int hp_;
  int range_;
}

and here is basically the LUA script I'd like to attach to it :
if HP < 0 then Destroy()
if RANGE < 20 then Attack()
else Get_Hit(1) --(some kind of lifetime)

my point is to link HP, RANGE, Destroy and Attack to the 
corresponding fields in my class, without creating my object in 
LUA... I mean, I have already read the Simple, Simpler, and Lunar 
Cpp Binding stuff, but it doesn't suit me, see that example main :

int main()
{
lua_State = lua_open();
Monster mob(10, 25);

//game stuff, firing, hitting, everything to be added here;
run_monster_script(mob); 
// should run the monster script for that monster... take the actual 
state of my instanciation, and update it...

//Monster mob should have 9 hp at that point....
return 0;
}


and that's all I need... hope someone can help

---------------------------------------------
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