diff --git a/src/application/application.cpp b/src/application/application.cpp index 1a9a8fad..6302926e 100644 --- a/src/application/application.cpp +++ b/src/application/application.cpp @@ -74,7 +74,9 @@ Application::Application(char const *name, ivec2 resolution, float framerate) data = new ApplicationData(name, resolution, framerate); g_world.ExecLua("lua/init.lua"); - int32_t gravity = g_world.GetVar("gravity"); + float gravity = g_world.GetLuaNumber("gravity"); + gravity = g_world.GetVar("gravity"); + gravity = gravity; } bool Application::MustTick() diff --git a/src/application/baselua.h b/src/application/baselua.h index 380e81ca..f0ddfe07 100644 --- a/src/application/baselua.h +++ b/src/application/baselua.h @@ -19,81 +19,6 @@ namespace lol { -//----------------------------------------------------------------------------- -#define LOLUA_CLASS_STATIC(ClassType, FuncName) Static ## ClassType ## FuncName -#define LOLUA_CLASS_METHOD(ClassType, FuncName) Method ## ClassType ## FuncName -#define LOLUA_CLASS_STATIC_C(ClassType, FuncName) Static ## #ClassType ## #FuncName -#define LOLUA_CLASS_METHOD_C(ClassType, FuncName) Method ## #ClassType ## #FuncName - -#define LOLUA_BEGIN_CTOR(ClassType) \ - ClassType* ClassType##New(lua_State* L) \ - { \ - int arg_idx = 1; \ - -#define LOLUA_END_CTOR(ClassType, ...) \ - return new ClassType(__VA_ARGS__); \ -} \ - -#define LOLUA_BEGIN_STATIC(FuncName) \ - int FuncName(lua_State* L) \ - { \ - int arg_idx = 1; \ - -#define LOLUA_BEGIN_CLASS_STATIC(ClassType, FuncName) \ - int LOLUA_CLASS_STATIC(ClassType, FuncName)(lua_State* L) \ - { \ - int arg_idx = 1; \ - -#define LOLUA_BEGIN_CLASS_METHOD(ClassType, FuncName) \ - int LOLUA_CLASS_METHOD(ClassType, FuncName)(lua_State* L) \ - { \ - int arg_idx = 1; \ - ClassType* this_ptr = luaW_check(L, arg_idx); \ - -#define LOLUA_CALL_FUNC(FuncName, ...) FuncName(__VA_ARGS__); -#define LOLUA_CALL_FUNC_RET(FuncName, ...) auto result = FuncName(__VA_ARGS__); -#define LOLUA_CALL_STATIC(ClassType, FuncName, ...) ClassType::FuncName(__VA_ARGS__); -#define LOLUA_CALL_STATIC_RET(ClassType, FuncName, ...) auto result = ClassType::FuncName(__VA_ARGS__); -#define LOLUA_CALL_METHOD(FuncName, ...) this_ptr->FuncName(__VA_ARGS__); -#define LOLUA_CALL_METHOD_RET(FuncName, ...) auto result = this_ptr->FuncName(__VA_ARGS__); - -#define LOLUA_ARG_STRING(VarName) String VarName = luaL_checkstring(L, arg_idx++); -#define LOLUA_ARG_CHAR(VarName) const char* VarName = luaL_checkstring(L, arg_idx++); -#define LOLUA_ARG_DOUBLE(VarName) double VarName = luaL_checknumber(L, arg_idx++); -#define LOLUA_ARG_INT(VarName) int32_t VarName = luaL_checkinteger(L, arg_idx++); -#define LOLUA_ARG_UINT(VarName) uint32_t VarName = luaL_checkunsigned(L, arg_idx++); -#define LOLUA_ARG_OBJ(VarType, VarName) VarType* VarName = luaW_check(L, arg_idx++); - -#define LOLUA_END_FUNC_STRING(VarName) lua_pushstring(L, VarName.C()); return 1; } -#define LOLUA_END_FUNC_CHAR(VarName) lua_pushstring(L, VarName); return 1; } -#define LOLUA_END_FUNC_FLOAT(VarName) lua_pushnumber(L, VarName); return 1; } -#define LOLUA_END_FUNC_INT(VarName) lua_pushinteger(L, VarName); return 1; } -#define LOLUA_END_FUNC_UINT(VarName) lua_pushunsigned(L, VarName); return 1; } -#define LOLUA_END_FUNC_OBJ(VarName) luaW_push(L, VarName); return 1; } -#define LOLUA_END_FUNC_STRING_RESULT LOLUA_END_FUNC_STRING(result) -#define LOLUA_END_FUNC_CHAR_RESULT LOLUA_END_FUNC_CHAR(result) -#define LOLUA_END_FUNC_FLOAT_RESULT LOLUA_END_FUNC_FLOAT(result) -#define LOLUA_END_FUNC_INT_RESULT LOLUA_END_FUNC_INT(result) -#define LOLUA_END_FUNC_UINT_RESULT LOLUA_END_FUNC_UINT(result) -#define LOLUA_END_FUNC_OBJ_RESULT LOLUA_END_FUNC_OBJ(result) -#define LOLUA_END_FUNC_VOID return 0; } - -#define LOLUA_BEGIN_TABLE_STATIC(ClassType) static luaL_Reg ClassType##StaticTable[] = { -#define LOLUA_BEGIN_TABLE_METHOD(ClassType) static luaL_Reg ClassType##MethodTable[] = { -#define LOLUA_ADD_TABLE_STATIC(ClassType, FuncName) { LOLUA_CLASS_STATIC_C(ClassType, FuncName), LOLUA_CLASS_STATIC(ClassType, FuncName) }, -#define LOLUA_ADD_TABLE_METHOD(ClassType, FuncName) { LOLUA_CLASS_METHOD_C(ClassType, FuncName), LOLUA_CLASS_METHOD(ClassType, FuncName) }, -#define LOLUA_END_TABLE { NULL, NULL } }; - -#define LOLUA_DEFINE_CLASS_LIBRARY(ClassType) \ - static int luaopen_##ClassType(lua_State* L) \ - { luaW_register(L, #ClassType, ClassType##StaticTable, ClassType##MethodTable, ClassType##New); return 1; }\ - -#define LOLUA_NEW_STATE(VarName) lua_State* L = (VarName = luaL_newstate()); -#define LOLUA_USE_STATE(VarName) lua_State* L = VarName; -#define LOLUA_REGISTER_CLASS_LIBRARY(ClassType) luaopen_##ClassType(L); - -#define LOLUA_REGISTER_STATIC(LuaFuncName, CppFuncName) lua_pushcfunction(L, CppFuncName); lua_setglobal(L, #LuaFuncName); - //----------------------------------------------------------------------------- class LuaObject {