generator
The core of seedKit: `define({ kit, version, settings, presets, rules })` makes a generator from data. A generator resolves a seed with a preset and locked settings into a plain-data description (`describe`, `random`), lists its settings with ranges, defaults and groups (`setting…
generator
The core of seedKit: define({ kit, version, settings, presets, rules }) makes a generator from data. A generator resolves a seed with a preset and locked settings into a plain-data description (describe, random), lists its settings with ranges, defaults and groups (settings, groups, presets), checks a description and reports what is wrong (check), fingerprints it (fingerprint, optionally ignoring settings) and turns it into a short code and back (encode, decode, fromCode). Settings can take ranges that depend on earlier settings, which keeps designs coherent. Called by generator kits such as Car Forge's schema.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2strict
quantise(v: number, step: number?, base: number?) → number
| arg | type | description |
|---|---|---|
| v | number | |
| step | number? | |
| base | number? |
clamp(x: number, a: number, b: number) → number
| arg | type | description |
|---|---|---|
| x | number | |
| a | number | |
| b | number |
define(def: any) → any
Make a generator from a definition: { kit, version, settings = { Setting }, presets = { Preset }, rules = { function(settings) -> (settingId?, message?, severity?) }, derive = function(desc) -> any? }.
| arg | type | description |
|---|---|---|
| def | any |
staticRange(s: Setting) → void
| arg | type | description |
|---|---|---|
| s | Setting |
rangeOf(s: Setting, resolved: any) → void
The [lo, hi] a setting may take given the settings resolved before it.
| arg | type | description |
|---|---|---|
| s | Setting | |
| resolved | any |
coerce(s: Setting, v: any) → any
| arg | type | description |
|---|---|---|
| s | Setting | |
| v | any |
settings(self: any) → void
Every setting: { id, label, group, kind, min, max, step, default, options, desc }, in resolution order.
| arg | type | description |
|---|---|---|
| self | any |
groups(self: any) → void
The group names, in the order settings first use them.
| arg | type | description |
|---|---|---|
| self | any |
presets(self: any) → void
The presets: { id, label, blurb, tags }.
| arg | type | description |
|---|---|---|
| self | any |
preset(self: any, id: string) → Preset
| arg | type | description |
|---|---|---|
| self | any | |
| id | string |
resolveOne(self: any, s: Setting, seed: number, preset: Preset?, lock: { [string]: any }, resolved: any) → any
Resolve one setting: lock, then the preset's fixed value, then a draw.
| arg | type | description |
|---|---|---|
| self | any | |
| s | Setting | |
| seed | number | |
| preset | Preset? | |
| lock | { [string]: any } | |
| resolved | any |
describe(self: any, seed: number, opts: any?) → Descriptor
Resolve a car / tree / prop from a seed. opts: { preset = id, lock = { [settingId] = value } }. Returns plain data: { kit, version, seed, preset, settings, locks }.
| arg | type | description |
|---|---|---|
| self | any | |
| seed | number | |
| opts | any? |
random(self: any, presetId: string?, seed: number?, lock: any?) → Descriptor
A random description that stays inside a preset (the seed picks it; nil seed draws one from `os.clock`).
| arg | type | description |
|---|---|---|
| self | any | |
| presetId | string? | |
| seed | number? | |
| lock | any? |
check(self: any, d: Descriptor) → any
Check a description against its settings and rules. Returns { ok, issues = { { setting, message, severity } } }.
| arg | type | description |
|---|---|---|
| self | any | |
| d | Descriptor |
add(id: string?, msg: string, sev: string?) → void
| arg | type | description |
|---|---|---|
| id | string? | |
| msg | string | |
| sev | string? |
canon(s: Setting, v: any) → string
One setting value as canonical text.
| arg | type | description |
|---|---|---|
| s | Setting | |
| v | any |
canonical(self: any, d: Descriptor) → string
The canonical text of a description: kit, version and every setting in order. Equal text = equal design.
| arg | type | description |
|---|---|---|
| self | any | |
| d | Descriptor |
fingerprint(self: any, d: Descriptor, ignore: { [string]: boolean }?) → string
A 16-hex-character fingerprint: two descriptions with the same fingerprint are the same design. `ignore` = { settingId = true } leaves settings out (e.g. paint, to group designs that share a body).
| arg | type | description |
|---|---|---|
| self | any | |
| d | Descriptor | |
| ignore | { [string]: boolean }? |
b36(n: number) → string
| arg | type | description |
|---|---|---|
| n | number |
unb36(t: string) → number
| arg | type | description |
|---|---|---|
| t | string |
encValue(s: Setting, v: any) → string
| arg | type | description |
|---|---|---|
| s | Setting | |
| v | any |
decValue(s: Setting, t: string) → any
| arg | type | description |
|---|---|---|
| s | Setting | |
| t | string |
encode(self: any, d: Descriptor, opts: any?) → string
The recipe of a description as a short string. opts.all = true locks every setting.
| arg | type | description |
|---|---|---|
| self | any | |
| d | Descriptor | |
| opts | any? |
decode(self: any, code: string) → void
Read a code back into { seed, preset, lock } (what `describe` takes), or nil and why.
| arg | type | description |
|---|---|---|
| self | any | |
| code | string |
fromCode(self: any, code: string) → Descriptor
Describe straight from a code.
| arg | type | description |
|---|---|---|
| self | any | |
| code | string |
derive(self: any, d: Descriptor) → any
Whatever the kit's `derive` makes of a description (the kit's own geometry numbers), cached by fingerprint.
| arg | type | description |
|---|---|---|
| self | any | |
| d | Descriptor |
Setting = {Preset = {Descriptor = {Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Showing up to 3 levels deep. Open a part to see what it holds further down.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.