Builtin Library
README.md
Part
Attach parts to the slots of another object: a wheel to a wheel mount, an
engine to an engine bay, a weapon to a hardpoint, a module to a socket.
Part declares the kinds of slot a part fits. Put it on the root of a bundle that
fills slots (a wheel, an engine, a seat, a turret, a wall module): the bundle
then fits every Slot whose kind its fits names. The declaration lives in
the bundle's template, so a part installed from another world's package fits
by kind the same way. Any other instantiable asset declares the kinds it fits
with a fits list in its .metadata.
Fields
| Field | Type | Notes |
|---|---|---|
fits | { string } | The slot kinds this part fits. |
Methods
| Method | Returns | Notes |
|---|---|---|
:fitsKind(kind) | boolean | Whether fits names kind. |
Usage
-- Author a wheel part and save it as a bundle
local wheel = entity.spawn("SportWheel")
wheel.component.add("Model", { model = "@builtin::meshes.cylinder" })
wheel.component.add("Part", { fits = { "wheel" } })
asset.create("bundle", "SportWheel", { entity = wheel })
Assembly:candidates(path) lists the bundles that fit a slot, and
Assembly:fits(path, part) says why one does not.