-
Notifications
You must be signed in to change notification settings - Fork 4
Inputs
This is a reference of Photon 2's standardized inputs. While Photon 2's input scheme is fully customizable, it is recommended to use standardized inputs to maximize inter-component compatibility (as this is what default components are based on).
These are the default input priorities. Inputs with higher numbers override those with lower numbers. Input priorities can be adjusted per component.
-- These are the approximate default values.
-- As they may occasionally change, the actual values can be
-- found in the lua/photon-v2/meta/base_entity.lua file.
ENT.DefaultInputPriorities = {
["Emergency.Cut"] = 160,
["Emergency.Illuminate"] = 150,
["Emergency.SceneForward"] = 140,
["Emergency.SceneLeft"] = 130,
["Emergency.SceneRight"] = 120,
["Vehicle.Signal"] = 110,
["Vehicle.Brake"] = 100,
["Vehicle.Transmission"] = 90,
["Emergency.Directional"] = 80,
["Emergency.Auxiliary"] = 70,
["Emergency.Siren2Override"] = 61,
["Emergency.SirenOverride"] = 60,
["Emergency.Siren2"] = 51,
["Emergency.Siren"] = 50,
["Emergency.Warning"] = 40,
["Emergency.Marker"] = 30,
["Vehicle.HighBeam"] = 20,
["Vehicle.Lights"] = 10,
["Vehicle.Ambient"] = 0
}
Use for the primary warning lights.
-
MODE1
Stage 1 lighting mode. Typically a rear-facing flash pattern with minimal or no forward-facing warning lights activated. Sometimes used to steady-burn all warning lights with a very brief flash on modern setups. -
MODE2
Stage 2 lighting mode. Usually flashes forward-facing warning lights. The rear patterns may be the same as mode 1 or they may flash faster. -
MODE3
Stage 3 lighting mode. Often adds white flashing (including headlights) and occasionally disables any rear-facing amber lighting. Sometimes uses faster flash patterns than mode 2.
Used for scene lighting/illumination.
-
ON
Takedown lighting. Adds dedicated forward-facing white lights. -
FLOOD
Flood lighting. Typically sets most or all forward-facing lights to steady-burn white and is brighter than takedown lighting.
-
ON
Left alley/left side.
-
ON
Right alley/left side.
For cruise/marker lighting.
-
ON
Normal cruise/marker lighting mode.
For traffic advisor patterns.
-
LEFT
Arrow left. -
RIGHT
Arrow right. -
CENOUT
Arrow center-out/diverge.
-
FRONT
Cut out front-facing lights. -
REAR
Cut out rear-facing lights.
-
OFF
Vehicle in a bright/daytime environment. -
DARK
Vehicle in a dark/nighttime environment.
-
HEADLIGHTS
Vehicle headlights on. -
PARKING
Vehicle parking lights on. -
DRLAUTO
Daytime running lights and automatic headlights.
-
BRAKE
Vehicle brake lights.
-
LEFT
Left turn signal. -
RIGHT
Right turn signal. -
HAZARD
Hazard lights (four-way flashers).
-
PARK
Vehicle parked (i.e. no driver). -
DRIVE
Vehicle driving (i.e. has driver). -
REVERSE
Vehicle reversing.
Note
There are no default virtual outputs. They must be either manually configured or automatically added using COMPONENT.Flags
as outputs to be utilized. Furthermore, virtual inputs added from flags will usually copy from an existing channel mode. You only need to implement these modes manually in unusual circumstances.
-
MODE3
When vehicle is parked andEmergency.Warning
is set toMODE3
.
-
MODE3
When vehicle is parked,Emergency.Warning
is set toMODE3
, and the vehicle is in a dark environment.
-
HEADLIGHTS
Headlights that are automatically activated.
For special actions that don't fit the provided default channels, you can use a custom channel instead. Creating and using a new channel requires only three things: a unique name, an input priority, and a command you can bind keys to.
For this example, a channel called Emergency.Command
will be created for the purpose of activating green steady-burn lights on a lightbar. The following segment has been created:
COMPONENT.Segments = {
-- New "Command" segment
Command = {
Frames = {
[1] = "[G] 12 14 16 18 11 13 15 17"
},
Sequences = {
["ON"] = { 1 }
}
}
}
Adding a channel to the COMPONENT.Inputs
section without an assigned input priority will result in an error when saving the component, so the input priority will be added first. To ensure the steady-burn green lights are visible while warning lights are flashing, an input priority number higher than Emergency.Warning
should be used. In this example, we will use 41.
As it's uncommon to adjust input priorities on components, a new COMPONENT.InputPriorities
block will likely need to be added.
COMPONENT.InputPriorities = {
-- This is the new channel, and 41 means it will take
-- priority over Emergency.Warning, which is 40.
["Emergency.Command"] = 41
}
Now that an input priority has been assigned, the new channel can be safely added to COMPONENT.Inputs
. As this channel needs only a basic on/off functionality, the mode used will simply be "ON"
.
COMPONENT.Inputs = {
-- This is the new channel
["Emergency.Command"] = {
-- This is the new mode
["ON"] = {
-- And this is the new segment
Command = "ON"
}
}
}
The component file should now save without any errors or warnings. To verify that the changes were registered, the component can be inspected in the preview browser, where the new input channel and mode should appear under the "Inputs" node.
Next, a command must be created so players actually activate the mode from the vehicle. In the addon project folder, create a new file for the Commands library to load. The path should be based on the following:
garrysmod\addons\my_photon_addon\photon-v2\library\commands\custom_command_file.lua
For this example, a basic toggle on/off command will be used (which will also trigger control panel beeps). This means a button is pressed to turn the channel on, and pressing the same button will turn the channel off again. Adapt the code block to your new channel and mode:
Photon2.RegisterCommand({
-- Use a unique command name
Name = "toggle_command_mode",
-- Use your name
Author = "Your Name",
-- Give the command a short title
Title = "Command Mode",
-- Use an appropriate category (can be anything)
Category = "Custom",
-- Describe what the command does
Description = "Toggles command mode lighting.",
-- Actions that occur when the key is pushed down
OnPress = {
-- Activates controller beep (leave this)
{ Action = "SOUND", Sound = "Controller" },
-- Insert the new channel, then the mode under `Value`
{ Action = "TOGGLE", Channel = "Emergency.Command", Value = "ON" },
},
-- Actions that occur when the key is lifted
OnRelease = {
-- Activates controller beep (leave this)
{ Action = "SOUND", Sound = "Controller" },
}
})
Save the file and restart the game to ensure the file is discovered and loaded correctly.
Next, the command needs to be bound to button. To do this, open the Control Options menu (also called the Input Configuration menu). The new command should appear in the list.
At the bottom of the window, click the button under "Key/Button" that says NONE
, and press a key you wish to bind to the command. As soon as the Input Configuration menu detects a change, a save and discard button will appear at the very bottom of the window. To apply your changes, press "Save Changes."
Note
As of March 11, 2024, it is not possible for vehicle files to manipulate user controls automatically. That means users of your component/vehicle will need to bind a button to the command on their own.
An automatic solution to skip this is planned and being worked on.
Your new channel and command are now ready for use. To test it, simply spawn and enter the vehicle with the component you modified. When you press the assigned button, the mode will toggle on and off.