Skip to content

Instantly share code, notes, and snippets.

@rdelian
Last active December 1, 2023 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdelian/e0c3da953869d1606f602e6d8e506820 to your computer and use it in GitHub Desktop.
Save rdelian/e0c3da953869d1606f602e6d8e506820 to your computer and use it in GitHub Desktop.
de_underglow Tutorial

Effects

There are 2 types of effects "step" and "breath". Both support single and multi colors as well as custom input from user for the first color.

Syntax

parameter description required
title Button name in Effects menu YES
type "step" OR "breath" YES
input Allow the user to enter a RGB value OPTIONAL
colors a list with colors YES

Example

{
    title = "Red & White",
    type = "breath",
    colors = {
        {255, 0, 0},
        {255, 255, 255}
    }
}

For more examples see ./config/colors.lua


Toggles

Neons will be enabled and disabled based on the values inside anim

Syntax

parameter description required
title Button name in Toggles menu YES
echo Play the effect in a loop (reverse play once finished) OPTIONAL
anim a list with neons state step by step YES
xenon a list with xenon state step by step OPTIONAL

anim => each element of the list contains a list with 4 values which ca be either 1 or 0
These indicates if the specific neons should be on or off. The order is the following LEFT, RIGHT, FRONT, BACK

xenon => same as anim 1=ON, 0=OFF

So if we wanna have an effect which will turn on the sides and then the front an rear one, it will look like this:

...
anim = {
    {1, 1, 0, 0},
    {0, 0, 1, 1}
}
...

Example

-- this will toggle the neons in this order: (REAR) > (SIDES) > (FRONT + XENON)
{
    title = "Forward",
    echo = false,
    anim = {
        {0, 0, 0, 1},
        {1, 1, 0, 0},
        {0, 0, 1, 0}
    },
    xenon = {0, 0, 1}
}

For more examples see ./config/toggles.lua


For developers

Functions can be accessed through exports.de_underglow:FUNCTION_NAME , if you find a use case for something that isn't accesible let me know.

API:

---@param bool => Show or hide the menu
function ToggleMenu(bool)

---@param handle => Car handle
---@param data => table with 4 elements which can be 1 or 0, order follows `SetVehicleNeonEnabled` format
function ToggleVehicleNeons(handle, data)

---@param handle => Car handle
---@param e => effect data table
---@info Needs to be run in a loop with max 10ms for Citizen.Wait, it also uses the Citizen.Wait function internaly
-------- so a speratate thread is more suited
function AnimVehicleNeonsColor(handle, e)

---@param handle => Car handle
---@param e => effect data table
---@info Needs to be run in a loop with max 100ms for Citizen.Wait
function AnimVehicleNeonsToggle(handle, e)

Example

local deug = exports.de_underglow -- Store the functions in a variable
local show_menu = false

CreateThread(function()
    while true do
        Wait(0)
        if IsControlJustPressed(0, 38) then
            show_menu = not show_menu
            deug:ToggleMenu(show_menu)
        end
    end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment