Skip to content

Commit a8be738

Browse files
committed
lua_rawset global value
1 parent 0a00069 commit a8be738

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

emmy_core/emmy_core.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,11 @@ extern "C" {
154154
luaL_setfuncs(L, lib, 0);
155155

156156
// _G.emmy_core
157-
lua_pushvalue(L, -1);
158-
lua_setglobal(L, "emmy_core");
157+
lua_getglobal(L, "_G");
158+
lua_pushstring(L, "emmy_core");
159+
lua_pushvalue(L, -3);
160+
lua_rawset(L, -3);
161+
lua_pop(L, 1);
159162

160163
return 1;
161164
}

emmy_core/emmy_helper_lib.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ int emmyHelperInit(lua_State* L) {
162162
int luaopen_emmy_helper(lua_State* L) {
163163
initialized = false;
164164

165+
lua_getglobal(L, "_G");
166+
lua_pushstring(L, "emmyHelperInit");
165167
lua_pushcfunction(L, emmyHelperInit);
166-
lua_setglobal(L, "emmyHelperInit");
168+
lua_rawset(L, -3);
169+
lua_pop(L, 1);
167170

168171
return 0;
169172
}

0 commit comments

Comments
 (0)