Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gdevelop5:all-features:filesystem [2019/01/24 20:03]
4ian
gdevelop5:all-features:filesystem [2019/06/20 23:46] (current)
4ian
Line 1: Line 1:
-# File system ​extension+# File system
 This extension gives you access to the file system of the pc the game is running on. This extension gives you access to the file system of the pc the game is running on.
-<​note>​This ​only works on Windows, Linux and MacOS. Mobile games and web games are currently not supported.</​note>​+<​note>​This works only on Windows, Linux and MacOS. Mobile games and web games are currently not supported.</​note>​
  
 ## File system versus Storage extension ## File system versus Storage extension
 GDevelop offers two different ways to save data permanently. The storage extension and the file system extension. GDevelop offers two different ways to save data permanently. The storage extension and the file system extension.
  
-Since GDevelop is built upon web technology at the time of writing every game is basically a website that either runs directly in a browser (Web export) or inside a stripped down browser container "​Electron"​ (Windows, MacOS, Linux) / "​Apache Cordova"​ (Android, iOS).+Since GDevelop is built upon web technologyat the time of writingevery game is basically a website that either runs directly in a browser (Web export) or inside a stripped down browser container "​Electron"​ (Windows, MacOS, Linux) / "​Apache Cordova"​ (Android, iOS).
  
-All those platforms offer web storage, integrated into the browser component of their runtimes where data can be saved in a dictionary like key/value style.+All these platforms offer web storage, integrated into the browser component of their runtimes where data can be saved in a dictionary like key/value style.
  
-For security reasons web browsers don't let websites write any data to the file system of the pc, they are executed on. Only the Electron based export offers ​this functionality.+For security reasonsweb browsers don't let websites write any data to the file system of the computer ​they are executed on. Only games exported for Windows, macOS or Linux can use this functionality.
  
-### Storage:+### Storage
  
 - It is available on all platforms, a game can be exported to. - It is available on all platforms, a game can be exported to.
Line 20: Line 20:
 - Its maximum capacity is limited to a few megabytes, depending on the type of web browser the player uses. - Its maximum capacity is limited to a few megabytes, depending on the type of web browser the player uses.
  
-- The player has no direct access to the web storage. ​+- The player has no direct access to web storage. ​
  
-### File system:+### File system
  
-- It is only available on Windows, Linux and MacOS.+- It is only available on Windows, Linux and macOS.
  
 - You can save any kind of data. - You can save any kind of data.
Line 37: Line 37:
 ## Asynchronous execution ## Asynchronous execution
 By default, actions get executed synchronously in GDevelop. This means that the game loop waits for each action to finish its execution before it will run the following event. By default, actions get executed synchronously in GDevelop. This means that the game loop waits for each action to finish its execution before it will run the following event.
-Actions ​which take longer than a few milliseconds to execute will freeze the whole execution of the game until they finish. ​+Actions ​that take longer than a few milliseconds to executewill freeze the whole execution of the game until they finish. ​
  
-To avoid those freezes GDevelop supports asynchronous execution of certain actions. If you choose the "​async"​ version of an action the operation will be delegated to a background task which runs in parallel to the game loop. After executing an asynchronous action, GDevelop will immediately execute the next event in the event sheet without waiting for the action to finish.+To avoid these freezesGDevelop supports asynchronous execution of certain actions. If you choose the "​async"​ version of an actionthe operation will be delegated to a background task which runs in parallel to the game loop. After executing an asynchronous action, GDevelop will immediately execute the next event in the event sheet without waiting for the action to finish.
  
-In order to get notified about the status of the background task, the asynchronous actions have an optional result variable. This variable will be updated with the result of the operation ​in the momentthe background task has finished.+In order to get notified about the status of the background task, the asynchronous actions have an optional result variable. This variable will be updated with the result of the operation, at the moment the background task has finished.
  
 By checking its value, you get to know when exactly the operation has finished and with which result: By checking its value, you get to know when exactly the operation has finished and with which result:
Line 49: Line 49:
 - **"​error"​**:​ Something went wrong while trying to perform the action. - **"​error"​**:​ Something went wrong while trying to perform the action.
  
-Saving the name of the next level after completing the previous one in a linear puzzle game will probably not need to be performed ​asynchronously.+Saving the name of the next level after completing the previous one in a linear puzzle gameneed not be done asynchronously.
  
-On the other hand, when trying to add an auto save function to an open world game with procedurally generatedunlimited terrain the game developer will probably not get around saving the game asynchronously due to the heap of data to be written into the file.+On the other hand, when trying to add an autosave ​function to an open world game with procedurally generated unlimited terrainthe game developer will probably not get around saving the game asynchronously due to the heap of data to be written into the file.
  
 It is up to the game developer to decide which variant of the action is suitable for the individual situation. It is up to the game developer to decide which variant of the action is suitable for the individual situation.
Line 71: Line 71:
 == Parameters == == Parameters ==
 ** Directory: ** The absolute file path to the directory which should be created. ** Directory: ** The absolute file path to the directory which should be created.
-It is advised to use the expressions for special folders (see below) to keep you game platform independent.+It is advised to use the expressions for special folders (see below)to keep you game platform independent.
  
-** (Optional) ​result ​variable: ** Variable to store the result. It can either hold the value '​ok':​ task was successful or '​error':​ an error occurred.+** (Optional) ​Result ​variable: ** Variable to store the result. It can either hold the value '​ok': ​the task was successful or '​error':​ an error occurred.
  
 --- ---
Line 85: Line 85:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred.+** (Optional) ​Result ​variable: ** Variable to store the result. It can either hold the value '​ok': ​the task was successful or '​error':​ an error occurred.
  
 --- ---
Line 97: Line 97:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred. The variable will be updated ​in the momentthe file operation has finished.+** (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.
  
 --- ---
Line 109: Line 109:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred.+** (Optional) ​Result ​variable: ** Variable to store the result. It can either hold the value '​ok': ​the task was successful or '​error':​ an error occurred.
  
 --- ---
Line 121: Line 121:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred. The variable will be updated ​in the momentthe file operation has finished.+** (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.
  
 --- ---
Line 133: Line 133:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred.+** (Optional) ​Result ​variable: ** Variable to store the result. It can either hold the value '​ok': ​the task was successful or '​error':​ an error occurred.
  
 --- ---
Line 145: Line 145:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred. The variable will be updated ​in the momentthe file operation has finished.+** (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.
  
 --- ---
Line 157: Line 157:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred.+** (Optional) ​Result ​variable: ** Variable to store the result. It can either hold the value '​ok': ​the task was successful or '​error':​ an error occurred.
  
 --- ---
Line 169: Line 169:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred. The variable will be updated ​in the momentthe file operation has finished.+** (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.
  
 --- ---
Line 179: Line 179:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred.+** (Optional) ​Result ​variable: ** Variable to store the result. It can either hold the value '​ok': ​the task was successful or '​error':​ an error occurred.
  
 --- ---
Line 189: Line 189:
 It is advised to use the expressions for special folders (see below) to keep your game platform independent. 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':​ task was successful or '​error':​ an error occurred. The variable will be updated ​in the momentthe file operation has finished.+** (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.
  
 ## Expressions ## Expressions
Line 211: Line 211:
 === Path delimiter === === Path delimiter ===
 This expression returns the operating system independent path delimiter character. ("​\"​ on Windows and "/"​ on Linux and MacOS). 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.+Use this expression to build cross-platform file paths that can be accessed on all supported operating systems.
  
 ## Example ## Example