Puzzle library¶
The puzzle library is the database of all known puzzle definitions. The global variable puzzles contains the global puzzle library.
Methods¶
puzzles:add()¶
puzzles:add() adds a puzzle to the global puzzle library. It takes one argument: a table containing the following keys:
idis a string containing a unique ID for the puzzleversionis a string containing the semantic version for the puzzlenameis a string containing a user-facing name for the puzzletagsis a table containing a tag specification.colorsis a string containing the ID of a color system in the color system libraryndimis the number of dimensions for the puzzlebuildis a function used to construct the puzzle
The keys id, version, ndim and build are required. All other keys are optional. The keys name, tags, and colors are recommended.
The puzzle is not constructed immediately when puzzles:add() is called. (Otherwise, the program would slow to a crawl loading all the puzzles on startup.) Instead, only the ID, name, tags, and other metadata is stored.
When the user first opens a puzzle, a puzzle object is initialized with a new ndim-dimensional space, and an empty color system, axis system, and twist system; build is then called with that puzzle as its argument. build is responsible for cutting the pieces and defining colors, axes, and twists. See Puzzle, Colors, Axes, and Twists for more.
Operations¶
#puzzlesreturns the number of puzzles that have been loadedtype(puzzles)returns'puzzledb'