mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 03:00:58 -06:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user