For example, given some SSC code similar to this:
Code: Select all
"myobject-01" "Sol/Earth"
{
OrbitFrame
{
. . .
}
ScriptedOrbit
{
Module "myscripts"
Function "location01"
TimeBase 2451545.0
}
}
"myobject-02" "Sol/Earth"
{
OrbitFrame
{
. . .
}
ScriptedOrbit
{
Module "myscripts"
Function "location01"
TimeBase 2451545.0
}
}
Obviously each instantiation of the script knows which object it's modifying (or it wouldn't work at all), but is there a standard syntax (eg. like "self:object()") to refer to the object of context from within the script?
ie.
What should <ssc-object> be replaced with, in the following...
Code: Select all
function location01(t)
-- Create a new table
local orbit = {};
orbit.params = t;
orbit.timebase = t.TimeBase
-- Set the required fields boundingRadius and position; note
-- that position is actually a function.
orbit.boundingRadius = 1000
function orbit:position(tjd)
local t = (tjd - self.timebase) * 86400;
local x = 0
local y = 0
local z = 0
if <ssc-object>:name() == "myobject-01" then
. . .
elseif <ssc-object>:name() == "myobject-02" then
. . .
else
. . .
end
return x, y, z
end
return orbit
end
NOTE: I know that I could pass in the name of the SSC object as part of the parameter list, and then retrieve the object from it's name, but that seems a little messy to me and clutters the SSC needlessly, given that IMO the script should already know it's context.