Drawing electric arcs on coils with ImmediateMesh in Godot
Four 9 m coils now light their hall and throw arcs made of two crossed ribbons. Also one script that turns every showing of juice red.
The four 9 m coils at the foot of the tower light the hall now, and they spark. Arcs crawl around each coil’s ring several times a second, one forks down to the earth rod every few seconds, and now and then one jumps to the next coil. Juice is also red everywhere the game shows it, except on one vat.
Why didn’t the coils light anything?
A coil’s lamp hangs 7.8 m up and had a 5 m range, so it didn’t reach the floor. I wanted the coils to light the hall, and I wanted some kind of cool electrical effect on them.
The lamp came first. Every machine was getting the same lamp energy and range, so the coil got a row in the machines table with its own values. I tried an energy of 2.2 over 14 m and it didn’t show on the floor under the hall’s orange lamps. An energy of 5.0 does. Every other machine’s lamp is unchanged, at 0.7 over 5 m.
Drawing an arc as two crossed ribbons
An arc is two crossed ribbons along a jagged line. There’s a thin near-white core inside a wider sheath in the lamp’s cyan. All of one coil’s arcs go in a single ImmediateMesh, unshaded and additive, drawn bright enough that it blooms. Each arc gets a new jagged line between the same two ends every 0.045 seconds, and the segments are about 0.38 m long.

Looking up at one coil while an arc strikes from the ring down toward the earth rod. The lamp flashes with it.
There are three kinds of arc, and each one has its own row of numbers.
| Kind | How often | How long it lasts | Core width | How far it strays | Forks |
|---|---|---|---|---|---|
| Around the ring | 0.25 to 0.9 s | 0.1 to 0.22 s | 0.03 m | 0.16 m | 0 |
| Ring to the earth rod | 4 to 9 s | 0.3 to 0.42 s | 0.055 m | 0.42 m | 2 |
| Across to the next coil | 8 to 18 s | 0.34 to 0.5 s | 0.05 m | 0.4 m | 1 |
An arc only jumps across to a coil whose ring is within 12 m. The script reads where the ring and the earth rod are from the coil model’s manifest, so the model didn’t need a rebuild. It’s attached by one small block where machines are created, to any piece whose table row has an arcs entry, so another machine could use it.

Two of the four coils from the middle of the aisle, with an arc jumping between their rings.
Flashing the lamp and making the crackle in code
Each arc adds energy to the coil’s lamp while it lasts. A ring arc adds 0.7, a strike to the rod adds 3.0 and a jump across adds 2.4. The lamp also wavers by 12% with the hum.
The sounds aren’t loaded from files. The crackles and the hum are synthesized in code at 22,050 Hz and cached once for all four coils. The hum loops quietly under everything and can be heard within 30 m, and the strike to the rod is the loudest crackle. I haven’t listened to either of them yet.
Why does an arc hang in the air when the game stops?
Everything in the game world counts game time, so the arcs count from the game clock and not from real time. When the clock is stopped, no new arc is made, an arc that’s in the air hangs there, and the hum holds. The coils go to sleep and draw and count nothing when the party is more than 60 m away, which is as far as the dungeon’s lamps can be seen, or when the coil isn’t shown.
The arcs don’t do anything to the party. Four coils cost 0.052 ms per frame of script, measured over 6,000 frames in the hall, and I couldn’t measure a difference in render time.
Making juice red everywhere
Things that show juice were orange, green or amber. I decided juice is red wherever it’s shown.
The color is in one small script now, and each place that shows juice reads it from there. It has three values.
REDis #C2413A, the muscle color of the meat theme. It’s on the rendering a wiped party leaves behind, which was orange, and on the old opening’s vats, which were green.INKis #DB8782, which isREDmoved 40% of the way to white. It’s for writing, because the plain red is too dark to read at small sizes and it’s close to the red of damage in the log. It’s on the log’s Juice tag, the “+N juice” over a kill and over a party card, “JUICE TO SPEND” and the count in the stats pane.DARKis for pools and the disc under a rendering.
I left two things alone on purpose. The green buy buttons stay green, because green there says something can be bought. The printed JUICE number on a party card stays the card’s ink, like HP and MP. The log’s combat color didn’t change.
What’s left?
The burst meat vat’s coolant, level strip and lamp are still cyan. Those colors are painted into the model, so making them red means rebuilding the model through the whole pipeline. A test prints NOT YET for that vat on every run until its lamp is red.
The look and pace of the arcs are a first version, and I haven’t judged them yet.