18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 04:47:06 +01:00
Files
maszyna/scripting
maj00r ee03ddf0f1 fix(python): each cab screen runs in globals of its own
All the Python screens ran in the one __main__ namespace, so a screen could rebind a name another screen, or
abstractscreenrenderer itself, relied on. scripts/screen_tablet_km.py (EN57AKM) does `from time import time`, after
which file_on_disk() of abstractscreenrenderer failed on Linux, where it looks a file name up in another case, with
"AttributeError: 'builtin_function_or_method' object has no attribute 'monotonic'". The same goes on any system for
a screen that reads `time` as a module once a tablet screen is loaded, and quietly for the colours, the helpers
(trainNumber, headZeros) and the table settings that screens of a vehicle define differently.

A screen file now runs in globals of its own, a copy of those of abstractscreenrenderer, so the 51 screens that
check `"abstractscreenrenderer" in globals()` still find its class. Its builtins are python's own and the names the
screens loaded so far define (the last one's when several do), so a screen that reads a name another screen defines
(monitoring4, journeyTimeSecs, czarny) finds it as before. The class of the screen is looked up in its own globals,
and in those names when the file doesn't define it. abstractscreenrenderer keeps running in __main__, which the
screens no longer change.

No change to the game data is needed.
2026-11-30 06:27:51 +01:00
..