Skip to content

Scripting

Syyrion edited this page Jan 6, 2024 · 4 revisions

Previous Section: Patterns


An introduction creating and spawning patterns using Stackup and Patternizer

Using P-Strings in Stackup

Walls are spawned by Stackup with the T:, t:, P:, and p: instructions. P-Strings are embedded as a part of these instrictions and are written immediately after the colon (with no spaces). These instructions pop two numbers: a starting side and a thickness.

Example

  • 0 40 T:_|.
    Create a barrage with the gap at side 0 with thickness 40.

Behavior

Tolerance is typically a small number that is added to the thickness of a ring to ensure that small seams between consecutive ring remain closed. Seams form because walls move in discrete steps and can only be spawned at discrete time intervals but can be have any thickness. So if the thickness value is not a multiple of the size of this discrete step, which it almost certainly isn't, a seam will form.

The instructions P: and p: add a wait event to the timeline after the wall spawn event. This wait event lasts just long enough so that the next wall spawn event will happen right at the moment when all previous walls have passed.

The four instructions cover all combinations of these behaviors:

Instruction Adds Wait Event Adds Tolerance
T: No No
t: No Yes
P: Yes No
p: Yes Yes

Pivot Control

Patternizer uses two pivots to determine how patterns and their components are positioned. The absolute pivot is typically used as an anchor point for the patterns. It is automatically initialized to a random side when a Stackup script is run. The relative pivot is a second pivot that can be moved and is derived from the absolute pivot and a global variable.

Let n be the number from Patternizer.sides. By default this is the current number of sides.

  • Absolute Pivot
    Initialized to a random number in [0, n), it's value can be accessed in Stackup with $abs or a.

  • Relative Pivot
    The position of the relative pivot is derived from the following expression: ($abs + $rel) % n and can be accessed in Stackup with r. Here, the variable $rel is an offset from $abs. This variable is initalized to 0 which means that the relative pivot always starts at the same location as the absolute pivot. The value of $rel can be changed using certain instructions, moving the relative pivot. The variable $rel can be accessed but r is usually more helpful.

The actual values of r and a are abstracted away from the user so there's no need to know their actual values. the can be passed directly into the P-String functions without issue.

Examples

  • a 40 T:_|.
    Create a barrage with the gap at the absolute pivot.

  • r 40 T:_|.
    Create a barrage with the gap at the relative pivot.

Pivot Offsets

Sometimes, it is desireable to spawn a ring at an offset from one of the pivots. The << and >> instructions provide a means to do this.

Examples

  • a 2 >> 40 T:_|.
    Create a barrage with the gap 2 sides clockwise from the absolute pivot.

  • r 1 << 40 T:_|.
    Create a barrage with the gap 1 side anti-clockwise from the relative pivot.

Moving the Relative Pivot

Making use of the relative pivot is important in most patterns. There are two ways to move the relative pivot.

  • rmv
    Moves the relative pivot relative to itself. This is used when relative positioning is needed.
  • amv
    Moves the relative pivot relative to the absolute pivot. This is used when absolute positioning is needed.

The Relative Offset

Whenever the relative pivot is moved, another variable $rof is updated to contain the shortest side-distance between the new and old position. This variable is primarily used for the spath and lpath instructions, which are explained later.

Mirroring

Patternizer will automatically mirror patterns, meaning anticlockwise becomes clockwise and vice versa. This can be helpful as when enabled, there is no need to create left and right handed versions of the same pattern. When disabled, no patterns will be mirrored.

Thickness Control

Stackup also has a few instructions for controlling getting specific thickness values.

Ideal thickness

The i instruction converts a number in units of ideal thickness into normal thickness. One unit of ideal thickness is the thickness/distance a wall traverses in the time the player can travel across one full side of the center polygon. It is inversely proportional to the side count and proportional to the wall speed.

  • 2 i
    Get the real thickness of 2 units of ideal thickness.

Short-Path and Long-Path

The spath and lpath instructions push the ideal thickness of traversing the short path or long path, respectively. The values returned are derived from the last side-distance that the relative pivot was moved. For example, if the side count was currently 6 and the relative pivot was moved 2 sides, spath would return the real thickness of 2 units of ideal thickness and lpath would return the real thickness of 4 units of ideal thickness. These commands can be used to create perfectly tight patterns.

Waiting

There are three instructions to manually insert a wait event into the timeline.

  • sleep
    Wait a certain number of seconds.
  • thsleep Wait the amount of time it would take a wall to traverse a certain distance/thickness. Commonly used to space out rings without creating any walls.
  • rsleep Wait the amount of time it takes for the player to rotate a certain number of revolutions. Commonly used at the end of a a pattern to space it out from the next pattern.

Pattern Spawner

Patternizer comes included with methods to automatically spawn patterns. Stackup programs can be added to a pool from which Patternizer will pick from as it is running. Patterns can be added upon the creation of a Patternizer instance with Patternizer:new(...) or added afterwards with Patternizer:add_program(program).

Example

Create a patternizer with three patterns in the pool.

Patternizer:new(
  [[
    a 40 p:_|.
    1.5 rsleep
  ]],
  [[
    a 40 p:|._
    1.5 rsleep
  ]],
  [[
    a 40 p:|.._
    1.5 rsleep
  ]]
)

Previous Section: Patterns

Clone this wiki locally