Skip to content

Patternizer

Syyrion edited this page Nov 6, 2022 · 11 revisions

A list of all functions and methods in Patternizer

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
    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.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.

  • Patternizer:interpret(program, ...)
    Accepts a Lua table generated by Patternizer.compile and runs the program. Any numbers 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. The order in which numbers are associated from the stack to the tuple is bottom to top, left to right. Programs must abide by the instruction limit.

  • Patternizer:restrict(program)
    Accepts a Lua table generated by Patternizer.compile and checks its restriction. Only the number at the bottom of the stack is checked. If there are no numbers remaining in the stack, the function returns true. Returns the result of the restriction. If there is no restriction, the function returns true. Programs must abide by the instruction limit.

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

Pattern Spawner

  • Patternizer:disable()
    Disables pattern spawning. This is used by Patternizer.spawn so direct use of this may cause unexpected behavior.

  • Patternizer:enable()
    Enables pattern spawning. This function is used by the pattern timeline so direct use of this may cause unexpected behavior.

  • Patternizer:spawn()
    Spawns a pattern as long as it is not disabled from the pattern pool. A pattern cannot be picked twice in a row.

  • Patternizer:pause()
    Pauses pattern spawning. This is preferred over the use of Patternizer:disable().

  • Patternizer:resume()
    Resumes pattern spawning. This is preferred over the use of Patternizer:enable().

  • Patternizer:pspawn()
    An alias for Patternizer.spawn that can be disabled/enabled by the pause/resume functions.

  • Patternizer:add(...)
    Compiles and adds a list of Stackup programs contained in strings to the pattern pool.

  • Patternizer:addProgram(...)
    Adds a list of already compiled Stackup programs to the pattern pool.

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

  • Patternizer:step(mFrameTime)
    Runs the timeline but does not spawn patterns.

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

Clone this wiki locally