I'm about to implement Lua support into my engine, but have stumbled upon a little problem that hopefully is pretty simple to solve.[/font]
I've been following this guide http://usefulgamedev...ua-example.html and it works without any issues. The problem is that all my engine classes is inside a namespace. So I tried to add a namespace around the Player class (in the example), and the files gets generated and the project still compiles. So to my question:
How do I create an instance of MyNameSpace::Player class in Lua?
#ifndef PLAYER_H
#define PLAYER_H
namespace MyNameSpace { // THIS IS ADDED BY ME!
class Player {
private:
int health;
public:
Player();
~Player();
void setHealth(int _health);
int getHealth();
};
}
#endif // PLAYER_H
[font="arial, verdana, tahoma, sans-serif"] [/font][font="arial, verdana, tahoma, sans-serif"]How should this file look like after I've added the namespace?[/font][font="arial, verdana, tahoma, sans-serif"] [/font]-- Create new Player object and set health
player = Player:new()
player:setHealth(4)
-- Display players health
io.write("LUA: Player's health is "..player:getHealth());
[font="arial, verdana, tahoma, sans-serif"] [/font][font="arial, verdana, tahoma, sans-serif"]Thanks for your help! 