SCAR TOOLKIT
AoE4 SCAR & Lua scripting reference

AoE4 SCAR & Lua Scripting Reference

A central hub for Age of Empires IV SCAR & Lua scripting: engine functions, helper patterns, HUD hooks, automation ideas and RTS tool workflows.

This page focuses on SCAR, Relic’s Lua-based scripting layer used inside Age of Empires IV. If you are building overlays, automation helpers, AI experiments or scenario scripts, this is where you keep track of engine calls, patterns and working examples.

What this reference is and where it comes from

The function names and categories used in this reference are compiled from multiple sources:

The goal is to have a practical, AoE4-focused list of the calls you will actually touch when building tools: player queries, entity groups, UI hooks, camera helpers, rules, and event callbacks – not just a raw dump.

SCAR Toolkit and this site are fan-made and are not affiliated with Xbox Game Studios, World’s Edge or Relic Entertainment. All trademarks are property of their respective owners.

Core patterns

Basic SCAR script structure for AoE4

Most single-file experiments in SCAR Toolkit follow a simple pattern: wrap your logic in a function, register it using Rule_AddOneShot or a timer, and keep helpers local so they don’t pollute the global namespace more than necessary.

-- Minimal SCAR example pattern used in SCAR Toolkit

function CustomScript()
    -- 1. Grab the local player
    local p = Game_GetLocalPlayer()
    if not p then
        return
    end

    -- 2. Add your test logic here
    --    Examples:
    --    - print("Hello from SCAR Toolkit")
    --    - query entities around the TC
    --    - place a minimap marker
end

-- Run once when injected
Rule_AddOneShot(CustomScript)

From here you can attach more rules: Rule_Add with timers for periodic logic, Rule_AddPlayerEvent for event-based reactions (being attacked, commands issued, upgrades finished, etc.).

Common SCAR families you’ll use

In practice, AoE4 SCAR scripts tend to lean on a few core function families:

  • Game_* – high-level game info (Game_GetLocalPlayer, replay state, etc.).
  • Player_* – per-player data (resources, population, civ, team).
  • EGroup_* / SGroup_* – entity and squad grouping, filtering, counting.
  • Squad_* / Entity_* – fine-grained operations on game objects.
  • Position_* – distance checks, proximity queries, coordinates.
  • UI_* – minimap markers, pings, HUD text, threat arrows.
  • Rule_* – timers, one-shots, event-driven rules.

SCAR Toolkit’s job is to make experimenting with these calls less painful: quick injection, logging, minimap visualization, and side panels that show what your script is actually doing.


Your reference content

Function index & categories

Below is the space where you can maintain a detailed function list: grouped by topic, searchable, and kept in sync with your own notes or generated data. You can structure this however you like – by namespace, by use case (HUD, minimap, entities, AI), or by script “recipes”.

Tip: If you’re generating this list from a JSON file or build step, keep this page as the shell and have your script inject the function tables into a container element here.


Last updated: 2025 – This reference focuses on AoE4’s SCAR behaviour as observed in current patches. If a future update changes function availability or behaviour, keep notes here so your scripts stay in sync.