Vehicles (Profiles) - photonle/Photon-v2 GitHub Wiki

Vehicle configurations in Photon 2 are given the generic term Profiles. This is because Photon 2 is designed to be "entity agnostic," and is not locked down to just prop_vehicle_jeep entities (which is part of the Source engine's native vehicle platform).

Creation

Vehicle files should be created in the following directory:

garrysmod/addons/my_custom_addon/lua/photon-v2/library/vehicles/unique_vehicle_id.lua

The top of the vehicle file should have the following:

if (Photon2.ReloadVehicleFile()) then return end
local VEHICLE = Photon2.LibraryVehicle()

VEHICLE.Title 		= "Readable Vehicle Title"
VEHICLE.Vehicle		= "base_vehicle_name"
VEHICLE.Category 	= "My Category"
VEHICLE.Author		= "Your Name"

[!IMPORTANT] The category "Photon 2" is internally protected to only allow official Photon 2 vehicles. If an unofficial vehicle uses this category name, it will be changed to "Photon 2: Addons" and a warning will appear in the logs.

-- This will change to Photon 2: Addons
VEHICLE.Category = "Photon 2"

This is specifically because some authors are copying default vehicle file code (which uses "Photon 2" as the category) for their test vehicles and forgetting to remove them before publishing their addons.

Equipment

Equipment configures components, props, sub-materials, and more that will be added to vehicle and optionally adjusted by players in game.

See the Equipment page for more information.

VEHICLE.Equipment = {
	{
		Category = "Category Name",
		Options = {
			{
				Option = "Option Name",
			},
			{
				Option = "Option 2 Name",
				Variants = {
					{
						Variant = "Variant Name",
					}
				}
			}
		}
	}
}

Platform Support

Photon 2's internal structure is flexible enough to work on any type of networked entity. Unlike Photon LE, Photon 2 uses a dedicated controller entity that's responsible for Photon-related networking and logic. This drastically enhances compatibility with both other addons and vehicle platforms alike.

Automatic Compatibility

By default, Photon 2 integrates with Garry's Mod's Vehicle list, which itself is actually flexible enough to support most third-party vehicle platforms by simply changing the Class = variable to the desired entity class.

Input Schemas

Input Schemas define the expected channels and modes that are to be used with a profile/vehicle. Schemas are utilized by player command queries and the HUD, allowing developers to change the labels, icons, supported modes and orders of specific modes.

When a schema is applied, Photon will automatically verify compatibility with the current equipment configuration of a profile/vehicle. If the schema defines a mode that is not used by any component, the mode will omitted and ignored by command queries and the HUD.

Default

Photon2.RegisterSchema({
    Name = "Default",
    Inputs = {
        ["Emergency.Warning"] = {
            { Label = "PRIMARY" },
            { Mode = "MODE1", Label = "STAGE 1" },
            { Mode = "MODE2", Label = "STAGE 2" },
            { Mode = "MODE3", Label = "STAGE 3" },
        },
        ["Emergency.Directional"] = {
            { Label = "ADVISOR" },
            { Mode = "LEFT", Label = "LEFT" },
            { Mode = "CENOUT", Label = "CTR/OUT" },
            { Mode = "RIGHT", Label = "RIGHT" }
        },
        ["Emergency.Marker"] = {
            { Label = "CRZ" },
            { Mode = "CRUISE", Label = "CRZ" }
        },
        ["Emergency.Auxiliary"] = {
            { Label = "AUX" },
            { Mode = "MODE1", Label = "RED" },
            { Mode = "MODE2", Label = "WHI" },
        },
        ["Emergency.Siren"] = {
            { Label = "SIREN" }
        }
    }
})