Space Engineers

Space Engineers

Not enough ratings
Grand Cruise 2.0 Guide
By Survival Ready
The manual describes the process of installing and configuring the Grand Cruise script ver.2.0 for safe ship flights in gravity and space
   
Award
Favorite
Favorited
Unfavorite
Introduction
Originally posted by Unknow Space Engineer:
Idea, implementation, experiment and repetition of the last two until the result is achieved.
In short, the script will try in every way to resist your attempts to crash the ship into an obstacle along the course of movement or into the surface of the planet.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2518014684
During the flight in planet gravity, you have access to all the usual controls of the ship, except for the ability to change the angles of inclination in pitch and roll. There are no such restrictions in space.For those who don't know, here are some definitions:

Raycast — the ability of the camera to touch an obstacle with a ray and get information about it
Pitch — angle of inclination of the ship from nose to tail (mouse forward/backward in the game)
Roll — the angle of the ship along the longitudinal axis (in the game, the Q and E keys)

The script is configured by setting the values of several variables, which are located in the code header. Most of them are optional, but they will allow you to take into account some of the design features of your ship for a safer flight.

In this guide I will describe their impact on the gameplay under the control of this script. First of all, set the game constants if you are playing in a world where speed mods are installed or the game inventory multiplier is used:
const int xrate = 1; // World constant: cargo blocks multiplicator const double mvel = 100; // World constant: maximum velocity
Installing the script
You will need a program block in which you will need to load the subscription script from the Steam workshop. I recommend that you immediately include the word "cruise" in its name to see information about your ship.


