mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-15 10:09:48 -05:00
Solve merge conflict
This commit is contained in:
@@ -158,11 +158,17 @@ function preInitialization()
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua'))
|
||||
dofile(openspace.absPath('${SCRIPTS}/bind_keys_osirisrex.lua'))
|
||||
|
||||
-- openspace.time.setTime("2018-12-20T22:47:00.00")
|
||||
--openspace.time.setTime("2019-05-25T03:57:55.00")
|
||||
openspace.time.setTime("2016 SEP 8 23:05:00.50")
|
||||
--openspace.time.setTime("2019 APR 16 12:03:00.00")
|
||||
--local startTime = "2019 APR 16 12:03:00.00"
|
||||
local startTime = "2016 SEP 8 23:05:00.50"
|
||||
|
||||
openspace.time.setTime(startTime)
|
||||
openspace.time.setDeltaTime(0)
|
||||
|
||||
openspace.scriptScheduler.load("${OPENSPACE_DATA}/scene/osirisrex/scheduled_scripts.lua")
|
||||
|
||||
-- Removing the line below will cause all scripts prior to <startTime> to be executed during initialization
|
||||
openspace.scriptScheduler.skipTo(startTime);
|
||||
|
||||
end
|
||||
|
||||
function postInitialization()
|
||||
@@ -189,6 +195,8 @@ function postInitialization()
|
||||
openspace.printInfo("Done setting default values")
|
||||
openspace.loadMission("${OPENSPACE_DATA}/scene/osirisrex/osirisrex/osirisrex.mission")
|
||||
|
||||
|
||||
|
||||
openspace.resetCameraDirection()
|
||||
end
|
||||
|
||||
|
||||
@@ -194,35 +194,10 @@ return {
|
||||
},
|
||||
},
|
||||
]]
|
||||
|
||||
-- Trail relative to Earth
|
||||
{
|
||||
Name = "OsirisRexTrailLocal",
|
||||
Parent = "BennuBarycenter",
|
||||
Renderable = {
|
||||
Type = "RenderableTrailNew",
|
||||
-- Spice
|
||||
Body = "OSIRIS-REX",
|
||||
Frame = "GALACTIC",
|
||||
Observer = BENNU_BODY,
|
||||
-- Optional rendering properties
|
||||
LineColor = { 0.9, 0.2, 0.9 },
|
||||
PointColor = { 0.9, 0.2, 0.9 },
|
||||
LineFade = 0.5, -- [0,1]
|
||||
RenderPart = 0.06,
|
||||
LineWidth = 2,
|
||||
ShowTimeStamps = false,
|
||||
RenderFullTrail = false,
|
||||
-- Time interval
|
||||
TimeRange = {
|
||||
Start = "2016 SEP 8 23:05:00.50",
|
||||
End = "2023 SEP 24 12:00:00",
|
||||
},
|
||||
SampleDeltaTime = 3600, -- Seconds between each point
|
||||
SubSamples = 3,
|
||||
},
|
||||
GuiName = "OsirisRexTrailLocal"
|
||||
},
|
||||
{
|
||||
Name = "OsirisRexTrailGlobal",
|
||||
Name = "OsirisRexTrailEarth",
|
||||
Parent = "LodEarth",
|
||||
Renderable = {
|
||||
Type = "RenderableTrailNew",
|
||||
@@ -246,10 +221,12 @@ return {
|
||||
SampleDeltaTime = 60, -- Seconds between each point
|
||||
SubSamples = 59,
|
||||
},
|
||||
GuiName = "OsirisRexTrailGlobal"
|
||||
GuiName = "OsirisRexTrailEarth"
|
||||
},
|
||||
|
||||
-- Trail relative to solar system barycenter
|
||||
{
|
||||
Name = "OsirisRexTrailSolar",
|
||||
Name = "OsirisRexTrailSolarSystem",
|
||||
Parent = "SolarSystemBarycenter",
|
||||
Renderable = {
|
||||
Type = "RenderableTrailNew",
|
||||
@@ -273,6 +250,37 @@ return {
|
||||
SampleDeltaTime = 3600, -- Seconds between each point
|
||||
SubSamples = 0,
|
||||
},
|
||||
GuiName = "OsirisRexTrailSolar"
|
||||
GuiName = "OsirisRexTrailSolarSystem"
|
||||
},
|
||||
|
||||
-- Trail relative to Bennu
|
||||
{
|
||||
Name = "OsirisRexTrailBennu",
|
||||
Parent = "BennuBarycenter",
|
||||
Renderable = {
|
||||
Type = "RenderableTrailNew",
|
||||
-- Spice
|
||||
Body = "OSIRIS-REX",
|
||||
Frame = "GALACTIC",
|
||||
Observer = BENNU_BODY,
|
||||
-- Optional rendering properties
|
||||
LineColor = { 0.9, 0.2, 0.9 },
|
||||
PointColor = { 0.9, 0.2, 0.9 },
|
||||
LineFade = 0.5, -- [0,1]
|
||||
RenderPart = 0.06,
|
||||
LineWidth = 2,
|
||||
ShowTimeStamps = false,
|
||||
RenderFullTrail = false,
|
||||
-- Time interval
|
||||
TimeRange = {
|
||||
Start = "2016 SEP 8 23:05:00.50",
|
||||
End = "2023 SEP 24 12:00:00",
|
||||
},
|
||||
SampleDeltaTime = 3600, -- Seconds between each point
|
||||
SubSamples = 3,
|
||||
},
|
||||
GuiName = "OsirisRexTrailBennu"
|
||||
},
|
||||
|
||||
|
||||
}
|
||||
|
||||
17
data/scene/osirisrex/scheduled_scripts.lua
Normal file
17
data/scene/osirisrex/scheduled_scripts.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
return
|
||||
{
|
||||
{
|
||||
Time = "2016 SEP 08 23:10:13",
|
||||
ReversibleLuaScript = {
|
||||
Forward = "openspace.printInfo('forward test 1');",
|
||||
Backward = "openspace.printInfo('backward test 1');",
|
||||
}
|
||||
},
|
||||
{
|
||||
Time = "2016 SEP 09 00:08:13",
|
||||
ReversibleLuaScript = {
|
||||
Forward = "openspace.printInfo('forward test 2');",
|
||||
Backward = "openspace.printInfo('backward test 2');",
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <openspace/util/mouse.h>
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/scripting/scriptscheduler.h>
|
||||
|
||||
#include <ghoul/glm.h>
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
@@ -80,6 +81,7 @@ public:
|
||||
interaction::InteractionHandler& interactionHandler();
|
||||
RenderEngine& renderEngine();
|
||||
scripting::ScriptEngine& scriptEngine();
|
||||
scripting::ScriptScheduler& scriptScheduler();
|
||||
NetworkEngine& networkEngine();
|
||||
LuaConsole& console();
|
||||
ModuleEngine& moduleEngine();
|
||||
@@ -138,6 +140,7 @@ private:
|
||||
std::unique_ptr<interaction::InteractionHandler> _interactionHandler;
|
||||
std::unique_ptr<RenderEngine> _renderEngine;
|
||||
std::unique_ptr<scripting::ScriptEngine> _scriptEngine;
|
||||
std::unique_ptr<scripting::ScriptScheduler> _scriptScheduler;
|
||||
std::unique_ptr<NetworkEngine> _networkEngine;
|
||||
std::unique_ptr<ghoul::cmdparser::CommandlineParser> _commandlineParser;
|
||||
std::unique_ptr<LuaConsole> _console;
|
||||
|
||||
86
include/openspace/scripting/scriptscheduler.h
Normal file
86
include/openspace/scripting/scriptscheduler.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __SCRIPTSCHEDULER_H__
|
||||
#define __SCRIPTSCHEDULER_H__
|
||||
|
||||
#include <ghoul/misc/dictionary.h>
|
||||
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
namespace scripting {
|
||||
|
||||
|
||||
|
||||
struct ReversibleLuaScript {
|
||||
std::string forwardScript;
|
||||
std::string backwardScript;
|
||||
};
|
||||
|
||||
struct ScheduledScript {
|
||||
ScheduledScript() : time(-DBL_MAX) { }
|
||||
ScheduledScript(const ghoul::Dictionary& dict);
|
||||
|
||||
double time;
|
||||
ReversibleLuaScript script;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Maintains an ordered list of \code ScheduledScripts.
|
||||
*/
|
||||
class ScriptScheduler {
|
||||
public:
|
||||
|
||||
void loadScripts(const std::string& filename);
|
||||
void loadScripts(const ghoul::Dictionary& dict);
|
||||
|
||||
void skipTo(double time);
|
||||
void skipTo(const std::string& timeStr);
|
||||
|
||||
std::queue<std::string> scheduledScripts(double newTime);
|
||||
std::queue<std::string> scheduledScripts(const std::string& timeStr);
|
||||
|
||||
const std::vector<ScheduledScript>& allScripts() const { return _scheduledScripts; };
|
||||
|
||||
static LuaLibrary luaLibrary();
|
||||
|
||||
private:
|
||||
|
||||
std::vector<ScheduledScript> _scheduledScripts;
|
||||
|
||||
size_t _currentIndex = 0;
|
||||
double _lastTime;
|
||||
|
||||
};
|
||||
|
||||
} // namespace scripting
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __SCRIPTSCHEDULER_H__
|
||||
@@ -82,6 +82,7 @@ set(OPENSPACE_SOURCE
|
||||
${OPENSPACE_BASE_DIR}/src/scene/scenegraphnode.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/lualibrary.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/scriptengine.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/scriptscheduler.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/scripting/scriptengine_lua.inl
|
||||
${OPENSPACE_BASE_DIR}/src/util/blockplaneintersectiongeometry.cpp
|
||||
${OPENSPACE_BASE_DIR}/src/util/boxgeometry.cpp
|
||||
@@ -169,6 +170,7 @@ set(OPENSPACE_HEADER
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/lualibrary.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/script_helper.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptengine.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/scripting/scriptscheduler.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/util/blockplaneintersectiongeometry.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/util/boxgeometry.h
|
||||
${OPENSPACE_BASE_DIR}/include/openspace/util/camera.h
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <openspace/rendering/renderable.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/scripting/scriptscheduler.h>
|
||||
#include <openspace/scene/ephemeris.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
@@ -49,6 +50,7 @@
|
||||
#include <openspace/util/syncbuffer.h>
|
||||
#include <openspace/util/transformationmanager.h>
|
||||
|
||||
|
||||
#include <ghoul/ghoul.h>
|
||||
#include <ghoul/cmdparser/commandlineparser.h>
|
||||
#include <ghoul/cmdparser/singlecommand.h>
|
||||
@@ -64,6 +66,7 @@
|
||||
#include <ghoul/misc/onscopeexit.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <queue>
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED
|
||||
#include <modules/onscreengui/include/gui.h>
|
||||
@@ -123,6 +126,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName,
|
||||
, _interactionHandler(new interaction::InteractionHandler)
|
||||
, _renderEngine(new RenderEngine)
|
||||
, _scriptEngine(new scripting::ScriptEngine)
|
||||
, _scriptScheduler(new scripting::ScriptScheduler)
|
||||
, _networkEngine(new NetworkEngine)
|
||||
, _commandlineParser(new ghoul::cmdparser::CommandlineParser(
|
||||
programName, ghoul::cmdparser::CommandlineParser::AllowUnknownCommands::Yes
|
||||
@@ -386,6 +390,7 @@ bool OpenSpaceEngine::initialize() {
|
||||
_scriptEngine->addLibrary(gui::GUI::luaLibrary());
|
||||
_scriptEngine->addLibrary(network::ParallelConnection::luaLibrary());
|
||||
_scriptEngine->addLibrary(ModuleEngine::luaLibrary());
|
||||
_scriptEngine->addLibrary(ScriptScheduler::luaLibrary());
|
||||
|
||||
#ifdef OPENSPACE_MODULE_ISWA_ENABLED
|
||||
_scriptEngine->addLibrary(IswaManager::luaLibrary());
|
||||
@@ -748,6 +753,12 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
Time::ref().advanceTime(dt);
|
||||
Time::ref().preSynchronization();
|
||||
|
||||
auto scheduledScripts = _scriptScheduler->scheduledScripts(Time::ref().currentTime());
|
||||
while(scheduledScripts.size()){
|
||||
_scriptEngine->queueScript(scheduledScripts.front());
|
||||
scheduledScripts.pop();
|
||||
}
|
||||
|
||||
_scriptEngine->preSynchronization();
|
||||
|
||||
_renderEngine->preSynchronization();
|
||||
@@ -771,7 +782,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
}
|
||||
|
||||
Time::ref().postSynchronizationPreDraw();
|
||||
|
||||
|
||||
_scriptEngine->postSynchronizationPreDraw();
|
||||
_renderEngine->postSynchronizationPreDraw();
|
||||
|
||||
@@ -782,6 +793,7 @@ void OpenSpaceEngine::postSynchronizationPreDraw() {
|
||||
_interactionHandler->postSynchronizationPreDraw();
|
||||
|
||||
// Update the synched variables in the camera class
|
||||
|
||||
_renderEngine->camera()->preSynchronization();
|
||||
_renderEngine->camera()->postSynchronizationPreDraw();
|
||||
|
||||
@@ -1019,6 +1031,11 @@ ScriptEngine& OpenSpaceEngine::scriptEngine() {
|
||||
return *_scriptEngine;
|
||||
}
|
||||
|
||||
ScriptScheduler& OpenSpaceEngine::scriptScheduler(){
|
||||
ghoul_assert(_scriptScheduler, "ScriptScheduler must not be nullptr");
|
||||
return *_scriptScheduler;
|
||||
}
|
||||
|
||||
LuaConsole& OpenSpaceEngine::console() {
|
||||
ghoul_assert(_console, "LuaConsole must not be nullptr");
|
||||
return *_console;
|
||||
|
||||
186
src/scripting/scriptscheduler.cpp
Normal file
186
src/scripting/scriptscheduler.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2016 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#include <openspace/scripting/scriptscheduler.h>
|
||||
|
||||
#include <openspace/engine/openspaceengine.h>
|
||||
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/spicemanager.h> // parse time
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/filesystem/filesystem>
|
||||
|
||||
|
||||
namespace openspace {
|
||||
namespace scripting {
|
||||
|
||||
namespace {
|
||||
const std::string _loggerCat = "ScriptScheduler";
|
||||
|
||||
const std::string KEY_TIME = "Time";
|
||||
const std::string KEY_FORWARD_SCRIPT = "ReversibleLuaScript.Forward";
|
||||
const std::string KEY_BACKWARD_SCRIPT = "ReversibleLuaScript.Backward";
|
||||
}
|
||||
|
||||
|
||||
ScheduledScript::ScheduledScript(const ghoul::Dictionary& dict)
|
||||
: ScheduledScript() // default init first
|
||||
{
|
||||
std::string timeStr;
|
||||
if (dict.getValue(KEY_TIME, timeStr)) {
|
||||
time = SpiceManager::ref().ephemerisTimeFromDate(timeStr);
|
||||
|
||||
if (!dict.getValue(KEY_FORWARD_SCRIPT, script.forwardScript)) {
|
||||
LERROR("Unable to read " << KEY_FORWARD_SCRIPT);
|
||||
}
|
||||
if (!dict.getValue(KEY_BACKWARD_SCRIPT, script.backwardScript)) {
|
||||
LERROR("Unable to read " << KEY_BACKWARD_SCRIPT);
|
||||
}
|
||||
}
|
||||
else {
|
||||
LERROR("Unable to read " << KEY_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptScheduler::loadScripts(const std::string& filepath) {
|
||||
ghoul::Dictionary timedScriptsDict;
|
||||
try {
|
||||
ghoul::lua::loadDictionaryFromFile(absPath(filepath), timedScriptsDict);
|
||||
}
|
||||
catch (const ghoul::RuntimeError& e) {
|
||||
LERROR(e.what());
|
||||
return;
|
||||
}
|
||||
loadScripts(timedScriptsDict);
|
||||
}
|
||||
|
||||
void ScriptScheduler::loadScripts(const ghoul::Dictionary& dict) {
|
||||
for (size_t i = 0; i < dict.size(); ++i) {
|
||||
std::string id = std::to_string(i + 1);
|
||||
const ghoul::Dictionary& timedScriptDict = dict.value<ghoul::Dictionary>(id);
|
||||
_scheduledScripts.push_back(ScheduledScript(timedScriptDict));
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptScheduler::skipTo(double newTime) {
|
||||
if (newTime > _lastTime) {
|
||||
while (_currentIndex < _scheduledScripts.size() && _scheduledScripts[_currentIndex].time <= newTime) {
|
||||
_currentIndex++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (0 < _currentIndex && _scheduledScripts[_currentIndex - 1].time > newTime) {
|
||||
_currentIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ScriptScheduler::skipTo(const std::string& timeStr) {
|
||||
skipTo(SpiceManager::ref().ephemerisTimeFromDate(timeStr));
|
||||
}
|
||||
|
||||
|
||||
std::queue<std::string> ScriptScheduler::scheduledScripts(double newTime) {
|
||||
std::queue<std::string> triggeredScripts;
|
||||
if (newTime > _lastTime) {
|
||||
while(_currentIndex < _scheduledScripts.size() && _scheduledScripts[_currentIndex].time <= newTime){
|
||||
triggeredScripts.push(_scheduledScripts[_currentIndex].script.forwardScript);
|
||||
_currentIndex++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (0 < _currentIndex && _scheduledScripts[_currentIndex - 1].time > newTime) {
|
||||
triggeredScripts.push(_scheduledScripts[_currentIndex - 1].script.backwardScript);
|
||||
_currentIndex--;
|
||||
}
|
||||
}
|
||||
|
||||
_lastTime = newTime;
|
||||
return triggeredScripts;
|
||||
}
|
||||
|
||||
std::queue<std::string> ScriptScheduler::scheduledScripts(const std::string& timeStr) {
|
||||
return std::move(scheduledScripts(SpiceManager::ref().ephemerisTimeFromDate(timeStr)));
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
// Lua library functions //
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace luascriptfunctions {
|
||||
int loadTimedScripts(lua_State* L) {
|
||||
using ghoul::lua::luaTypeToString;
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
|
||||
std::string missionFileName = luaL_checkstring(L, -1);
|
||||
if (missionFileName.empty()) {
|
||||
return luaL_error(L, "filepath string is empty");
|
||||
}
|
||||
|
||||
OsEng.scriptScheduler().loadScripts(missionFileName);
|
||||
}
|
||||
|
||||
int skipTo(lua_State* L) {
|
||||
using ghoul::lua::luaTypeToString;
|
||||
int nArguments = lua_gettop(L);
|
||||
if (nArguments != 1)
|
||||
return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments);
|
||||
|
||||
std::string dateStr = luaL_checkstring(L, -1);
|
||||
if (dateStr.empty()) {
|
||||
return luaL_error(L, "date string is empty");
|
||||
}
|
||||
|
||||
OsEng.scriptScheduler().skipTo(dateStr);
|
||||
}
|
||||
} // namespace luascriptfunction
|
||||
|
||||
|
||||
|
||||
LuaLibrary ScriptScheduler::luaLibrary() {
|
||||
return {
|
||||
"scriptScheduler",
|
||||
{
|
||||
{
|
||||
"load",
|
||||
&luascriptfunctions::loadTimedScripts,
|
||||
"string",
|
||||
"Load timed scripts from file"
|
||||
},
|
||||
{
|
||||
"skipTo",
|
||||
&luascriptfunctions::skipTo,
|
||||
"string",
|
||||
"skip to a time without executing scripts"
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace scripting
|
||||
|
||||
} // namespace openspace
|
||||
Reference in New Issue
Block a user