# Floating Sandbox How-To: Create an Electrical Layer

This is the first part of a multi-part post explaining how to build electrical layers in ships for Floating Sandbox.

Note: this tutorial has been updated on 09/06/2020 to cover the new electricals materials that have been added to Floating Sandbox in version 1.15.

One of the major new features introduced with Floating Sandbox 1.14 is the ability to create complex circuits sporting a number of different components – switches, engines, horns & bells, and so on. While for a few ship builders there’s nothing special in the way these components must be placed in a ship, for the vast majority of Floating Sandbox users out there this is a novel topic. This post attempts to provide an introduction to creating electrical layers in existing ships, while a subsequent post will walk-through the task of placing “advanced” elements and laying them out in a neat electrical panel, just like this:

## The Structural Layer

In this post we’ll assume you’re starting from a plain, structure-only ship image just like the following one – feel free to download it and use it as we walk through this tutorial:

Right-click on this ship, choose “Save image as”, and save it on your computer, making sure to name the new file “my_ship_structure.png“. This will be your structural image, i.e. the image that provides Floating Sandbox with the solid particles that make up the structure of your ship.

As you should probably know by now, each pixel in the structural image above corresponds to a particle, and the color of that pixel indicates the “material” that the particle is made of, based on a large “map” of color↔material correspondences – the “material palette”, which you may find under the Guides folder of Floating Sandbox. This is the full material palette at the time of writing (1.15):

Now that you have a structure for your ship, it’s time to take it to the next step: you need to transform this ship from a “basic” ship to an “advanced” ship, which is capable of using multiple images to provide different ship characteristics to Floating Sandbox. An “advanced” ship may in fact provide many things, such as ropes, high-definition images, and electrical element information.

To create an advanced ship, create a text file in the same folder in which you have just saved “my_ship_structure.png”, name the text file “MyShip.shp” (make sure you get rid of any other parts of the filename, such as “.txt“), and paste the following text into it:

```{
"structure_image" : "my_ship_structure.png",
"ship_name": "My Ship!",
"created_by": "Myself!"
}```

Let’s test this out! Start Floating Sandbox, click on “Load Ship”, and navigate to the folder in which you have saved the structure image and the text file above; you should see your ship twice now:

The ship to the left is your new “MyShip.shp” file, while the ship to the right is your structural image, which is listed by Floating Sandbox just because it has a “.png” extension. We’re gonna focus on your “MyShip.shp” file, as that is your “advanced” ship.

You can now load your “advanced” ship and play with it, but you’ll notice that it’s not that different than the initial “basic” ship – it’s exactly the same ship in fact. That’s because we’ve only specified a structural layer.

## The Electrical Layer

Let’s now add an electrical layer image. An electrical layer image provides the electrical components of a ship. Specifically, a pixel in the electrical layer image says that the ship particle that is specified in the structural layer image at the same location, should acquire the electrical properties of the electrical material corresponding to the pixel’s color.

The palette containing the game’s electrical materials is under the Guides folder, and at the time of writing it contains the following elements:

As an example, if in the electrical layer you place a pixel with color (255, 224, 17) at coordinates (161, 19), you will be saying that the particle at coordinates (161, 19) in the structural layer (highlighted in the following screenshot) will acquire the properties of the “High Lamp” electrical material – a lamp that makes “a lot” of light.

Let’s do just that then!

Using your favorite paint tool – I’m using Windows 7’s Paint – create a new image with  the exact same size as our structure image (215 x 48 pixels), and make sure the image is completely white. Place then a single pixel of color (255, 224, 17) at coordinates (161, 19) – that will be our lamp.

Lamps however require power, and cables to carry that power. Place then a generator – color (252, 8, 8) – at position (76, 45) (I like my generators to be placed at the bottom of ships!), and draw a continuous line of cable color (112, 0, 0) connecting the two:

Save your new image as “my_ship_electrical.png” and you’re done – this is your first circuit!

We now have to tell Floating Sandbox that this circuit belongs to our ship. We do so by editing the “MyShip.shp” file and adding an “electrical image” directive to it:

```{
"structure_image" : "my_ship_structure.png",
"electrical_image" : "my_ship_electrical.png",
"ship_name": "My Ship!",
"created_by": "Myself!"
}```

Open up the ship in Floating Sandbox, and you should now have a bright lamp close to the bridge of your ship, exactly as follows:

## The Rules

