mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Add ability to schedule Lua scripts (#3416)
This commit is contained in:
@@ -102,7 +102,6 @@ public:
|
||||
void addLibrary(LuaLibrary library);
|
||||
bool hasLibrary(const std::string& name);
|
||||
|
||||
|
||||
virtual void preSync(bool isMaster) override;
|
||||
virtual void encode(SyncBuffer* syncBuffer) override;
|
||||
virtual void decode(SyncBuffer* syncBuffer) override;
|
||||
@@ -111,6 +110,11 @@ public:
|
||||
void queueScript(Script script);
|
||||
void queueScript(std::string script);
|
||||
|
||||
// Runs the `script` every `timeout` seconds wallclock time
|
||||
void registerRepeatedScript(std::string identifier, std::string script,
|
||||
double timeout, std::string preScript = "", std::string postScript = "");
|
||||
void removeRepeatedScript(std::string_view identifier);
|
||||
|
||||
std::vector<std::string> allLuaFunctions() const;
|
||||
const std::vector<LuaLibrary>& allLuaLibraries() const;
|
||||
|
||||
@@ -141,6 +145,19 @@ private:
|
||||
|
||||
std::vector<std::string> _scriptsToSync;
|
||||
|
||||
struct RepeatedScriptInfo {
|
||||
/// This script is run everytime `timeout` seconds have passed
|
||||
std::string script;
|
||||
|
||||
/// This script is run when the repeated script is unregistered
|
||||
std::string postScript;
|
||||
|
||||
std::string identifier;
|
||||
double timeout = 0.0;
|
||||
double lastRun = 0.0;
|
||||
};
|
||||
std::vector<RepeatedScriptInfo> _repeatedScripts;
|
||||
|
||||
// Logging variables
|
||||
bool _logFileExists = false;
|
||||
bool _logScripts = true;
|
||||
|
||||
Reference in New Issue
Block a user