Wavelengths

From The Powder Toy
Revision as of 11:57, 7 October 2023 by Jerehmia (talk | contribs) (Added hexadecimal values and a short explanation)
Jump to: navigation, search

Wavelengths are stored in the ctype field and determine the colour of the elements (e.g. PHOT, FILT, BRAY, BIZR, BIZS and BIZG.) They can be used as storage by setting the wavelengths to a certain amount and read that info by filtering out some wavelengths and letting others through. This save shows that use. Wavelengths are displayed at the HUD on top of the element name. In a full spectrum, the wavelengths on the left are red, and on the right they are blue. In between are the colours of the rainbow. When it isn't a full spectrum, then some colours will be missing. To set a wavelength, you need to set the ctype to get different wavelength. The wavelengths are:

Wavelengths.png
Ctype Values (from blue to red)
Wave number Decimal value Hexadecimal value
1 1 0x1
2 2 0x2
3 4 0x4
4 8 0x8
5 16 0x10
6 32 0x20
7 64 0x40
8 128 0x80
9 256 0x100
10 512 0x200
11 1024 0x400
12 2048 0x800
13 4096 0x1000
14 8192 0x2000
15 16384 0x4000
16 32768 0x8000
17 65536 0x10000
18 131072 0x20000
19 262144 0x40000
20 524288 0x80000
21 1048576 0x100000
22 2097152 0x200000
23 4194304 0x400000
24 8388608 0x800000
25 16777216 0x1000000
26 33554432 0x2000000
27 67108864 0x4000000
28 134217728 0x8000000
29 268435456 0x10000000
30 536870912 0x20000000

You can add them together, e.g. to get both wavelengths, 30 (the leftmost and the reddest wavelength) and 1 (the rightmost and the bluest wavelength) in the same spectra, you need to add the corresponding ctypes in the chart. 30.536870912 ctype for wave 30 = 536870912, 1.1 ctype for wave 1 = 1, 536870912 + 1 = 536870913. So, set the ctype of the PHOT or FILT or whatever to 536870913 to get both wavelengths 30 and 1.

If you know hexadecimal working with ctypes becomes very easy because every hexadecimal digit represents a cluster of 4 wavelengths. Assume we want to set the second, the fourth, the fifth and the eight wavelength: wavelength 2 = 0x2, wavelength 4 = 0x8, wavelength 5 = 0x10 and wavelength 8 = 0x80, adding them gives 0x2 + 0x8 + 0x10 + 0x80 = 0x9a.

 You can enter hexadecimal values in the console and in the PROP tool by using the 0x prefix.