diff --git a/data/assets/actions/planets/planet_lighting.asset b/data/assets/actions/planets/planet_lighting.asset index 83c3441b69..dc7f692ccc 100644 --- a/data/assets/actions/planets/planet_lighting.asset +++ b/data/assets/actions/planets/planet_lighting.asset @@ -43,7 +43,7 @@ end]] return commandString end -local function getIlluminationAction(node, global) +local function getIlluminationAction(node, node_lower, global) local actionString = "_standard_illumination" local actionName = "Standard Illumination" local actionCommand = getIlluminationCommand(node, global) @@ -54,7 +54,7 @@ local function getIlluminationAction(node, global) end local action = { - Identifier = "os." .. string.gsub(node, "%s+", "") .. actionString, + Identifier = "os." .. string.gsub(node_lower, "%s+", "") .. actionString, Name = node .. " " .. actionName, Command = actionCommand, Documentation = "Enables " .. string.lower(actionName) .. " for" .. node, @@ -64,34 +64,34 @@ local function getIlluminationAction(node, global) return action end -local current_focus_global = getIlluminationAction("Current Focus", true) +local current_focus_global = getIlluminationAction("Current Focus", "current_focus", true) asset.export("current_focus_global", current_focus_global.Identifier) -local current_focus_standard = getIlluminationAction("Current Focus", false) +local current_focus_standard = getIlluminationAction("Current Focus", "current_focus", false) asset.export("current_focus_standard", current_focus_standard.Identifier) -local earth_global = getIlluminationAction("Earth", true) +local earth_global = getIlluminationAction("Earth", "earth", true) asset.export("earth_global", earth_global.Identifier) -local earth_standard = getIlluminationAction("Earth", false) +local earth_standard = getIlluminationAction("Earth", "earth", false) asset.export("earth_standard", earth_standard.Identifier) -local mars_global = getIlluminationAction("Mars", true) +local mars_global = getIlluminationAction("Mars", "mars", true) asset.export("mars_global", mars_global.Identifier) -local mars_standard = getIlluminationAction("Mars", false) +local mars_standard = getIlluminationAction("Mars", "mars", false) asset.export("mars_standard", mars_standard.Identifier) -local venus_global = getIlluminationAction("Venus", true) +local venus_global = getIlluminationAction("Venus", "venus", true) asset.export("venus_global", venus_global.Identifier) -local venus_standard = getIlluminationAction("Venus", false) +local venus_standard = getIlluminationAction("Venus", "venus", false) asset.export("venus_standard", venus_standard.Identifier) -local titan_global = getIlluminationAction("Titan", true) +local titan_global = getIlluminationAction("Titan", "titan", true) asset.export("titan_global", titan_global.Identifier) -local titan_standard = getIlluminationAction("Titan", false) +local titan_standard = getIlluminationAction("Titan", "titan", false) asset.export("titan_standard", titan_standard.Identifier) -local saturn_global = getIlluminationAction("Saturn", true) +local saturn_global = getIlluminationAction("Saturn", "saturn", true) asset.export("saturn_global", saturn_global.Identifier) -local saturn_standard = getIlluminationAction("Saturn", false) +local saturn_standard = getIlluminationAction("Saturn", "saturn", false) asset.export("titan_standard", saturn_standard.Identifier) diff --git a/scripts/core_scripts.lua b/scripts/core_scripts.lua index d227205716..8237fe66be 100644 --- a/scripts/core_scripts.lua +++ b/scripts/core_scripts.lua @@ -76,7 +76,7 @@ openspace.setDefaultGuiSorting = function() end openspace.rebindKey = function(oldKey, newKey) - local t = openspace.getKeyBinding(oldKey) + local t = openspace.keyBindings(oldKey) openspace.clearKey(oldKey) for _, v in pairs(t) do openspace.bindKey(newKey, v) diff --git a/src/engine/openspaceengine_lua.inl b/src/engine/openspaceengine_lua.inl index 1b512505ab..61ccabcedb 100644 --- a/src/engine/openspaceengine_lua.inl +++ b/src/engine/openspaceengine_lua.inl @@ -104,12 +104,6 @@ namespace { LTRACEC("OpenSpaceEngine", fmt::format("waiting {}", future->errorMessage)); } } - - if (!future || !future->isFinished) { - throw ghoul::lua::LuaError( - future ? "Download failed: " + future->errorMessage : "Download failed" - ); - } } } // namespace diff --git a/src/scripting/scriptengine.cpp b/src/scripting/scriptengine.cpp index b61ed05a3a..c9da5e5e75 100644 --- a/src/scripting/scriptengine.cpp +++ b/src/scripting/scriptengine.cpp @@ -756,10 +756,9 @@ void ScriptEngine::addBaseLibrary() { codegen::lua::DirectoryExists, codegen::lua::WalkDirectory, codegen::lua::WalkDirectoryFiles, - codegen::lua::WalkDirectoryFolder, + codegen::lua::WalkDirectoryFolders, codegen::lua::DirectoryForPath, - codegen::lua::UnzipFile, - codegen::lua::SaveLastChangeToProfile + codegen::lua::UnzipFile } }; addLibrary(lib); diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index fc201daf0d..1ec9ad551c 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -183,9 +183,9 @@ std::vector walkCommon(std::string path, bool recursive, bool sorte * default value for this parameter is "false". The third argument determines whether the * table that is returned is sorted. The default value for this parameter is "false". */ -[[codegen::luawrap]] std::vector walkDirectoryFolder(std::string path, - bool recursive = false, - bool sorted = false) +[[codegen::luawrap]] std::vector walkDirectoryFolders(std::string path, + bool recursive = false, + bool sorted = false) { namespace fs = std::filesystem; return walkCommon( @@ -241,82 +241,6 @@ std::vector walkCommon(std::string path, bool recursive, bool sorte } } -// Saves the last entry from the script log to the current profile. -[[codegen::luawrap]] void saveLastChangeToProfile() { - using namespace openspace; - std::string asset = global::configuration->asset; - std::filesystem::path logFilePath = absPath(global::configuration->scriptLog); - std::ifstream logfile(logFilePath); - std::string actualLastLine; - std::string lastLine; - std::string line; - // add check for log file - if (!logfile.good()) { - throw ghoul::lua::LuaError(fmt::format( - "Could not open scriptlog {}", logFilePath - )); - } - while (std::getline(logfile, line)) { - actualLastLine = lastLine; - lastLine = line; - } - - if (actualLastLine.find("openspace.setPropertyValue") == std::string::npos) { - throw ghoul::lua::LuaError("Only property value changes can be saved"); - } - - std::string dataString = "${ASSETS}/"; - std::filesystem::path assetPath = absPath(fmt::format( - "{}{}.scene", dataString, asset - )); - std::filesystem::path tempAssetPath = absPath(fmt::format( - "{}{}.scene.tmp", dataString, asset - )); - std::string strReplace = "--customizationsend"; - std::string strNew = fmt::format("{}\n{}", actualLastLine, strReplace); - std::ifstream filein(assetPath); - std::ofstream fileout(tempAssetPath); - if (!filein) { - throw ghoul::lua::LuaError(fmt::format( - "Could not open profile {}", assetPath - )); - } - if (!fileout) { - throw ghoul::lua::LuaError(fmt::format( - "Could not open tmp profile {}", tempAssetPath - )); - } - - bool found = false; - while (std::getline(filein, line)) { - if (line == strReplace) { - line = strNew; - found = true; - } - line += "\n"; - fileout << line; - } - filein.close(); - fileout.close(); - if (found) { - if (std::filesystem::is_regular_file(assetPath)) { - std::filesystem::remove(assetPath); - } - int success = rename(tempAssetPath.string().c_str(), assetPath.string().c_str()); - if (success != 0) { - throw ghoul::lua::LuaError(fmt::format( - "Error renaming file {} to {}", tempAssetPath, assetPath - )); - } - if (std::filesystem::is_regular_file(tempAssetPath)) { - std::filesystem::remove(tempAssetPath); - } - } - else { - throw ghoul::lua::LuaError("Can not save to built in profiles"); - } -} - #include "scriptengine_lua_codegen.cpp" } // namespace