Move Exoplanet creation code from C++ to Lua (#3450)

* Move exoplanet creation code to Lua

* Add more descriptions and handle missing values

* Remove old creation function and move load from CSV to Lua

* Properly document all functions, including a type for the `systemData` return value

* Add `\param` documentation to the scripts

* Cleanup and move helper functions to core scripts

* Throw Lua errors when things go wrong, instead of returning empty objects

This prevents the rest of the code from being run

* Flesh out TODO comments, so future us know why they are there


---------

Co-authored-by: Alexander Bock <alexander.bock@liu.se>
This commit is contained in:
Emma Broman
2024-10-21 09:30:18 +02:00
committed by GitHub
parent 6dd3dd8ab8
commit 68c2157dd4
10 changed files with 1268 additions and 796 deletions

View File

@@ -88,6 +88,38 @@ openspace.documentation = {
target several nodes. If the fade time is not provided then the
"OpenSpaceEngine.FadeDuration" property will be used instead. If the third argument
(endScript) is provided then that script will be run after the fade is finished.]]
},
{
Name = "ternary",
Arguments = {
{ "condition", "Boolean" },
{ "trueValue", "any" },
{ "falseValue", "any" }
},
Return = "any",
Documentation = [[
A utility function to return a specific value based on a True/False condition.
\\param condition The condition to check against
\\param trueValue The value to return if the condition is True
\\param falseValue The value to return if the condition is False
\\return Either the trueValue of falseValue, depending on if the condition is true
or not
]]
},
{
Name = "isEmpty",
Arguments = {
{ "object", "any" }
},
Return = "Boolean",
Documentation = [[
A utility function to check whether an object is empty or not. Identifies `nil`
objects, Tables without any keys, and empty strings.
\\param object The object to check
\\return A Boolean that specifies if the object is empty or not
]]
}
}
@@ -305,3 +337,15 @@ openspace.toggleFade = function(renderable, fadeTime, endScript)
openspace.fadeIn(renderable, fadeTime, endScript)
end
end
openspace.ternary = function(condition, trueValue, falseValue)
if condition then return trueValue else return falseValue end
end
openspace.isEmpty = function(v)
if type(v) == "table" then
return next(v) == nil
else
return v == nil or v == ''
end
end