fish.txt (example 1) — https://pastebin.com/1RTgxsrn
dragon.txt (example 2) — https://textbin.net/f2omkrxg0d
The video thumbnail is an edited screenshot. The dragon is darker in the game.
Example 1 (fish)
I will use this image: https://i.imgur.com/vjTvJUy.png
source: https://csunplugged.org/fr/resources/pixel-painter/
But this image is too big. I want a black square correspond to a pixel (black square size = 1x1 pixel). To do this, I will rezise the image to 44x32 pixels.

Now, one black square = 1x1 pixel.
Convert image to text
I use ImageMagick (https://imagemagick.org/) to get the coordinates of the black pixels.
magick convert fish_44x32.gif fish.txt
fish.txt sample
# ImageMagick pixel enumeration: 44,32,255,srgb
0,0: (255,255,255) #FFFFFF white
1,0: (255,255,255) #FFFFFF white
2,0: (255,255,255) #FFFFFF white
[...]
19,0: (0,0,0) #000000 black
20,0: (0,0,0) #000000 black
21,0: (0,0,0) #000000 black
[...]
16,1: (255,255,255) #FFFFFF white
17,1: (0,0,0) #000000 black
18,1: (0,0,0) #000000 black
[...]
Edit the text file
We want the lines that contain (0,0,0) #000000 black. They are the black pixels.
Firstly, I remove the unwanted lines.
I do a search and replace in a text editor.
I search the regular expression
\d+,\d+: \(255,255,255\).+\r\n
and replace it by "" (nothing).Now, we have only the lines that contain (0,0,0) #000000 black.
I convert the lines in a compatible format for the mod.
Example:
18,1: (0,0,0) #000000 black
will become...stone_wall_1x1 18 -1 0
Wich means a stone_wall_1x1 will be created in x=18 y=-1 z=0. If the coordinates in y are not negatives, the construction will be in inverted in y axis.I search the regular expression ^(\d+),(\d+).+
and replace it by stone_wall_1x1 \1 -\2 0
I add these lines at the beginning. The construction will be created at the player's coordinates.
!offset_x={x}
!offset_y={y}
!offset_z={z}
Run the Batch build command
You could download the fully edited fish.txt file: https://pastebin.com/1RTgxsrn
Copy fish.txt to the Valheim install path. Ex: C:\Steam\steamapps\common\Valheim\ In Valheim, open the console (F5). Type build -f fish.txt
Example 2 (dragon)
For a more detailed example, see example 1 (fish).
This example was more complicated because the image is big.
I downloaded this image: https://www.pngegg.com/en/png-plgvx
I edited it. Edited version: https://imgur.com/UoFGZhy
I convert the image to text to get the coordinates of each pixel.
magick convert dragon.png dragon.txt
I search the regular expression
\d+,\d+: \(255,255,255\).+\r\n
and replace it by "" (nothing).I search the regular expression
^(\d+),(\d+).+
and replace it byice_rock1 \1/20 -\2/20 0 0 0 0 0 0 0 0 0 0 0 0.003 0.003 0.003
The last three numbers (0.003) are the scale of the object (ice_rock1). An ice_rock1 is very big, so we need to rescale it. Also, x and y coordinates are divided by 20.
How can I know these values? I did some tests. I divide these values otherwise the space between objects would be too big. You have to do tests to find good values.
The syntax of each line is
id pos_x pos_y pos_z angle_x angle_y angle_z point_x point_y point_z axis_x axis_y axis_z angle scale_x scale_y scale_z
Fully edited dragon.txt: https://textbin.net/f2omkrxg0d
See also: Ice sculpture. made from 4000 resized ice bergs (by britzerland)
0 comments