Skip to content

Patternizer

Syyrion edited this page Feb 15, 2024 · 11 revisions

A list of all functions and methods in Patternizer

Parameters

  • Patternizer.timeline
    This is a Queue Class from Signals. Do not modify.

  • Patternizer.sides
    A numerical Cascade class. Contains the number that $sides is initialized to when using Stackup. Defaults to the current side count.

  • Patternizer.mirroring
    A boolean Cascade class. Determines whether random mirroring is enabled. Defaults to true.

  • Patternizer.tolerance
    A numerical Cascade class. A thickness value that is added to walls to prevent seams from forming. Defaults to 4.

Methods and Functions

  • Patternizer:new(...)
    Creates a new Patternizer instance. Any Stackup scripts provided will be compiled and added to the pattern pool.

  • Patternizer:link(char, fn)
    Links a Lua function to a character which can be called from Stackup via a call: instruction or used within a pattern. Only alphanumeric characters, periods, and underscores (A-Z a-z 0-9 . _) are accepted. A few characters are always assigned to certain functions by default. These can be overridden.

    Character Function
    . cWall
    1 cWall
    c cWall
    o oWall
    r rWall

    Note: Any character that is not linked to a function will do nothing when called. By convention, the underscore is always unlinked as it is used to create openings in patterns.

    IMPORTANT: Indexing the link function with a character will return the Lua function linked to that specific character.

    Patternizer.link['c']

    The above statement will return the Lua function that is associated with the character 'c'.

  • Patternizer:unlink(char)
    Removes the link between a Lua function and a character.

  • Patternizer:strwall(str, pos, th)
    Generates a single horizontal row of walls from the pattern string <str> at starting at side <pos> with thickness <th>.

    Note: This method can be called directly without creating a new Patternizer instance. All settings and function character assignments will be default if this is done.

  • Patternizer:include(name, fn)
    Includes a lua function <fn> with name <name> so it can be used with the (<body>)<function> and #(<body>)<function> instructions. This function can accept any number of arguments and must return only numbers.

Compiler

  • Patternizer.compile(str)
    Converts a Stackup script into a table that can be more easily interpreted by Lua. Returns said table.

    Note: This is a function, NOT a class method! It does not accept a self parameter and thus a period should be used instead of a colon when indexing the function. This also implies that all compiled programs are identical, regardless of whatever Patternzer instance generated it. However, the way they are interpreted may differ between instances.

Interpreters

  • Patternizer:interpret(program, ...)
    Accepts a Lua table generated by Patternizer.compile and runs the program. Any extra numbers provided are pushed to the stack in order from left to right before the program is run. After the program terminates, a tuple of numbers that remain on the stack is returned. Numbers at the bottom of the stack come first in the returned tuple. Programs must abide by the instruction limit.

  • Patternizer:restrict(program)
    Accepts a Lua table generated by Patternizer.compile and checks its restriction statement. Only the number at the bottom of the stack is checked. If no numbers remain in the stack, the function returns true. If a restriction statement doesn't exist, the function returns true. If the number checked is 0, returns false, otherwise true. Programs must abide by the instruction limit.

  • Patternizer:send(str, ...)
    Compiles and interprets a string directly.

Pattern Spawner

  • Patternizer:add_program(program)
    Adds an already compiled Stackup program to the pattern pool.

  • Patternizer:clear()
    Removes all patterns from the pattern pool.

  • Patternizer:allow_pattern_repeat()
    Allows patterns to be picked twice in a row from the pattern pool.

  • Patternizer:disable_pattern_repeat()
    Prevents patterns from being picked twice in a row from the pattern pool.

  • Patternizer:suspend()
    Suspends pattern spawning.

  • Patternizer:resume()
    Resumes pattern spawning.

  • Patternizer:spawn()
    Spawns a random pattern from the pattern pool as long as it is not disabled due to the timeline containing pattern events. Patterns cannot be picked twice in a row unless this behavior is disabled.

Timeline

  • Patternizer:run(mFrametime)
    Runs the timeline and spawns patterns.

Clone this wiki locally