Mercurial > mm7
view LuaClass.h @ 2055:95e9a5141338
PlayerModule.swig
author | Ritor1 |
---|---|
date | Sat, 30 Nov 2013 20:08:51 +0600 |
parents | 29e16f184db8 |
children |
line wrap: on
line source
#pragma once #include <lib/lua/lua.h> #include <Log.h> #include "OSAPI.h" extern "C" int luaopen_UIControl(lua_State *L); // declare the wrapped module class LuaVM { public: void Initialize() { L = luaL_newstate(); if ( L == NULL ) Log::Warning(L"Error creating Lua context.\n"); luaL_openlibs(L); if ( luaL_dofile(L,GetScriptFileLocation("script.lua"))) Log::Warning(L"Error opening script.lua\n"); // все нужные cxx luaopen_UIControl(L); } bool DoFile(const char *filename) { if (luaL_dofile(L, GetScriptFileLocation(filename))) { Log::Warning(L"Error opening %s", filename); return 1; } return 0; } protected: lua_State *L; const char *GetScriptFileLocation(const char *script_name) { static char buf[2048]; strcpy(buf, "Data/scripts/lua/core/"); strcat(buf, script_name); return buf; } }; extern LuaVM *pMM_lua;