Skip to content

Glow

Needs the internal running and needs_internal = true in script_info. Without the flag every function returns false.

glow.set(ptr, r, g, b [, a [, width [, fill]]])  -> boolean
glow.clear(ptr)                                   -> boolean
glow.clear_all()                                  -> boolean

Outlines a player or an entity in a colour you choose. It is the same glow the menu uses for players.

glow.set(ptr, r, g, b [, a [, width [, fill]]])

ArgumentTypeWhat it is
ptrintegerWhich entity. p:entity_ptr() for a player, row.ptr for an entities.by_class row
r, g, bintegerColour, 0 to 255
aintegerAlpha, 0 to 255. Default 255
widthnumberOutline width. Default 1
fillinteger0 outline only (default), 1 solid, 2 health. The same three choices as the menu's Fill setting

Colour values must be whole numbers. Anything outside 0 to 255 is clamped.

Calling it again on the same entity changes that entity's glow. If two scripts glow the same entity, the last call wins.

lua
script_info = { name = "low_hp_glow", needs_internal = true }

function on_tick()
    for _, p in ipairs(get_players()) do
        if p:is_alive() and p:get_health() < 250 then
            glow.set(p:entity_ptr(), 255, 60, 60, 255, 2)   -- thick red outline
        else
            glow.clear(p:entity_ptr())
        end
    end
end

Any entity with a row works the same way:

lua
local rows = entities.by_class("npc_trooper")
if rows then
    for _, e in ipairs(rows) do
        glow.set(e.ptr, 80, 200, 255, 200, 1, 1)   -- solid light blue
    end
end

glow.clear(ptr) and glow.clear_all()

glow.clear(ptr) removes one entity's glow.

glow.clear_all() removes every glow set by every script, not only yours. To remove only your own, clear them one by one.

Notes

  • A glow stays until you clear it. Clear it when you no longer want that entity lit.
  • true means stored, not showing. Check internal.is_loaded(). If the internal is not running, nothing is drawn.
  • Up to 64 entities can glow at once, across every script. Past that, new ones are ignored.
  • Your glows are cleared when your script is turned off or errors. You do not need on_disable for that.