------------------------------------------------------------------------------
| 53 | |
| 54 | //------------------------------------------------------------------------------ |
| 55 | bool ofxLua::init(bool abortOnError, bool openLibs, bool ofBindings) { |
| 56 | |
| 57 | clear(); |
| 58 | |
| 59 | L = luaL_newstate(); |
| 60 | if(L == NULL) { |
| 61 | ofLogError("ofxLua") << "Error initializing lua"; |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | // open libs |
| 66 | if(openLibs) { |
| 67 | luaL_openlibs(L); |
| 68 | } |
| 69 | if(ofBindings) { |
| 70 | luaopen_of(L); |
| 71 | luaopen_glm(L); |
| 72 | } |
| 73 | |
| 74 | // clear stack since opening libs leaves tables on the stack |
| 75 | lua_settop(L, 0); |
| 76 | |
| 77 | // set the panic function |
| 78 | lua_atpanic(L, &atPanic); |
| 79 | |
| 80 | this->abortOnError = abortOnError; |
| 81 | ofLogVerbose("ofxLua") << "Initialized state"; |
| 82 | |
| 83 | return true; |
| 84 | } |
| 85 | |
| 86 | void ofxLua::clear() { |
| 87 | if(L != NULL) { |
no test coverage detected