Why do I get all the stupid bugs?
** EDIT **
Look at the comments of this post for some LUA stuff =)
local p = Vector3(1.1, 2.2, 9.3)
local y = Vector3(3.0, 3.1, 2.4)
local a = Vector3.add(y,p)
print("p: ", p:x(), p:y(), p:z())
print("y: ", y:x(), y:y(), y:z())
print("a: ", a:xyz())
class LUAVector3
{
DECLARE_SCRIPT(Vector3)
public:
static int Create(lua_State* L);
// Getters / Setters
static int x (lua_State *L);
static int y (lua_State *L);
static int z (lua_State *L);
static int xyz (lua_State *L);
// Operations
static int Add(lua_State* L);
// ....
};
int LUAVector3::Add(lua_State* L)
{
Vector3* v1 = CheckType(L, 1);
Vector3* v2 = CheckType(L, 2);
Vector3* sum = Push(L);
*sum = *v1 + *v2;
return 1;
}
I got function calls from Lua to C working, but was just so perplexed by the amount of work required to get C++ classes into Lua that I just decided to drop it and continue on my Asteroids clone. I tried out Python and apparently it's really easy to bind in that. I still have to try out GameMonkey and Squirrel as well.
Any progress on your side of the factory? I'll upload the Lua class wrapper I made if you want it.