Cleaned up scripts directory

Made scripts runnable at startup
Added printing functions and remapped default Lua printing
This commit is contained in:
Alexander Bock
2014-08-29 13:04:20 +02:00
parent 1782857c72
commit 79174d5b6c
17 changed files with 221 additions and 59 deletions

View File

@@ -28,6 +28,9 @@
#include <ghoul/lua/ghoul_lua.h>
#include <set>
namespace openspace {
namespace scripting {
class ScriptEngine {
public:
struct LuaLibrary {
@@ -43,14 +46,21 @@ public:
bool addLibrary(const LuaLibrary& library);
bool hasLibrary(const std::string& name);
bool runScript(std::string script);
bool runScript(const std::string& script);
bool runScriptFile(const std::string& filename);
private:
bool isLibraryNameAllowed(const std::string& name);
void addLibraryFunctions(const LuaLibrary& library, bool replace);
void addBaseLibrary();
void remapPrintFunction();
lua_State* _state;
std::set<unsigned int> _registeredLibraries;
};
} // namespace scripting
} // namespace openspace
#endif // __SCRIPTENGINE_H__

View File

@@ -27,10 +27,22 @@
struct lua_State;
namespace openspace {
namespace scripting {
// Helper functions
int printDebug(lua_State* L);
int printInfo(lua_State* L);
int printWarning(lua_State* L);
int printError(lua_State* L);
int printFatal(lua_State* L);
// Properties
int property_setValue(lua_State* L);
//static int property_getValue(lua_State* L);
} // namespace scripting
} // namespace openspace
#endif // __SCRIPTFUNCTIONS_H__