Multi-Script Projects
A single .cat file can define multiple CatWeb scripts using the script directive. This keeps code organized while producing multiple CatWeb scripts.
script "movement":
on loaded:
initBoard()
fn initBoard():
createTable("items")
script "utils":
on loaded:
log("Utilities loaded")Each script block produces a separate entry in the compiled JSON output.
When used with the Catpile editor, scripts are placed under their parent UI elements in the VFS tree. The compiler merges compiled scripts back into the correct position using alias matching.
Each script block is compiled independently:
cpile site.cat -o output.jsonThe output contains one array entry per script:
[
{"class": "script", "alias": "movement", "content": [...], "globalid": "..."},
{"class": "script", "alias": "utils", "content": [...], "globalid": "..."}
]When importing and recompiling a CatWeb page, the editor:
- Decompiles the page to
.catfiles (one per script) - Stores UI element data in the VFS
- On "Full Project" compile, sends all scripts to the API
- Merges compiled scripts back into the UI tree
- Returns complete page JSON with
{favicon, webcontent, title, background}
Page properties (favicon, title, background, description, thumbnail_id) are preserved during import and re-included in compiled output.
{
"favicon": "122781995056465",
"title": "[W.I.P] Catpile Demo",
"background": "#323232",
"webcontent": [
{"class": "script", "alias": "movement", "content": [...]},
{"class": "Frame", "globalid": "myFrame", "size": "{0.5,0},{0.5,0}"}
]
}The .catui file maps element paths to global IDs:
{
"paths": {
"Page.FileLoader": "5s",
"Page.FileLoader.Load": "@<",
"Page.FileLoader.FileInput": "2\""
},
"tree": [...],
"ui": [...]
}Generated by the decompiler. Used by the compiler to resolve page. references.