diff --git a/automated_updates_data.json b/automated_updates_data.json index 80568805d6..d9b7216a6c 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-08", + "summary": "Improved filesystem docs (added ReadDirectory action, UserHomePath expression, and path utility expressions) and fixed screenshot docs (broken expression syntax, outdated beta note, added desktop-only caveat)" } ] } diff --git a/docs/gdevelop5/all-features/filesystem/index.md b/docs/gdevelop5/all-features/filesystem/index.md index a53d7d5ad6..b4863b6a32 100644 --- a/docs/gdevelop5/all-features/filesystem/index.md +++ b/docs/gdevelop5/all-features/filesystem/index.md @@ -192,6 +192,17 @@ 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 the content of a directory +This action reads the list of files and subdirectories inside a directory and stores them in a scene variable as an array of strings. Each element is the **name** (not the full path) of a file or subdirectory found in that folder. +== Parameters == +** Directory path: ** The absolute path to the directory to read. + +** Variable: ** The scene variable where the result will be stored. On success, it becomes an array of strings. On error, the variable is set to `"error"`. + +This is useful for scanning a save folder for existing save files, listing level files stored as JSON, or building a simple file browser. + ## 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 @@ -213,10 +224,22 @@ This folder is used for temporary files that your operating system can delete at #### Userdata folder This expression returns the operating system independent path to the _UserData_ folder of the user that runs your game. This folder is used for storing application settings. +#### User home folder +This expression returns the path to the current user's home directory (e.g. `C:\Users\username` on Windows, `/home/username` on Linux, `/Users/username` on macOS). #### 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. +## Path utility expressions + +When you have a file path as a string, these expressions let you extract individual parts of it: + +- **Directory name**: Returns the directory portion of a path, without the filename. For example, from `C:\Games\saves\save1.json` it returns `C:\Games\saves`. +- **File name**: Returns the filename with its extension. From `C:\Games\saves\save1.json` it returns `save1.json`. +- **Extension name**: Returns the file extension including the leading period. From `save1.json` it returns `.json`. + +These are helpful when you receive a full file path (for example from the **Read the content of a directory** action combined with the folder path) and need to extract just the name or extension. + ## 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..51e16ed2b4 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 to a 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 can only be saved to a file on **Windows, Linux, and macOS**. This action has no effect on web or mobile exports. To capture a screenshot on other platforms, consider rendering to a texture or using a platform-specific solution. -**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 the **"Take screenshot"** action to save everything currently drawn on the game window to a *PNG* file. -Relative paths are not supported. +**Save path**: An absolute file path where the screenshot will be saved (e.g. `"C:\MyFolder\MyScreenshot.png"` on Windows). Relative paths are not supported. -!!! note +!!! tip - 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 expressions from the [File system extension](/gdevelop5/all-features/filesystem) to build cross-platform paths automatically, rather than hardcoding them. ## 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