# Script screens Screens drawn by scripts, alongside the Python screens (`pyscreen:`, `pydestinationsign:`): Lua scripts, run by LuaJIT, and WebAssembly modules, run by the WAMR interpreter (`ref/wamr`). A script gets the same input a Python screen gets (the table in `python_var_doc.md`), returns an RGBA image and, in the cab, may send commands. A Lua script is text, kept with the vehicles and the `scripts/` folder like the Python screens, and changed with any editor. A WebAssembly module is compiled from another language (Rust, C, Zig and the like). Both run sandboxed: a script reaches only the functions of `eu07` below, and reads files only from its own folder and below. A Lua script gets no `io`, `os`, `ffi`, `debug` or `require`, and no precompiled code is loaded. Unlike a Python screen, which refreshes after a time (`python.updatetime`, `updatetime:`), a script screen refreshes every so many rendered frames, set in `eu07.ini`. A call into a script may run at most 200 million instructions (Lua runs without the JIT compiler so that the limit holds). A script that fails, or runs over, is switched off, and the reason goes to the log. ## eu07.ini | key | default | meaning | |--------------------------|---------|--------------------------------------------------------------------------------| | `luascreens.enabled` | 1 | 0: no Lua screens; the vehicles show what they did before | | `wasm.enabled` | 1 | 0: no WebAssembly screens; the vehicles show what they did before | | `screens.cabframes` | 4 | a screen in the cab is refreshed every so many frames (1-1000) | | `screens.externalframes` | 30 | a screen outside the cab (destination sign) is refreshed every so many frames | | `screens.gpupost` | 1 | 0: `led_post` and `resize` of the Lua screens always run on the cpu, as they did before | `wasm.cabframes` and `wasm.externalframes`, the first names of the last two, are read as well. A screen may ask for a longer interval of its own (`frames:` below); the longer of the two counts. Screens sharing an interval are spread over its frames, so they don't all refresh on the same one. A screen in the cab is refreshed only while the player sits in that cab, a screen outside only while its vehicle is drawn. ## .mmd In the cab section, next to `pyscreen:`: ``` luascreen: { ekran.lua target: screen01 frames: 6 parameters: id=1&mode=full } wasmscreen: { ekran.wasm target: screen02 } ``` | key | meaning | |---------------|---------------------------------------------------------------------------------------------------| | (first token) | the script, relative to the vehicle folder when it has no path of its own | | `target:` | the submodel the screen is drawn on (its texture is replaced); `none` for a screen that only sends commands | | `frames:` | the screen's own refresh interval, used when longer than `screens.cabframes` | | `parameters:` | extra `key=value` pairs, `&`-separated, added to the input | A touch on the screen's submodel comes in the input as the list of points `touches`, as for the Python screens. In `internaldata:`, next to `pydestinationsign:`: ``` luadestinationsign: { scripts/led_111a20.lua parameters: kod_e=IC&kod_p=TLK&kod_o=R instance: name } destinationsignbackground: make:scripts/led_111a20.lua?dummy=1 ``` `luadestinationsign:` and `wasmdestinationsign:` take the keys of `pydestinationsign:` (`instance:`, `parameters:`, `background:`) and `frames:`. The input is what a Python sign gets: the timetable (`$timetable`), `_id1` (the train), `_id2` (the instance) and the parameters, read anew on every refresh, so the sign can follow the journey. The vehicles of one train showing the same request share one screen and one texture. A static destination texture, when there is one, still comes first. A blank sign (`background:`, or the older `destinationsignbackground:`) named `make: