Menu docs: clarify that image paths must be escaped to correctly render on Windows (#15072)

This commit is contained in:
Zughy 2024-08-28 15:37:43 +02:00 committed by GitHub
parent c893e0b72b
commit 3441fd6e04
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -8,6 +8,15 @@ The main menu is defined as a formspec by Lua in `builtin/mainmenu/`
Description of formspec language to show your menu is in `lua_api.md` Description of formspec language to show your menu is in `lua_api.md`
Images and 3D models
------
Directory delimiters change according to the OS (e.g. on Unix-like systems
is `/`, on Windows is `\`). When putting an image or a 3D model inside a formspec,
be sure to sanitize it first with `core.formspec_escape(img)`; otherwise,
any resource located in a subpath won't be displayed on OSs using `\` as delimiter.
Callbacks Callbacks
--------- ---------
@ -62,6 +71,12 @@ Functions
Filesystem Filesystem
---------- ----------
To access specific subpaths, use `DIR_DELIM` as a directory delimiter instead
of manually putting one, as different OSs use different delimiters. E.g.
```lua
"my" .. DIR_DELIM .. "custom" .. DIR_DELIM .. "path" -- and not my/custom/path
```
* `core.get_builtin_path()` * `core.get_builtin_path()`
* returns path to builtin root * returns path to builtin root
* `core.create_dir(absolute_path)` (possible in async calls) * `core.create_dir(absolute_path)` (possible in async calls)