Ok, I whipped this up real quick and did some rudimentary testing.
I threw this into the speech responder 'Jumped' script for testing, but it could also go into the 'Jumping' (or any other) script...
Code:
{if state.destination:
{set dest to SystemDetails(state.destination)}
{set diff_x to sub(dest.x, system.x)}
{set diff_y to sub(dest.y, system.y)}
{set diff_z to sub(dest.z, system.z)}
{set pow_x to pow(diff_x, 2)}
{set pow_y to pow(diff_y, 2)}
{set pow_z to pow(diff_z, 2)}
{set distance to add(pow_x, pow_y)}
{set distance to add(distance, pow_z)}
{set distance to pow(distance, 0.5)}
{set distance to round(distance, 1)}
Distance to {state.destination} is {distance} light years.
}
It's written for readability over efficiency, so feel free to obfuscate to your heart's content!
With regards to Voice Attack, here are some examples for setting and clearing the 'destination' variable...
VA Command called 'Set destination'. Currently set to Sol...
Code:
Set Text [destination] to 'Sol'
Set Text [State variable] to 'destination'
Execute external plugin, 'EDDI 2.1.0-b3' and wait for return (context = setstate, Text Variables = State variable)
VA Command called 'Clear destination'. Sets 'destination' to 'Not Set'
Code:
Set Text [destination] to [Not Set]
Set Text [State variable] to 'destination'
Execute external plugin, 'EDDI 2.1.0-b3' and wait for return (context = setstate, Text Variables = State variable)
Standard disclaimer... Guaranteed until you can no longer see my tail lights, YMMV.