diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset index 4b6aa574c2..0d45b5abd9 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/charon/charon.asset @@ -13,8 +13,7 @@ local Charon = { Translation = { Type = "SpiceTranslation", Target = "CHARON", - Observer = "PLUTO BARYCENTER", - Kernels = NewHorizonsKernels + Observer = "PLUTO BARYCENTER" }, Rotation = { Type = "SpiceRotation", diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/kerberos.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/kerberos.asset index 0434de709b..fb2ddb43a6 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/kerberos.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/kerberos.asset @@ -11,8 +11,7 @@ local Kerberos = { Translation = { Type = "SpiceTranslation", Target = "KERBEROS", - Observer = "PLUTO BARYCENTER", - Kernels = PlutoKernels + Observer = "PLUTO BARYCENTER" } }, Renderable = { diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/nix.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/nix.asset index bea389470d..c5f7e03923 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/nix.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/nix.asset @@ -11,8 +11,7 @@ local Nix = { Translation = { Type = "SpiceTranslation", Target = "NIX", - Observer = "PLUTO BARYCENTER", - Kernels = PlutoKernels + Observer = "PLUTO BARYCENTER" } }, Renderable = { diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/styx.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/styx.asset index 25c369e4e7..bc54df433a 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/styx.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/minor/styx.asset @@ -3,7 +3,6 @@ local transforms = asset.require('../transforms') local kernels = asset.require('../kernels').PlutoKernels - local Styx = { Identifier = "Styx", Parent = transforms.PlutoBarycenter.Identifier, @@ -11,8 +10,7 @@ local Styx = { Translation = { Type = "SpiceTranslation", Target = "STYX", - Observer = "PLUTO BARYCENTER", - Kernels = PlutoKernels + Observer = "PLUTO BARYCENTER" } }, Renderable = { diff --git a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset index 5299ebc5dd..968a7edd86 100644 --- a/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset +++ b/data/assets/scene/solarsystem/dwarf_planets/pluto/pluto.asset @@ -13,8 +13,7 @@ local Pluto = { Translation = { Type = "SpiceTranslation", Target = "PLUTO", - Observer = "PLUTO BARYCENTER", - Kernels = NewHorizonsKernels + Observer = "PLUTO BARYCENTER" }, Rotation = { Type = "SpiceRotation", diff --git a/data/assets/scene/solarsystem/missions/apollo/11/lem_flipbook.asset b/data/assets/scene/solarsystem/missions/apollo/11/lem_flipbook.asset index a716eb4626..06e4259d50 100644 --- a/data/assets/scene/solarsystem/missions/apollo/11/lem_flipbook.asset +++ b/data/assets/scene/solarsystem/missions/apollo/11/lem_flipbook.asset @@ -18,13 +18,8 @@ asset.onInitialize(function () openspace.globebrowsing.addBlendingLayersFromDirectory(vrts, assetGlobe); flipbook = helper.createFlipbook(assetPrefix, assetGlobe, 19); - function nextFlip() - helper.nextFlipbookPage(flipbook); - end - - function previousFlip() - helper.previousFlipbookPage(flipbook); - end + rawset(_G, "nextFlip", function() helper.nextFlipbookPage(flipbook) end) + rawset(_G, "previousFlip", function() helper.previousFlipbookPage(flipbook) end) openspace.bindKey("p", "nextFlip()", "Show the next Apollo 11 flipbook image.", "Next A11 flip", "/Missions/Apollo/11") openspace.bindKey("o", "previousFlip()","Show the previous Apollo 11 flipbook image.", "Prev A11 flip", "/Missions/Apollo/11") diff --git a/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset b/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset index ce2f3b32bc..68e23b4742 100644 --- a/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset +++ b/data/assets/scene/solarsystem/missions/messenger/messengerSC.asset @@ -172,7 +172,7 @@ local MessengerTrail = { Type = "SpiceTranslation", Target = "MESSENGER", Observer = "MERCURY BARYCENTER", - Kernels = Kernels + Kernels = LocalKernels }, Color = { 0.288, 0.375, 0.934 }, EnableFade = false, diff --git a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset index 3a963722e2..35210c0e09 100644 --- a/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset +++ b/data/assets/scene/solarsystem/missions/newhorizons/pluto.asset @@ -1,6 +1,7 @@ local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') local sunTransforms = asset.require('scene/solarsystem/sun/transforms') +local NewHorizonsKernels = asset.require('./kernels').NewHorizonsKernels local assets = asset.syncedResource({ Name = "Pluto Assets", diff --git a/data/assets/scene/solarsystem/planets/neptune/irregular_prograde_moons.asset b/data/assets/scene/solarsystem/planets/neptune/irregular_prograde_moons.asset index 632ebd6859..826e6366c4 100644 --- a/data/assets/scene/solarsystem/planets/neptune/irregular_prograde_moons.asset +++ b/data/assets/scene/solarsystem/planets/neptune/irregular_prograde_moons.asset @@ -3,7 +3,7 @@ local proceduralGlobes = asset.require('util/procedural_globe') local transforms = asset.require('./transforms') local kernels = asset.require('./kernels') local kernel081 = kernels.nep081 -local kernel087 = kernels.nep087 +local kernel086 = kernels.nep086 local kernel088 = kernels.nep088 diff --git a/data/assets/util/asset_helper.asset b/data/assets/util/asset_helper.asset index 77a28382f1..e5cf1582e6 100644 --- a/data/assets/util/asset_helper.asset +++ b/data/assets/util/asset_helper.asset @@ -13,7 +13,7 @@ local registerSpiceKernels = function (spiceAsset, kernels) end) spiceAsset.onDeinitialize(function () for i = #kernels, 1, -1 do - kernel = kernels[i] + local kernel = kernels[i] openspace.spice.unloadKernel(kernel) end end) @@ -75,7 +75,7 @@ local registerDashboardItems = function (dashboardAsset, items) ) dashboardAsset.onDeinitialize(function () for i = #items, 1, -1 do - item = items[i] + local item = items[i] openspace.dashboard.removeDashboardItem(item.Identifier) end end) @@ -103,7 +103,7 @@ local registerSceneGraphNodesAndExport = function (sceneAsset, nodes, override) end) sceneAsset.onDeinitialize(function () for i = #nodes, 1, -1 do - node = nodes[i] + local node = nodes[i] openspace.removeSceneGraphNode(node.Identifier) end end) diff --git a/data/assets/util/procedural_globe.asset b/data/assets/util/procedural_globe.asset index 23198f2e65..4c34de326a 100644 --- a/data/assets/util/procedural_globe.asset +++ b/data/assets/util/procedural_globe.asset @@ -68,7 +68,7 @@ local createGlobes = function(t) end end - result = {} + local result = {} for i, v in ipairs(t) do local globe = nil diff --git a/data/assets/util/static_server.asset b/data/assets/util/static_server.asset index 3e98da9fdd..936f18277f 100644 --- a/data/assets/util/static_server.asset +++ b/data/assets/util/static_server.asset @@ -10,7 +10,7 @@ local backend = asset.syncedResource({ asset.onInitialize(function () -- Unzip the server bundle - dest = backend .. "/backend" + local dest = backend .. "/backend" if not openspace.directoryExists(dest) then openspace.unzipFile(backend .. "/backend.zip", dest, true) end diff --git a/data/assets/util/tle_helper.asset b/data/assets/util/tle_helper.asset index fdcccdbb43..6a80121695 100644 --- a/data/assets/util/tle_helper.asset +++ b/data/assets/util/tle_helper.asset @@ -24,7 +24,7 @@ end -- Check format of a set of 3 TLE file lines and return nonzero if there is a format error function isValidTLEFileFormat(lineArr) - function isEmpty(s) return s == nil or s == '' end + local function isEmpty(s) return s == nil or s == '' end if isEmpty(lineArr[1]) or isEmpty(lineArr[2]) or isEmpty(lineArr[3]) then return false diff --git a/ext/ghoul b/ext/ghoul index 1413844185..bddc5370d7 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 1413844185b244559b8b90a06e03ddcea33fb2b5 +Subproject commit bddc5370d7dd8bc8ab05f2a234a12f2d0e266ca4 diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index 9771fd8b3f..e6153e0d84 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -118,7 +118,7 @@ end openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, startDate, endDate, timeResolution, resolution, format, temporalFormat) temporalFormat = temporalFormat or 'YYYY-MM-DD' - temporalTemplate = + local temporalTemplate = "" .. "" .. startDate .. "" .. "" .. endDate .. "" .. @@ -130,7 +130,7 @@ openspace.globebrowsing.createTemporalGibsGdalXml = function (layerName, startDa end openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolution, format) - tileLevel = 5 + local tileLevel = 5 -- These resolutions are defined by GIBS: https://wiki.earthdata.nasa.gov/display/GIBS/GIBS+API+for+Developers#GIBSAPIforDevelopers-Script-levelAccessviaGDAL if resolution == "2km" then tileLevel = 5 @@ -153,7 +153,7 @@ openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolutio return "" end - rasterCount = 3 + local rasterCount = 3 if format == "jpg" then if layerName == "ASTER_GDEM_Greyscale_Shaded_Relief" then rasterCount = 1 @@ -167,7 +167,7 @@ openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolutio return "" end - gdalWmsTemplate = + local gdalWmsTemplate = "" .. "" .. "https://gibs.earthdata.nasa.gov/wmts/epsg4326/best/" .. @@ -198,14 +198,21 @@ openspace.globebrowsing.createGibsGdalXml = function (layerName, date, resolutio end openspace.globebrowsing.parseInfoFile = function (file) - Name = nil - Identifier = nil - Description = nil - ColorFile = nil - HeightFile = nil + -- We are loading these values from an external info file and since we are switching + -- to a strict Lua, we need to predefine these global variables + local function declare(name) + rawset(_G, name, "") + end + + declare("Name") + declare("Identifier") + declare("Description") + declare("ColorFile") + declare("HeightFile") + declare("Location") local dir = openspace.directoryForPath(file) - file_func, error = loadfile(file) + local file_func, error = loadfile(file) if file_func then file_func() else @@ -213,6 +220,15 @@ openspace.globebrowsing.parseInfoFile = function (file) return nil, nil, nil, nil end + -- Hoist the global variables into local space + local Name = rawget(_G, "Name") + local Identifier = rawget(_G, "Identifier") + local Description = rawget(_G, "Description") + local ColorFile = rawget(_G, "ColorFile") + local HeightFile = rawget(_G, "HeightFile") + local Location = rawget(_G, "Location") + + -- Now we can start local name = Name or Identifier local identifier = Identifier or Name @@ -222,7 +238,7 @@ openspace.globebrowsing.parseInfoFile = function (file) end local color = nil - if ColorFile then + if ColorFile and ColorFile ~= "" then color = { Identifier = identifier, Name = name, @@ -233,7 +249,7 @@ openspace.globebrowsing.parseInfoFile = function (file) end local height = nil - if HeightFile then + if HeightFile and HeightFile ~= "" then height = { Identifier = identifier, Name = name, diff --git a/scripts/strict.lua b/scripts/strict.lua deleted file mode 100644 index 088ef4c62d..0000000000 --- a/scripts/strict.lua +++ /dev/null @@ -1,40 +0,0 @@ --- strict.lua --- checks uses of undeclared global variables --- All global variables must be 'declared' through a regular assignment --- (even assigning nil will do) in a main chunk before being used --- anywhere or assigned to inside a function. --- distributed under the Lua license: http://www.lua.org/license.html - -local getinfo, error, rawset, rawget = debug.getinfo, error, rawset, rawget - -local mt = getmetatable(_G) -if mt == nil then - mt = {} - setmetatable(_G, mt) -end - -mt.__declared = {} - -local function what () - local d = getinfo(3, "S") - return d and d.what or "C" -end - -mt.__newindex = function (t, n, v) - if not mt.__declared[n] then - local w = what() - if w ~= "main" and w ~= "C" then - error("assign to undeclared variable '"..n.."'", 2) - end - mt.__declared[n] = true - end - rawset(t, n, v) -end - -mt.__index = function (t, n) - if not mt.__declared[n] and what() ~= "C" then - error("variable '"..n.."' is not declared", 2) - end - return rawget(t, n) -end - diff --git a/src/engine/configuration.cpp b/src/engine/configuration.cpp index e168e90877..f063bded20 100644 --- a/src/engine/configuration.cpp +++ b/src/engine/configuration.cpp @@ -37,7 +37,6 @@ namespace { // We can't use ${SCRIPTS} here as that hasn't been defined by this point constexpr const char* InitialConfigHelper = "${BASE}/scripts/configuration_helper.lua"; - constexpr const char* StrictLuaScript = "${BASE}/scripts/strict.lua"; struct [[codegen::Dictionary(Configuration)]] Parameters { // The SGCT configuration file that determines the window and view frustum @@ -650,9 +649,6 @@ Configuration loadConfigurationFromFile(const std::string& filename, if (FileSys.fileExists(absPath(InitialConfigHelper))) { ghoul::lua::runScriptFile(result.state, absPath(InitialConfigHelper)); } - if (FileSys.fileExists(absPath(StrictLuaScript))) { - ghoul::lua::runScriptFile(result.state, absPath(StrictLuaScript)); - } // Load the configuration file into the state ghoul::lua::runScriptFile(result.state, filename); diff --git a/support/coding/codegen b/support/coding/codegen index d1e354f072..2efd176817 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit d1e354f07257d37b241d7c8d3a85eef3d0cb62bd +Subproject commit 2efd1768176c1559b8eda3cbdcaeea2ded46e145