Skip to content
Lily-Rose edited this page Aug 8, 2020 · 16 revisions

This page is all about how to make a custom component for Photon Lighting Engine. This is a detailed word for word page, with code examples for those who aren't visual learners. For those who are visual learners, there is a Video Guide by Schmal.

This approach is an additional "helper" feature, for those who didn't quite fully understand the Video Guide by Schmal or wants to double-check their code versus a finished product.

Things that will be discussed

File Path
COMPONENT.Model
COMPONENT.NotLegacy
COMPONENT.Skin
COMPONENT.Category
COMPONENT.Bodygroups
COMPONENT.ColorInput
COMPONENT.UsePhases
COMPONENT.DefaultColors
COMPONENT.Meta
COMPONENT.Positions
COMPONENT.Sections
COMPONENT.Patterns
COMPONENT.TrafficDisconnect
COMPONENT.Modes

File Path

Expanding onto Schmal's first video, you'll already have a file path directory setup in your addons folder, For example; Tutorial\lua\autorun\"File.Lua, we need to expand onto this to enable custom components to be detected by photon.

For example; Tutorial\lua\autorun\photon\library\auto, you'll then place another .lua within the last folder. Please remember, that the file name for your component needs to be ORIGINAL and unique AS well as the component name within the file as the local name. An example would be; local name = "Your name "what component is"

I prefer doing things such as Lilys M9 ~ This tells you that it was created by Lily and it's an M9. However, you're free to make the component local name whatever you'd like, as long as it is unique and original.

COMPONENT.Model

This is what model will appear when you place the component into your .lua, so for example models/noble/whelen_m9/whelen_m9.mdl, the model that appears will be Noble's Whelen M9. However, you can straight remove this line if you want the component to have no model, which for example is good for headlights or taillights that don't rely on a model.

COMPONENT.NotLegacy

This is an internal checking based on the rotation of the lights, this is best to leave this check marked as; COMPONENT.NotLegacy = true

COMPONENT.Skin

This is if the prop selected has multiple skins it enables you to change it. For example some props might be Skin 0 = Clear glass, where Skin 1 = Red / Blue Glass. This just enables you to change the skin.

COMPONENT.Category

Offical Categories
Hidden
Equipment
Interior
Exterior
Auxiliary
Lightbar

What does this mean? Well, these are only actually relevant if you use the In-game express editor, Photon will automatically place your component under that category. It also means if you later look back at your code or someone else does, they can see where it belongs on a vehicle.

COMPONENT.Bodygroups

This is if the prop selected has multiple body groups it enables you to change it. For example, some props might have a body group to enable you to change the colour of the class for example clear glass, Red / Blue Glass, etc. This just enables you to change the skin.

COMPONENT.ColorInput

This is what enables a user to change the colour of the lightbar/component light by using; Color1 = "BLUE", Color2 = "RED" But unfortunately, this line isn't actually used and is untouched by anything. In theory, it would work as I have described above.

COMPONENT.UsePhases