CubeGun

CubeGun

Not enough ratings
Basic Automatic Ship Tutorial
By 8Z
The new circuit system is pretty powerful. This tutorial aims to teach you the basics of creating your own automatic ship for all purposes, mining and combat alike!
   
Award
Favorite
Favorited
Unfavorite
The Circuit System Explained
After one year of hiatus, an entire new system is in place, and that is the circuit system. It is used to control your ships, manually or automatically alike. If you have played programming puzzle games, or have experience in programming (even graphics ones like that cat thing Scratch), this should be very familiar.

If you haven't done the new tutorial yet, do so immediately. It gives the gist of things, and tells you basic controls. For this tutorial, I will start off with this example ship (DO NOT ACTUALLY USE THIS. THIS IS A BAD SHIP.)


Once you click the Circuitry button on the top left, this new menu will pop up.



This menu displays every circuit part of a ship, which determines its behaviour. For clarification, it is best to move the icons to relatively distant places like this.


Following the in-game tutorial, you should know how to connect key presses to respective parts. Every circuit part is like the key bind, albeit some are more complex with more inputs and outputs.

As a rule of thumb, you can only connect one output (solid line circle, gives out information)



... to one input (dotted line circle, takes information and does stuff).



But only having these does nothing. Our objective is automation, which requires we to get information from not the player's input, but the game environment itself. Which item can possibly achieve that...?
Trigger Warning
Triggers.



Triggers are just a block. It does nothing by itself, but it provides invaluable information about things we are interested in. We will go with the Enemy Detector, a trigger that gives information on our nearest enemy. After placing it anywhere on the ship (but do not place it on an axis!), enter the Circuitry menu and you will see it pop up.



As you can see, the Enemy Detector has two outputs, Angle and Distance.

Angle is always in radians (pi). It is the relative angle of the enemy ship to you.
Distance is in meters (or blocks).

For my example, I have bought a simple Label (that just shows the data on the UI) and connected them. During testing, the angle will show up:





  • If the angle is 0, it means the target is straight ahead.
  • If the angle is positive, it means the target is to your right.
  • If the angle is negative, the target is to your left.
  • If the angle is -1 / 1, the target is right behind.

Other entity detectors (meteor, planet, map edge) work the same way.
Number detectors (time, hp, power, speed) output one number instead, and are straightforward. Perecentages are in fractions (0-1).
Aim and Fire
Before going into full automatic, it is important to remember that you don't have to make a ship fully auto to benefit from triggers and circuitry. Why?

The Axis

Arguably the one thing that changed the combat dynamic the most, the Axis (with three variants, Y only, X & Z, and piston) allows anything attached on top of it to become movable through circuitry. Mainly this means weapons, but Thrusters can also be used on it. (more on this later).



The tutorial ship already has an Spin Axis (the Y variant, which is also the one you will be using the most as it is horizontal) with some Machine Guns on it. To make the turret lock on to the nearest enemy, just connect the trigger's Angle with the Spin Axis's Y.



Run the ship in Test mode, and fire away. You will notice that your gun is always pointed at the enemy. So much more convenient!




Be warned that Spin Axises do not behave as intended when put at the bottom of a block. Multiply the angle value by -1 to make it aim at the enemy instead of away from.


To make it so that the weapon only fires when enemy is within distance, use the Enemy Trigger's Distance and compare it with a constant (like 35), then hook the result to the weapon.
Moves like Jagger
Of course, shooting is one thing, but a ship isn't a ship if it's a sitting duck. Thrusters, like Spin Axises, can be rigged to activate on certain conditions.

Usually, you will want to head towards an entity. You have two ways to achieve this:

The Two Thrusters

The Two Thrusters fashion is standard and straightforward. Two sets of thrusters push the ship left or right (with optional third set that goes straight). By checking the Angle output and comparing it with 0 (straight forward), you can constantly adjust left and right movement so that you are heading towards the target.

Example of a standard Two Thrusters setup:



Explanation: If Angle > 0, engage left and center thrusters; otherwise engage right and center thrusters.


Example of a slightly more advanced Two Thrusters setup, with margins:



Explanation: If Angle > 0.1, engage left thrusters; If Angle < -0.1, engage right thrusters; If Distance > 10, engage center thrusters.
The advanced version is more stable and goes faster (since it adjusts rotation less), but aims less precise.

The Axis Thruster

Remember what I said about adding Thrusters onto axises? This method is based off this idea. By placing thrusters onto an axis turret, you push yourself towards your target.

Example of an Axis Thruster ship: (note that I put the turret on top, more later)


Example of an Axis Thruster setup:



Note that a constant of 0.25 was added to the axis. This allows the ship to run circles around its target, instead of running into it. You might want to combine this with checks to make sure that you are always going away from your target instead of going near.

Also note that currently, putting Axis turrets below your ship makes its value go negative. You may have to correct this (or don't, since the effect isn't entirely undesirable).


Compared to the Axis Thruster, the Two Thruster method:
  • Is much, much more structurally simple
  • Points the ship in the correct direction, useful when you mount equipment

Compared to the Two Thruster, the Axis Thruster method:
  • Has no turning radius (go in the opposite direction, fast)
  • Allows maximum speed in every direction (because all thrusters are used)

Which method you choose, however, is entirely up to you and the situation your ship build is in.
Conclusion
Hopefully, at the end of this tutorial, you now know the basics of creating your own automatic ship! If you created one suitable for combat, make sure to take it to the PVE arena where you will fight other programmed ships. Do not be afraid to experiment, test and build fancy new techniques - that's what this system is for!

Again, thank you very much for reading, and I hope you enjoy the game.
1 Comments
shaneblob06 29 May, 2017 @ 1:59pm 
To be honest, I prefered the old system. But I cant play the game, cause of constant 10% and cant connect.