MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / RunString

Function RunString

source/extern/imgui_lua_bindings.cpp:51–91  ·  view source on GitHub ↗

Example lua run string function returns NULL on success and error string on error

Source from the content-addressed store, hash-verified

49// Example lua run string function
50// returns NULL on success and error string on error
51const char * RunString(
52#if LUA_BINDINGS_LOCAL_STATE
53 lua_State* lState,
54#endif
55 const char* szLua) {
56 if (!lState) {
57 fprintf(stderr, "You didn't pass a valid lState, either assign that or refactor LoadImguiBindings and RunString\n");
58 }
59
60 int iStatus = luaL_loadstring(lState, szLua);
61 if(iStatus) {
62 return lua_tostring(lState, -1);
63 //fprintf(stderr, "Lua syntax error: %s\n", lua_tostring(lState, -1));
64 //return;
65 }
66#ifdef ENABLE_IM_LUA_END_STACK
67 endStack.clear();
68#endif
69 iStatus = lua_pcall( lState, 0, 0, 0 );
70
71#ifdef ENABLE_IM_LUA_END_STACK
72 bool wasEmpty = endStack.empty();
73 while(!endStack.empty()) {
74 ImEndStack(endStack.back());
75 endStack.pop_back();
76 }
77
78#endif
79 if( iStatus )
80 {
81 return lua_tostring(lState, -1);
82 //fprintf(stderr, "Error: %s\n", lua_tostring( lState, -1 ));
83 //return;
84 }
85#ifdef ENABLE_IM_LUA_END_STACK
86 else if (!wasEmpty) {
87 return "Script didn't clean up ImGui stack properly";
88 }
89#endif
90 return NULL;
91}
92
93
94#define IMGUI_FUNCTION_DRAW_LIST(name) \

Callers

nothing calls this directly

Calls 6

fprintfFunction · 0.85
luaL_loadstringFunction · 0.85
clearMethod · 0.45
emptyMethod · 0.45
backMethod · 0.45
pop_backMethod · 0.45

Tested by

no test coverage detected