Sfoglia il codice sorgente

in lua sample, path to game resource is hardcoded; need fix

mikymod 12 anni fa
parent
commit
c7f24ccea5
2 ha cambiato i file con 14 aggiunte e 15 eliminazioni
  1. 1 0
      samples/lua/CMakeLists.txt
  2. 13 15
      samples/lua/lua.cpp

+ 1 - 0
samples/lua/CMakeLists.txt

@@ -4,6 +4,7 @@ set (SRC
 	lua.cpp
 )
 
+add_definitions(-Wl,-E)
 add_library (game SHARED ${SRC})
 target_link_libraries(game crown)
 

+ 13 - 15
samples/lua/lua.cpp

@@ -1,4 +1,3 @@
-#include "lua.hpp"
 #include "Crown.h"
 #include "Game.h"
 
@@ -6,40 +5,39 @@
 namespace crown
 {
 
-lua_State* state;
-int z;
+lua_State* L;
 
 void init()
 {
-	state = luaL_newstate();
-	luaL_openlibs(state);
+	L = luaL_newstate();
+	luaL_openlibs(L);
 
-	if (luaL_loadfile(state, "lua_sample/lua/game.raw") || lua_pcall(state, 0, 0, 0))
+	if (luaL_loadfile(L, "/home/mikymod/test/res_linux/lua/game.raw") || lua_pcall(L, 0, 0, 0))
 	{
-		os::printf("error: %s", lua_tostring(state, -1));
+		os::printf("error: %s", lua_tostring(L, -1));
 	}
 
-	lua_getglobal(state, "init");
+	lua_getglobal(L, "init");
 
-	lua_pcall(state, 0, 0, 0);
+	lua_pcall(L, 0, 0, 0);
 }
 
 void shutdown()
 {
-	lua_getglobal(state, "shutdown");
+	lua_getglobal(L, "shutdown");
 
-	lua_pcall(state, 0, 0, 0);
+	lua_pcall(L, 0, 0, 0);
 
-	lua_close(state);
+	lua_close(L);
 }
 
 void frame(float dt)
 {
-	lua_getglobal(state, "frame");
+	lua_getglobal(L, "frame");
 
-	lua_pushnumber(state, dt);
+	lua_pushnumber(L, dt);
 
-	lua_pcall(state, 1, 0, 0);
+	lua_pcall(L, 1, 0, 0);
 }
 
 }