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.