From 4def28ad0d3aa88b259c82f284f91493d8dda5e7 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Wed, 30 Oct 2024 19:35:37 +0100 Subject: [PATCH] DOCS/man/input: note that properties can be unavailable on init It comes up often in IRC and issues that users don't understand why the path property is initially unavailable, so link the section that mentions it from the Properties section, and expand on how to get these properties. --- DOCS/man/input.rst | 3 +++ DOCS/man/lua.rst | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index e334d4e5d1..763710d198 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1940,6 +1940,9 @@ If an option is referenced, the property will normally take/return exactly the same values as the option. In these cases, properties are merely a way to change an option at runtime. +Note that many properties are unavailable at startup. See `Details on the script +initialization and lifecycle`_. + Property list ------------- diff --git a/DOCS/man/lua.rst b/DOCS/man/lua.rst index a5f8923218..95234c3784 100644 --- a/DOCS/man/lua.rst +++ b/DOCS/man/lua.rst @@ -86,7 +86,8 @@ own event handlers which you have registered with ``mp.register_event``, or timers added with ``mp.add_timeout`` or similar. Note that since the script starts execution concurrently with player initialization, some properties may not be populated with meaningful values until the relevant subsystems have -initialized. +initialized. Rather than retrieving these properties at the top of scripts, you +should use ``mp.observe_property`` or read them within event handlers. When the player quits, all scripts will be asked to terminate. This happens via a ``shutdown`` event, which by default will make the event loop return. If your