diff --git a/automated_updates_data.json b/automated_updates_data.json index 80568805d6..224f9fc40e 100644 --- a/automated_updates_data.json +++ b/automated_updates_data.json @@ -88,6 +88,10 @@ { "date": "2026-04-02", "summary": "Improved multiplayer docs: added Quick Join section, documented player username/ping/last-joined/last-left expressions, lobby ID expression, custom message variable variant, and synchronization rate action" + }, + { + "date": "2026-04-03", + "summary": "Fixed filesystem docs (wrong 'saved' in load paths, duplicate delete heading, added ReadDirectory, UserHomePath, DirectoryName, FileName, ExtensionName) and fixed screenshot docs (broken expression syntax, removed outdated beta note, added desktop-only warning)" } ] } diff --git a/docs/gdevelop5/all-features/filesystem/index.md b/docs/gdevelop5/all-features/filesystem/index.md index a53d7d5ad6..06f9d1cb69 100644 --- a/docs/gdevelop5/all-features/filesystem/index.md +++ b/docs/gdevelop5/all-features/filesystem/index.md @@ -131,7 +131,7 @@ This action loads the JSON formatted text from a file and converts it into a sce == Parameters == ** Scene variable: ** The name of the scene variable to which the loaded structure will be added. -** Load path: ** The path on the file system where the file should be saved. +** Load path: ** The path on the file system where the file is located. It is advised to use the expressions for special folders (see below) to keep your game platform independent. ** (Optional) Result variable: ** Variable to store the result. It can either hold the value 'ok': the task was successful or 'error': an error occurred. @@ -143,7 +143,7 @@ This action loads the JSON formatted text from a file and converts it into a sce == Parameters == ** Scene variable: ** The name of the scene variable to which the loaded structure will be added. -** Load path: ** The path on the file system where the file should be saved. +** Load path: ** The path on the file system where the file is located. It is advised to use the expressions for special folders (see below) to keep your game platform independent. ** (Optional) Result variable: ** Variable to store the result. It can either hold the value 'ok': the task was successful or 'error': an error occurred. The variable will be updated, at the moment the file operation has finished. @@ -184,7 +184,7 @@ It is advised to use the expressions for special folders (see below) to keep you --- -#### Delete a file +#### Delete a file (async) This action deletes the file at the given file path __asynchronously__. == Parameters == ** File path: ** The path on the file system where the file is located. @@ -192,6 +192,15 @@ It is advised to use the expressions for special folders (see below) to keep you ** (Optional) Result variable: ** Variable to store the result. It can either hold the value 'ok': the task was successful or 'error': an error occurred. The variable will be updated, at the moment the file operation has finished. +--- + +#### Read directory contents +This action reads the contents of a directory and stores the list of files and subdirectories into a scene variable as an array. This operation is asynchronous. +== Parameters == +** Directory path: ** The absolute path to the directory to read. + +** Scene variable: ** The variable that will receive the list of entries (array of strings with names). If an error occurs, the variable is set to the string `"error"` instead. + ## Expressions These expressions return the path to special folders on the users' operating system. If you use these expressions for loading and saving files it will be guaranteed to work on all supported operating systems. (Currently Windows, Linux, and macOS) !!! tip @@ -216,6 +225,14 @@ This folder is used for storing application settings. #### Path delimiter This expression returns the operating system independent path delimiter character. ("\" on Windows and "/" on Linux and macOS). Use this expression to build cross-platform file paths that can be accessed on all supported operating systems. +#### Home folder +This expression returns the operating system independent path to the _Home_ folder of the user that runs your game (e.g. `C:\Users\Alice` on Windows or `/home/alice` on Linux). +#### Directory name +This expression takes a file or folder path and returns only the directory portion, stripping the filename. Useful when you need to derive a directory path from a known file path. +#### File name +This expression takes a file path and returns only the filename including its extension (e.g. `"screenshot.png"`). +#### Extension name +This expression takes a file path and returns only the file extension including the leading period (e.g. `".png"`, `".json"`). ## Example In order to save a screenshot to the _Pictures_ directory you could write: diff --git a/docs/gdevelop5/all-features/screenshot/index.md b/docs/gdevelop5/all-features/screenshot/index.md index bb4518a422..5b481eb8a0 100644 --- a/docs/gdevelop5/all-features/screenshot/index.md +++ b/docs/gdevelop5/all-features/screenshot/index.md @@ -3,35 +3,29 @@ title: Screenshot extension --- # Screenshot extension -This extension lets you save a screenshot of the running game in a specified folder. +This extension lets you save a screenshot of the running game as a PNG file. -Note: As of GDevelop 5.0.0-beta92 the screenshot action is no longer an extension. Just add an action and search for `screenshot` or go to `Other Actions`/`Screenshot`/`Take screenshot`. - -### Actions - -#### Take screenshot - -Use this action to save a screenshot of everything which is currently drawn on the game window into a *png* file. +!!! note -##### Parameters: + Screenshots are only supported on Windows, Linux, and macOS (desktop exports). Web and mobile exports do not have access to the file system and cannot save screenshots. -**Save path**: The file path where the screenshot should be saved. +### Take screenshot -The save path needs to be an absolute path on the file system (Like "C:\MyFolder\MyScreenshot.png" on Windows)' +Use this action to save a screenshot of everything currently drawn on the game window into a PNG file. If the save path does not end with `.png`, the extension is added automatically. -Relative paths are not supported. +**Save path**: The absolute file path where the screenshot should be saved (for example `C:\MyFolder\MyScreenshot.png` on Windows). Relative paths are not supported. !!! note - In order to create a game that runs on all supported platforms you should use the special folders from the file system extension in combination with the path separator. These determine the path to common folders like *Pictures*, *Documents* or *Desktop* automatically. You can read more about it in [this article](/gdevelop5/all-features/filesystem). + Use the special folder expressions from the [File system extension](/gdevelop5/all-features/filesystem) to build cross-platform paths that work on all supported operating systems. ## Example -This path: - -``` () + () + "my_screenshot.png" ``` +``` +FileSystem::PicturesPath() + FileSystem::PathDelimiter() + "my_screenshot.png" +``` -This will save the screenshot to the *Pictures* folder on Windows, Linux and MacOS. +This saves the screenshot to the *Pictures* folder on Windows, Linux, and macOS. ## Reference