Lua · Examples · HUD

Team score bar

T and CT score on top of the screen, with the round number and a round timer.

Uses: globals.score, game.round, game.time

team_score_bar.lua
-- name: Score Bar
-- author: Adolfjon
-- version: 1.0
-- description: Score, round and round time on top.

local bg = color(12, 14, 18, 215)
local tcol = color(234, 190, 84)
local ctcol = color(110, 160, 240)
local white = color(240, 242, 246)
local dim = color(150, 156, 168)

function on_frame()
    if not game.in_match() then return end
    local t, ct = globals.score()
    if t < 0 then return end
    local w = draw.screen()
    local x, y, bw = w / 2 - 110, 12, 220
    draw.rect_filled(x, y, bw, 42, bg, 10)
    draw.rect_filled(x, y, bw / 2, 3, tcol, 2)
    draw.rect_filled(x + bw / 2, y, bw / 2, 3, ctcol, 2)
    local ts, cts = tostring(t), tostring(ct)
    draw.text(x + 20, y + 10, ts, tcol, 22)
    local cw = draw.text_size(cts, 22)
    draw.text(x + bw - 20 - cw, y + 10, cts, ctcol, 22)
    local secs = math.floor(game.time())
    local mid = "R" .. game.round() .. "  " .. string.format("%d:%02d", secs // 60, secs % 60)
    local mw = draw.text_size(mid, 13)
    draw.text(x + (bw - mw) / 2, y + 15, mid, dim, 13)
end

Install it

  1. Press Copy on the code above.
  2. In the menu, open Lua and press From Clipboard. The file is named from its -- name: line.
  3. Turn the script on in the list. Its settings show on its own tab.

Change anything you like and press Save (Ctrl+S) in the editor; the script reloads at once. See Getting started for the other ways to add scripts.