These are the rules to follow when drawing an image for the electrical layer of a ship:

• The size of the electrical layer image must match the size of the structural layer image
• For every pixel in the electrical layer image there must be a corresponding pixel in the structural layer; in other words, electrical materials must be superimposed onto structural particles
• All the other pixels in the electrical layer image which are not meant to carry electrical elements must be full white (255, 255, 255); it is an error if a non-white pixel is found whose color is not among the colors in the electrical materials palette
• Electrical elements that require power in order to work – that is, the majority of electrical elements – need to be connected to at least one generator via a path (a series of connected particles) of conductive elements like cable
• Two electrical elements are considered connected only if they are adjacent, that is, if they touch each other, even if only at a corner

That’s all for now. In the next posts we will explore the new, advanced electrical materials that were made available in Floating Sandbox 1.14 and 1.15, and how you may control your advanced electrical elements from a neat electrical panel.

## 25 thoughts on “Floating Sandbox How-To: Create an Electrical Layer”

1. Fernando says:

Gracias por ayudarme como hago mi capa electrica.
Me gustaria tambien como hago una capa de textura 👍
Me encanta floating sandbox es mi juego preferido sigan asi.

1. Gabriele Giuseppini says:

Muchas gracias Fernando!
For the texture, have a look at “Guides\How to build a Ship.md” under Floating Sandbox’s folder. We’ll probably write a post also to explain that in detail, sooner or later!

Its good im trying to add engines rn

3. how do you make a ship in this game????????????

1. Gabriele Giuseppini says:

Hi,
There’s is an explanation under the “Guides” folder of the game (“How to Build a Ship.md”), but as a starter, you just draw a ship using the colors in the material palette, as explained at the top of this post.

P.S.: a future version of Floating Sandbox will come with an in-game ship builder, but that might take a while.

1. jaedyn says:

rip me my ship buillder is in a locked file

2. Gabriele Giuseppini says:

What do you mean with “a locked file”?

4. Ugnius says:

I always get an error :

Maritime Disaster

Found two electrical elements with instance ID “0” in the electrical layer image, at (55, 24) and at (13, 24); make sure that all instanced elements have unique values for the blue component of their color nodes!

1. Gabriele Giuseppini says:

Hi, the error message is clear: you have two electrical elements with the same value for the blue component, i.e. zero. Read up the “instanced elements” section of this tutorial: instance IDs (blue components) must be unique, hence you cannot have two of them with the same value.

2. medicship says:

Maritime Disaster

the electrical layer image specifies an electrical material at (92, 37), no pixel may be found at those coordinates in structural layer image

1. Gabriele Giuseppini says:

Hi, what exactly do you find confusing in that message? Is it the wording?

2. medicship says:

Maybe?

3. Gabriele Giuseppini says:

Well, this will soon be a thing of the past – with the upcoming ShipBuilder, creating electrical circuits will be a breeze and these messages will be gone.

5. Alex says:

Yes me too but my error is Maritime Disaster could not load imagie C:\windows\users\me\AppData\local\FloatingSandbox\Ships\Aboats_model1_old_fashion_electrical. The file doese not exist.

1. Gabriele Giuseppini says:

You need to make sure that the filename you have in the .shp file matches the file really on disk. I suspect that Windows is hiding file extensions, so your filename is really “Aboats_model1_old_fashion_electrical.png” – note the “.png” at the end.

1. RandomGamer says:

Hey when i am testing it this comes Maritime Disaster cannot find electrical material for colour key #111111 at pixel [0,33]

2. Gabriele Giuseppini says:

That means that you’ve put a pixel at x=0 and y=33 with color #111111, which is none of the electrical materials. You should only use colors from the electrical materials palette.

6. jeffrey plays jerryplays says:

ahh both ships dont appear in floating sandbox

7. jeffrey plays jerryplays says:

why dont you make a video on this

8. Cleptrophese The Human Bean says:

How do I save it as .shp? I’m changing it to “all files” and making sure “.shp” is in the name, but it seems to swap it back to .txt every time. Using the default Microsoft Notepad for Windows 10, and joining files in Paint.NET (which all work in Floating Sandbox individually). I’ve made a ship in this before, I’m doing everything the same, not sure where I’m going wrong?

1. Gabriele Giuseppini says:

Hi, you have to enable “Filename extensions” in Windows’ folder options before being able to change extensions arbitrarily.