Nivekk / KOS

Fully programmable autopilot mod for KSP.
Other
80 stars 30 forks source link

Made SpecialValue even more special. ... #207

Open palaslet opened 10 years ago

palaslet commented 10 years ago

Override of "Value" property enables projection of different datatype when no suffix is used. An example would be:

SENSOR:ACC:ACTIVE -> Here the SENSOR:ACC returns a sensor object that can handle suffixes. SENSOR:ACC without suffix would return the object of the Value property. This example returns a vector that can be used for vector operations. SENSOR:ACC:MAG -> since the sensor object does not support the MAG suffix, the expression engine tries to use the object returned from the Value property before it fails. In this example the Value property returns a vector and thus the term is valid and will return the magnitude of the vector representing the sensor value.

The default implementation is to return the SpecialValue itself ("return this;"). This ensures no existing functionality is affected.

Nivekk commented 10 years ago

I'll take a closer look at this one when I get the chance. I agree with what you're doing but I think I might want to implement it differently.