diff --git a/Manual/contents/Additional_Information/Additional_Information.htm b/Manual/contents/Additional_Information/Additional_Information.htm index 7a7b1ba32..67de2e103 100644 --- a/Manual/contents/Additional_Information/Additional_Information.htm +++ b/Manual/contents/Additional_Information/Additional_Information.htm @@ -4,7 +4,7 @@
This section of the manual contain a collection of miscellaneous articles related to programming and the way the GameMaker Language works. The following articles are designed as companion articles to further expand your understanding of how GameMaker works and how to get the most from the different language features available:
When using the file system functions or included files with GameMaker it is vitally important to know exactly how the file system works and what things are going on behind the scenes. To that end, this section is designed to explain and clarify exactly how things are stored, where they are stored and what possible limits or workarounds there may be to this system.
-The first and most important thing to note about the file functions is that they are limited - in general and by default - to the sandbox. What this means is that GameMaker cannot save or load files from anywhere that is not part of the game bundle or the local storage for the device without explicit input from the user, and even then this input is limited to only Windows, macOS and Ubuntu (Linux) target platforms.
+When using the file system functions or included files with GameMaker, it's important to know how the file system works and what things are going on behind the scenes. This section is designed to explain and clarify exactly how things are stored, where they are stored and what possible limits or workarounds there may be to this system.
+The first thing to note about the file functions is that they are limited - in general and by default - to the sandbox. What this means is that GameMaker cannot save or load files from anywhere that is not part of the game bundle or the local storage for the device without explicit input from the user, and even then this input is limited to only Windows, macOS and Ubuntu (Linux) target platforms.
It is possible to turn off sandboxing on the Desktop targets (Windows, macOS, and Ubuntu) by checking the Disable file system sandbox option in the Game Options for the target platform. You do this at your own risk, and while this will open up file saving and loading and permit you to access files anywhere on the given system, it may still be limited by the OS permissions.
+To understand the sandbox first of all you need to understand that there are two distinct areas for files:
The following diagram may help you to visualise this better:
-When your game is sandboxed, the two target areas - the bundle directory and the local storage area - are available on each target platform, but on each one they will work slightly differently. However GameMaker has abstracted out the main essence of what can and can't be done, making it easier to re-target games to multiple environments.
-To start with, you should understand what is meant when we talk of the working_directory. This is a synonym for the two possible save locations (as illustrated by the diagram above) and when you use that directory it will do one of two things depending on whether you are reading or writing, and whether the file you are reading from has been changed or not:
+When your game is sandboxed, only the two target areas - the file bundle and the save area - are available on each target platform, but on each one they will work slightly differently. However GameMaker has abstracted out the main essence of what can and can't be done, making it easier to re-target games to multiple environments.
+To start with, let's look at how files are looked up in GameMaker, say if you do a read:
+buf = buffer_load("my_file.dat");
+or a write:
+buffer_save(buf, "my_file.dat");
+This will do one of two things depending on whether you are reading or writing:
In general GameMaker will handle all this for you and you rarely need to use the working_directory built-in variable.
Using these two simple rules we can now see how the following functions work (these are examples to help you to visualise the process for the different functions available):
On the Windows, macOS and Ubuntu (Linux) platforms there are two ways to save and load files from outside of the sandbox and that is either using the functions get_open_filename and get_save_filename (both of these functions will require that the user select an area for loading and saving and the return string can then be used in the rest of the file functions to bypass the sandbox - see the function descriptions for more details). The other way is to disable the sandbox altogether from the Game Options for the target platform (only available for Desktop targets, as discussed further up this page).
+On the Windows, macOS and Ubuntu (Linux) platforms there are two ways to save and load files from outside of the sandbox and that is either using the functions get_open_filename and get_save_filename (both of these functions will require that the user select an area for loading and saving, and the returned string can then be used in the rest of the file functions to bypass the sandbox - see the function descriptions for more details). The other way is to disable the sandbox altogether from the Game Options for the target platform (only available for Desktop targets, as discussed further up this page).
On HTML5 it is also possible to load files from outside the sandbox from a server, however this should only be done using the function buffer_load_async as loading synchronously has been deprecated on most browsers and will eventually be obsoleted. This means that files being loaded in this way should be saved as binary files - for example, you can save an *.ini as a string (see ini_close for details) and then write that into a buffer which can then be saved and loaded using the async functions. Note that if you are loading images using sprite_add then these are already dealt with asynchronously.
-You should also know that each target platform has its own save area where files and directories can be written to and read from. Below is a list of those areas for each target when sandboxed:
+Each target platform has its own save area where files and directories can be written to and read from. Below is a list of those areas for each target when sandboxed: