Subframe

From The Powder Toy
Jump to navigation Jump to search

What's Subframe?

Subframe is a general name for technology that abuses particle update order.

Particle Order

Every frame in The Powder Toy, all the particles are updated one after another according to their ID.

When you hover over a particle with debug mode (use the "D" key to toggle) the ID is visible next to the X and Y values.

Every time you load a save, the particles are ordered from left to right and top to bottom. That means they will also be updated in that order (because the IDs are also ordered). You should always assume that the order of your contraptions can break when reloading the save.

Solid Spark

Solid sparks are used to activate powered materials every frame. It can bypass the spark cooldown (which is why spark blinks).

There are two common ways to make these. In what follows, I'll refer to an 'active' particle (the one that needs to be sparked, e.g. ARAY, DRAY) and the 'sparker' to mean the conductive element that the active particle needs to touch (e.g. PSCN, METL).

We are trying to make sure that by the time the active particle is updated, the SPRK has a `life` of 3.

CONV Spam

In addition to the active particle and its sparker, you need two CONVs. Their particle IDs must be ordered,

1. Active particle

2. CONV with the `ctype` of the sparker. Optionally, set its `tmp` to SPRK (aka 15) to prevent this particle from acting on other elements.

3. CONV with `ctype` of SPRK.

The ID of the sparker *does not matter*.

1. Unlike most other elements, the life of SPRK decreases by 1 before the frame 'begins'. This is why the sparker's ID is arbitrary.

2. The active particle sees a SPRK of life 3, and fires.

3. The first CONV turns the SPRK into the sparker element.

4. The second CONV converts sparker->SPRK(sparker), with life 4.

So the 1st particle gets sparked, the spark is replaced with the original material, and then gets sparked again.

Life Deserialisation

Since LSNS life deserialisation was added to the game, a different (and in some sense complementary) technique has become the dominant way to make solid spark. For this technique, you need one LSNS with its tmp=3 within detection range of a FILT. Whenever the LSNS fires, it sets the life of any neighbouring particles to the value encoded in the FILT. Now, all particle orderings are possible - if the LSNS fires before the active particle, it should set life=3; if it fires after, it should set life=4 (as in the CONV technique).

Language: English