I need it to make so that the md script interrupts the travel engine (I transformed into an hyperdrive with very high speed) to avoid the player to travel inside a planet. At very high speed the collision does not work and anyway I want that the speed returns to normal in proximity of a planet, for both immersion and gameplay.
Seems that no matter how I recall the planet, I get a lookup error when asking to calculate player.entity or player.ship distance from it.
First, the only conditions that work are <event_player_travelmode_started/> or <event_player_changed_activity activity="activity.travel" /> and so on.
If I try to use an <event_cue_signalled cue="md.Setup.Start"/> nothing happens, even with instantiate="true".
Then the part that matters most, I tried to call the planet in more than one way, as is used for instance in the md/terraforming.xml.
Code: Select all
<set_value name="$Sector" exact="player.sector"/>
<set_value name="$Cluster" exact="$Sector.cluster"/>
<set_value name="$ClosePlanet" exact="$Cluster.planets"/>
<set_value name="$PlayerShip" exact="player.ship"/>
Code: Select all
<find_cluster_in_range name="$Cluster" object="$Sector" maxdistance="1" multiple="true" sortbydistanceto="$PlayerShip" sortlimit="1"/>
<find_object_component name="$ClosePlanet" object="$Cluster" class="class.planet" multiple="true" sortbydistanceto="$PlayerShip" sortlimit="1"/>
Code: Select all
<set_value name="$ClosePlanetSize" exact="$ClosePlanet.size"/>

finally, the not working code:
Code: Select all
<do_if value="(player.activity == activity.travel or $PlayerShip.travel.active) and ($ClosePlanet.distanceto.{$PlayerShip} lt 200km)">
<play_sound sound="'ui_interaction_not_possible'" type="ui" />
<set_cockpit_tint resettodefault="true" sethudcolors="true" />
<set_player_activity activity="activity.none" />
<speak actor="player.computer" line="30224658" priority="1" comment="Planet is nearby. Travel Mode is not possible." />
<show_help duration="3s" custom="'You are too close to a planet to use the Travel Drive'"/>
<set_playership_throttle value="100" comment="to force stop, no matter what"/>
<force_player_speed speed="100" comment="Throttle value (defaults to 0) (-1 for full reverse, 0 for stop and 1 for full forward)"/>
</do_if>
* Expression: (player.activity == activity.travel or $PlayerShip.travel.active) and $ClosePlanet.distanceto.{$PlayerShip} lt 200000m
I tried 20000km as test, because it is so big that any distance has to be included, but errors are always, no matter how I calculate the distance or if I use the $ClosePlanetSize
Action is anyway activated but only the (player.activity == activity.travel or $PlayerShip.travel.active) is read so of course (as expected) the traveldrive deactivates always at any distance, because $ClosePlanet.distanceto.{$PlayerShip} is discarded.
I tried several others way to recall the planet in the sector or in the cluster, using simple <find_cluster, <find_sector, nothing seems to work
