lua-users home
lua-l archive

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


Hi.

I need to define some classes hierarchy for my game, like in this pseudocode:

class Actor {
public:

	virtual void update()
	{
		print("Actor::update");
	}
};

class Soldier: public Actor {
public:

	void update()
	{
		Actor::update();

		print("Soldier::update");
	}
};

Soldier soldier;

soldier.update();

This should print 

Actor::update
Soldier::update


Is there any way of doing this in Lua?


I´ve found some links about OOP in Lua, but none seemed to be pratical/fast to be used in a game, also the call to the base class methods is a problem, too.

Thanks

Jose