MCPcopy Create free account
hub / github.com/Norbyte/ositools / LoadScript

Method LoadScript

OsiInterface/LuaBinding.cpp/LuaBinding.cpp:491–510  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489
490
491 bool LoadScript(std::string const & script, std::string const & name = "")
492 {
493 /* Load the file containing the script we are going to run */
494 int status = luaL_loadbufferx(state_, script.c_str(), script.size(), name.c_str(), "text");
495 if (status != LUA_OK) {
496 OsiError("Failed to parse script: " << lua_tostring(state_, -1));
497 lua_pop(state_, 1); /* pop error message from the stack */
498 return false;
499 }
500
501 /* Ask Lua to run our little script */
502 status = lua_pcall(state_, 0, LUA_MULTRET, 0);
503 if (status != LUA_OK) {
504 OsiError("Failed to execute script: " << lua_tostring(state_, -1));
505 lua_pop(state_, 1); // pop error message from the stack
506 return false;
507 }
508
509 return true;
510 }
511
512 void Call(char const * func, char const * arg)
513 {

Callers 1

LuaLoadFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected