Part Item

Each part is defined as an entry in your parts table with configurable fields for how it behaves during installation, usage, and interaction with vehicles.

πŸ“„ Fields:

Field
Type
Required
Description

label

string

βœ…

The display name of the part.

searchChance

number

βœ…

Chance this item is found in a search. Set to 0 to make it unsearchable. Think of it like names in a hatβ€”more entries = higher odds.

weight

number

βœ…

Weight of the part in the inventory (e.g., 1000 = 1kg).

tools

table

❌

Tools required to fit this part. Format: { itemName = quantity }.

consumables

table

❌

Items that will be consumed when installing this part. Same format as tools.

anim

table

❌

Animation config when applying the part.

β†’ dict

string

⚠️

Animation dictionary. Must specify either dict or scenario.

β†’ clip

string

βœ…

Animation clip name.

β†’ flag

number

❌

Optional animation flags.

β†’ time

number

❌

Time in seconds to complete the install animation.

reqParts

array

❌

Names of other parts required before this one can be installed.

model

string

❌

Prop model name shown in hand or placed during install (e.g. "prop_oilcan_01a").

applyRange

number

❌

Max distance from the vehicle to allow this part to be installed.

applyAtBone

string

❌

The bone name where this part applies (e.g., "engine").

canStart

function

❌

Function run to check if the car can start based on this part. Parameters:<br/>β†’ itemExists: boolean (is part installed?)<br/>β†’ _type: string (part name)<br/>Should return: boolean, message.

removePart

function

❌

Function triggered when removing the part. Parameters:<br/>β†’ self: vehicle object<br/>β†’ entity: number (vehicle entity ID)<br/>β†’ _type: string (part name).

addPart

function

❌

Function triggered when adding the part. Same parameters as removePart.


πŸ’‘ Example

luaCopyEditparts = {
    oil_filter = {
        label        = "Oil Filter",
        searchChance = 15,
        weight       = 250,
        tools        = { wrench = 1 },
        consumables  = { oil = 1 },
        anim         = {
            dict  = "anim@amb@clubhouse@tutorial@bkr_tut_ig3@",
            clip  = "machinic_loop_mechandplayer",
            flag  = 16,
            time  = 5
        },
        reqParts     = { "engine_cover" },
        model        = "prop_oilcan_01a",
        applyRange   = 2.0,
        applyAtBone  = "engine",
        canStart     = function(installed, part)
            return installed, installed and "" or "Engine won't start without oil filter."
        end,
        removePart   = function(self, entity, part)
            -- custom logic to clean up or detach
        end,
        addPart      = function(self, entity, part)
            -- apply tuning or set vars
        end
    }
}

Last updated