Scripts are event-driven rules for Dummynation scenarios and mods. Each script waits for a trigger (an event such as a new game starting or a war being declared), checks a condition, and runs a list of actions. Functions are reusable calculations that scripts call.
This schema describes the scripts.json file saved with a custom scenario, and everything inside it: scripts, functions, typed values, conditions, actions, and the full catalogs of commands, expression methods and triggers. The same definitions appear in the SCRIPT, SCRIPT_SOURCE and SCRIPT_FUNCTION roots of a scenario patch (see $defs/scriptPatch).
The in-game script editor reads and writes this format, so building a script there and inspecting the saved file is the quickest way to learn it. Saved files keep scripts in the compact source format (the source property) and functions as JSON. Both forms describe the same tree, and either is accepted when loading.