#ifndef LUA_DEF
#define LUA_DEF
#include "data.h"
class Data;
int luaMoverGet(lua_State *);
int luaMoverSet(lua_State *);
int luaMoverCalc(lua_State *);
int luaMoverGetX(lua_State *);
int luaMoverSetX(lua_State *);
int luaMoverGetY(lua_State *);
int luaMoverSetY(lua_State *);
int luaMoverGetExp(lua_State *);
int luaMoverSetExp(lua_State *);
int luaMoverGetAngle(lua_State *);
int luaMoverSetAngle(lua_State *);
int luaMoverGetTimer(lua_State *);
int luaDrawGraph(lua_State *);
int luaPadIsPressA(lua_State *);
int luaPadIsPushA(lua_State *);
int luaPadIsPressB(lua_State *);
int luaPadIsPushB(lua_State *);
int luaPadIsPressUP(lua_State *);
int luaPadIsPushUP(lua_State *);
int luaPadIsPressDOWN(lua_State *);
int luaPadIsPushDOWN(lua_State *);
int luaPadIsPressLEFT(lua_State *);
int luaPadIsPushLEFT(lua_State *);
int luaPadIsPressRIGHT(lua_State *);
int luaPadIsPushRIGHT(lua_State *);
class Lua {
private:
Data *dataPtr_;
lua_State *L_;
public:
Lua() : L_() {}
virtual ~Lua() {}
virtual lua_State * getL() { return L_; }
virtual int open(
Data *dataPtr
)
{
L_ = luaL_newstate();
luaL_openlibs(L_);
luaL_dofile(L_, ".\\lua\\luatest.lua");
lua_pushlightuserdata(L_, dataPtr);
lua_setglobal(L_, "DID");
lua_register(L_, "cppMoverGet", luaMoverGet);
lua_register(L_, "cppMoverSet", luaMoverSet);
lua_register(L_, "cppMoverCalc", luaMoverCalc);
lua_register(L_, "cppMoverGetX", luaMoverGetX);
lua_register(L_, "cppMoverSetX", luaMoverSetX);
lua_register(L_, "cppMoverGetY", luaMoverGetY);
lua_register(L_, "cppMoverSetY", luaMoverSetY);
lua_register(L_, "cppMoverGetExp", luaMoverGetExp);
lua_register(L_, "cppMoverSetExp", luaMoverSetExp);
lua_register(L_, "cppMoverGetAngle", luaMoverGetAngle);
lua_register(L_, "cppMoverSetAngle", luaMoverSetAngle);
lua_register(L_, "cppMoverGetTimer", luaMoverGetTimer);
lua_register(L_, "cppDrawGraph", luaDrawGraph);
lua_register(L_, "cppPadIsPressA", luaPadIsPressA);
lua_register(L_, "cppPadIsPushA", luaPadIsPushA);
lua_register(L_, "cppPadIsPressB", luaPadIsPressB);
lua_register(L_, "cppPadIsPushB", luaPadIsPushB);
lua_register(L_, "cppPadIsPressUP", luaPadIsPressUP);
lua_register(L_, "cppPadIsPushUP", luaPadIsPushUP);
lua_register(L_, "cppPadIsPressDOWN", luaPadIsPressDOWN);
lua_register(L_, "cppPadIsPushDOWN", luaPadIsPushDOWN);
lua_register(L_, "cppPadIsPressLEFT", luaPadIsPressLEFT);
lua_register(L_, "cppPadIsPushLEFT", luaPadIsPushLEFT);
lua_register(L_, "cppPadIsPressRIGHT", luaPadIsPressRIGHT);
lua_register(L_, "cppPadIsPushRIGHT", luaPadIsPushRIGHT);
dataPtr_ = dataPtr;
return 0;
}
virtual void close()
{
if (L_) lua_close(L_);
}
};
#endif