Skip to reading
PCA Script Programming

30. Headers, includes and shared state

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

The only language header is language 1.0. PCA Script does not have C-style header files, #include, textual macros or an import statement that pastes another file into this one. A leading #include would be a comment.

Code example
function run()
    let library = include_script("utility_pca")
    let total = call_script(library, "add_points", [10, 5])
    set_included_variable(library, "last_total", total)
    return get_included_variable(library, "last_total", 0)
end

With one argument, include_script() checks that a script ID exists and returns that ID. It does not run the other script’s top-level code or import its functions into your local scope. With additional arguments it uses the same call route as call_script().

Code example
function add_points(base: integer, bonus: integer): integer
    return base + bonus
end
Code example
function run()
    return add_points(10, 5)
end

Put the second example in a separate PCA Script called utility_pca. The included-variable helpers use a router-owned dictionary keyed by script ID and variable name. They do not read the other script’s local let declarations. This store is session/cache state, not a saved-game variable system.

A header can describe a public function’s parameters in comments, but its executable definition still belongs in a script record. Use the shared router for libraries and the Variable Designer for saved story state.

Page 38 of 357Permalink
Go to page