You can change the values ​​of the variables after the "=" sign; the names of the variables before it do not need to be changed. After loading the script code, immediately pay attention to the variable
string referent = ""; // exact controller custom name (optional)
This is the name of the control controller block (cockpit, pilot's seat, control station, etc.) from which the script receives information about the altitude above the planet's surface. By default, the first available controller that can control the ship is taken, but due to design features, especially for large ships, this block may be at an altitude higher than the one set in the variable
float minalt = 30; // minimal altitude correction in meters (0 = off)
You should take this into account and choose the one below as the main controller. The easiest way is to use the remote control unit, which, although not used in ver. 2.0, can be useful in this capacity.

After installing the script on the screen of the software block, you will be able to see the main characteristics of your ship and estimate its thrust reserve.

Flight safety
There are four variables responsible for this
double raycast = 100; // cruise obstacle detect in meters (0 == off) double coward = 2; // obstacle approach in ship length (min = 0.1) float minalt = 30; // minimal altitude correction in meters (0 = off) int landsmin = 1; // landing velocity close to the ground (min = 1)

raycast — determines at what distance to the obstacle the lift thrusters will start working in cruise control mode to fly around it from above. The lower the value of this variable, the closer the ship can fly to the obstacle and the less time will remain before the collision. A small value is useful when exploring for ore, and a large value will allow you to safely deliver the cargo to the desired point, especially when flying in the mountains. For such a correction, you will need a front camera.

coward — used to fly to the desired object (base, stone with ore on the surface, asteroid, etc.) using the front camera via lidar. The distance is specified in the length of the ship's hull. This is because the script cannot automatically determine where exactly on the ship the camera you are flying along is installed. If the camera is installed on the bow of the ship, then with a value of 1 you will stop in front of the obstacle at a distance of the length of the ship's hull, and if in the tail, then close to the obstacle.

minalt — minimum flight altitude. Works only in gravity. The lower this value, the closer to the planet's surface the ship will fly, but you should not set the altitude less than 20 m because the ship may start to touch trees, which are not detected by the camera as obstacles and can knock the ship down or knock it off course. Additional conditions for setting this variable will be given below.

landsmin — minimum landing speed at the last stage near the surface after the ship reaches the altitude specified in the minalt variable. It is not recommended to set it higher than 5, so as not to damage the ship upon landing.
Vertical flights
Running the script with the "escape" argument allows you to move the ship up or down in gravity. If the altitude is not specified at startup, the ship will begin to ascend to the planet's orbit and will not stop until it leaves gravity.

As a parameter, you can specify the exact height to which you want to move the ship. The relative height from the current position of the ship with a "+" (plus) or "-" (minus) sign, as well as the name of an alternative controller for changing the orientation of the ship towards maximum thrust. Below are the call options with arguments:

escape 700 - rise or fall to altitude of 700 m escape +100 - rise 100 m up from the current altitude escape -100 - descend 100 m down from the current altitude escape - fly into orbit around the planet escape Remote Control - fly into the planet's orbit using an alternative controller

This works on any planet except Pertam, which has a variable gravity well depth. You can see this by the in-game altitude mark on the screen, which can disappear already at an altitude of 3500 m from the planet's surface, while gravity will still affect the ship. Therefore, use the "stop" command if the ship begins to rise above the planned altitude, so as not to fly into Pertam orbit.

When taking off, the script will automatically disable the landing gear and connectors of the ship.

Parachute
The script can use parachutes for emergency braking if the ship's descent speed is too high. This can happen if you are flying the ship in Flat Fly mode (executing a script with the "0" argument) and using the "C" key you accelerate the ship too much towards the planet's surface. In other cases, parachutes are not used.
Landing ship
Automatic landing of the ship is initiated by executing a script with the argument "landing" and is possible in the presence of gravity. Landing is performed in free fall mode without the use of parachutes. The lift thrusters are turned on at the moment when the calculated thrust of the ship is sufficient to slow it down to the altitude specified in the variable minalt. The descent to the surface will be performed at the speed set in the variable landsmin.

Four variables are responsible for setting up the control of the chassis and thrusters after the ship touches the surface:
bool lockship = true; // try parking ship after landing (gears/connects) bool lockwait = false; // wait for ship to align with terrain after landing bool thrustoff = false; // turn off all thrusters after landing bool freefall = false; // descent by gravity alone

lockship — can take two values: true or false (lowercase). true means that after landing the script will try to lock all plates and connectors for which Used for parking is set. Keep this in mind if the ship has other plates or connectors that are not used for parking the ship, but, for example, for attaching rovers in the shuttle hangar.

You can combine all connectors, parking chassis and magnetic plates into a group and specify its name in the group dictionary if automatic detection does not suit you:
Dictionary<string, string> groups = new Dictionary<string, string>() { {"landing", ""}, // landing gear, magnetic plates and connectors used for landing };

lockwait — can take two values: true or false (lowercase). If you want the ship to lock to the surface with all available landing gear after landing, set this value to true. This is useful for ships with folding ramps (dropships), when the rotation angle of the rotor or ramp hinge is set in advance and is calculated for the ship to be fully parked. Using Autolock in the landing gear and magnetic plates settings will cancel the effect of this variable.

lockwait = false. Ship is parked with gravity alignment
lockwait = true. Ship is parked to the terrain surface

thrustoff — can take two values: true or false (lowercase). true means that after landing, all thrusters should be turned off so that the ship does not consume energy and hydrogen. This can be useful when using chassis on subgrid, since in this case the game does not turn off the thrust automatically.

freefall — If set to true, then only gravity will be used to descend to the planet's surface. A good solution for ships with a small hydrogen reserve.

To perform a landing, the ship must be in the planet's gravity. You can execute the script with one argument:
landing - land on the surface of a planet landing Remote Control - perform landing using alternate controller (see below)

Automation in the landing process
Sometimes it is useful to perform some additional actions before landing, such as extending the landing gear or opening the ship's landing ramp. In this case, you can use a timer or some script that will perform all the necessary procedures. The names of timer blocks are specified in the dictionary
Dictionary<string, string> timers = new Dictionary<string, string>() { {"before landing", ""}, {"after landing", ""}, {"before escape", ""}, };

Here, in double quotes "" you can specify case-sensitive block names, for example:
Dictionary<string, string> timers = new Dictionary<string, string>() { {"before landing", "Timer Landing"}, {"after landing", "Timer Recharge"}, {"before escape", "Timer Takeoff"}, };

Timer Landing will trigger when the ship reaches the altitude specified by the minalt variable (see above), and Timer Recharge will trigger after the landing gear and connectors are connected to the stations.

Note: Sometimes you need to perform more complex actions related to landing. For this, the Grand Cruise script is compatible with another of my scripts, Easy Play. If the variable specifies the name of the program block with this script, then the scripts with the same name will be executed instead of timers.
string pbeasy = "PB EasyPlay"; // EasyPlay PB block name (optional)

Alternate controller
If the ship has a more powerful thrust along an axis other than the vertical thrust of the main controller, then you can use an alternate controller, which must be installed so that the vertical thrust is carried out along this axis.

This is well suited for ships with a rocket-type layout. The alternate controller will allow you to take off and land on the surface of a planet using cruise engines, while in space you will be able to move in the normal way. The easiest way to do this is to use a Remote Control block, but you can also use an alternate cockpit.
Remote Control oriented towards cruise thrusters
Vertical landing with Remote Control block

Landing on a ground station
The script can perform a landing on a static structure that is raised above the planet's surface to a certain height. To do this, when setting the value of the variable minalt, you should take into account the height at which such a landing is to be performed, so that the landing speed is minimal (see the variable landsmin).

After the ship's speed is equal to 0, the script will decide that the landing is complete and perform the associated actions. Automatic landing in space does not work.
Lidar flights
Want to quickly find uranium in space or send your ship from Earth to the Moon without the risk of meeting an asteroid? Then you will need a course camera whose name will have the word "cruise".

You can have multiple cameras installed on the main grid, a subgrid, or even on another grid via a connector, but only one will be used at any given time. The rest will be backups.

4 variables are responsible for setting up this mode, two of which have already been described above:
float rayspeed = 90; // default velocity for fly to target by lidar m/s double rayrange = 10000; // default lidar raycast camera range in meters

rayspeed is the speed at which the ship will approach the research object (like the speed for the Autopilot)

rayrange is the maximum distance at which the camera will see objects (can be limited by the world settings)

Two more variables raycast and coward are responsible for the range of the flight and approach to the obstacle, respectively.

Approaching an object
This is one of the most useful features of the script for exploring the world and searching for ore deposits on planets and in space.

It is initiated very simply: you need to point the camera at the object and execute the script twice with the argument lidar. The first time you will see the characteristics of the target on the screen: a planet, an asteroid, a large or small grid and the distance to it, and the second click activates the flight to the target at the speed set in the variable rayspeed.

If you output the execution of the script with the lidar argument to the digital control panel of the ship (cockpit or pilot's seat) via Toolbar Config, then this will be equivalent to simply double-clicking on the specified digital button. The ship should remain motionless or have a slight shift in the camera sight from the original point.


At the end of the flight, the ship will fly to the specified point at a distance set in the variable coward, determined by the dimensions of the hull. That is, if the length of your ship is 90 m and the camera is installed on the nose, then with a value of 0.5 it will stop in front of the asteroid at a distance of 45 m. Which is enough to immediately assess the ore deposits or fly to the next one.

In space, the approach to the object is performed in a straight line, and in gravity - it depends on whether the point you need is located above or below the ship. If above, the ship will fly to it in a straight line with minimum altitude control, and if below, then the ship will first align with gravity, fly to the point located above the object, and then descend to it.

This solution can be a good start for automatic parking using the AI ​​Flight (Move) & AI Recorder blocks, which can be activated by a timer before landing (see the "Ship Landing" section).


Obstacle avoidance
When flying in cruise control mode, the course camera detects obstacles at a short distance in the direction of travel, which depends on the values ​​of the variables coward and raycast. The latter is set in meters and plays a major role in assessing the distance to the obstacle.

In gravity, the higher the value of raycast, the steeper the slope the ship can overcome when flying above the surface. In space, the size of the asteroid that the ship can fly around depends on this value, so if you are flying a long distance into the unknown, it is better to make it larger.

It is important to understand that the ship only sees ahead through the camera and flies around the obstacle using lift engines. Therefore, it is possible that the camera detects an obstacle that is located within the boundaries of the asteroid, for example, under an overhanging canopy. In this case, when the ship moves up to fly around the asteroid, it will run into an obstacle above itself, which the camera does not see. The same applies to a cluster of asteroids, which the game presents as a single object.

LCD output
The script can output telemetry to the screen of any game block that allows this. To do this, you will need to add the prefix "cruise" to the block name and specify the ordinal number of the screen to which the output will be performed using the underscore "_". For example, to output the cockpit to 2 screens, you need to add to its name: Cockpit Cruise_2. Without "_", the output will be performed on the first screen of the block.
Output to the 2-d screen Cockpit Cruise_2 Radar
Output to 1-st screen PB Cruise (without "_")

By default, the script displays the main characteristics of the ship, including thrust on all axes (for gravity in tons, for space in kN), remaining energy and hydrogen, parachute readiness, container loading, and the state of the landing gear. This information is updated every time the script finishes executing the next task.

During the task execution, the operating time in minutes and seconds and the corresponding telemetry are displayed. The output is configured in the dictionary:
Dictionary<string, string> lcdout = new Dictionary<string, string>() { {"header", "-= Grand Cruise 2.0 =-\n\n"}, {"view", "ship"}, {"text color", "40:200:40"}, {"text background", "0:0:0"}, {"script color", "40:140:0"}, {"script background", "0:0:0"}, };

The second pair of values ​​{"view", "ship"} defines what will be output by default each time the script finishes flying in one of the modes. You can change the output by replacing "ship" with a key value from another dictionary:
Dictionary<string, Progs> viewDict = new Dictionary<string, Progs>() { // system scripts - don't change this settings { "ship", new Progs { RUN="[inner]", OUT="ship" } }, { "sets", new Progs { RUN="[inner]", OUT="sets" } }, { "clear", new Progs { RUN="[script]", OUT="clear" } }, { "clock", new Progs { RUN="[script]", OUT="TSS_ClockAnalog" } }, { "horizon", new Progs { RUN="[script]", OUT="TSS_ArtificialHorizon" } }, { "energy", new Progs { RUN="[script]", OUT="TSS_EnergyHydrogen" } }, { "weather", new Progs { RUN="[script]", OUT="TSS_Weather" } }, { "help", new Progs { RUN="PB EasyPlay", OUT="help" } }, };

The first key value in double quotes "" can be used as an argument for the script. For example, if you enter "sets" in the argument line and run the script, you will be able to see all the current settings of the variables described in the previous sections. Running the script with the "horizon" argument will output a vanilla script that shows the current altitude and position of the ship relative to gravity, etc.

If you want to override the default output, you can either replace the "ship" value in the first dictionary, or run the script with the "view MODE" argument, where MODE is one of the key values ​​in the second dictionary. This can be useful if you prefer to constantly see, for example, the horizon for the game, rather than grid information.
Jump Drive
The script allows you to set the jump distance in km for all jump drives installed on the main or attached grid, including Prototech drives. This allows you to jump more accurately to the Unidentified Signal by quickly setting the distance to the GPS mark without using the Terminal slider.

Using the "jump NN" argument, you can set any distance that the ship can jump to using the total power of all installed jump drives. Do not worry if the jump distance exceeds the minimum or maximum value.

You can put a short jump of 5-7 km on the control panel to use it in combat.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3484516876
This blueprint consists of two independent ships that can use each other's blocks — the camera and jump drives.
Conclusion
If you have any questions about installing and configuring the Grand Cruise 2.0 script, you can watch the video guide
https://www.youtube.com/watch?v=Z-OPSUfJmVQ
Example of a large grid ship with excess lift thrust with the script installed and configured
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3337302530
A small grid ship with a small thrust reserve and thrusters on subgrids
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3341326477&searchtext=
Easy Play script for takeoff and landing automation scenarios
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2688952356