mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-27 15:29:26 -06:00
Cleaned up scripts directory
Made scripts runnable at startup Added printing functions and remapped default Lua printing
This commit is contained in:
@@ -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__
|
||||
|
||||
@@ -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__
|
||||
|
||||
Reference in New Issue
Block a user