[RESOLVED] File functions with Web and Android builds + JSON or XML parser

Started by Joacim Andersson, Thu 26/12/2024 11:09:14

Previous topic - Next topic

Joacim Andersson

First I want to start with an apology since I, asked for 2 different things in this post, but in my mind, they are connected.

1. The File* functions in AGS seem simple enough to use, I just wondered about file locations when building for the web or Android, I only need read permission but the files also have to be "installed" somehow.

What is the best solution for this? Can the $DATA$ tag be used and if so where do I place the files for them to be included in the build?

2. Are any modules available for AGS to read and traverse a structured file, as in JSON or XML format?

Crimson Wizard

There are 2 script modules which work with text-based file formats:

INI file module:
(i used this one)
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-inifile2-1-0-0-ags-3-x-read-and-write-configuration-to-files/
Among other things, this module can be used to read or write AGS own config file, since it's written in INI format.

JSON module:
(never tried this myself)
https://www.adventuregamestudio.co.uk/forums/modules-plugins-tools/module-jsonparser-0-1-0/



$DATA$ tag should work anywhere, since it reads from installation package. The engine hides implementation details. $DATA$ tag supports subdirectories (actually, all tags do).

With Android, normally you should package all your game files into APK.
With Web, I guess that you place files together with the other game files.

Besides that, you can package custom files inside the game.ags. To do this use "Package custom data folder(s)" option in General Settings (see explanation here: https://adventuregamestudio.github.io/ags-manual/GeneralSettings.html#compiler)

eri0o

If you use the data tag it will be inside the game package so there is not anything to do differently in any platform. It will work the same. The data tag is read only as it's inside the game package and it can't be modified by the game itself.

The web only use a virtual file system, and files in the save directory are persisted through a domain dependant key value database in the browser itself - this is not synced in any way by the browser in a cross platform way. There is no way currently to download the files from the web build in the browser - except if you hack something there. The web build is meant for small games or demo games, and the files persisted in the browser are just a small convenience.

Crimson Wizard

Quote from: eri0o on Thu 26/12/2024 12:01:59If you use the data tag it will be inside the game package so there is not anything to do differently in any platform. It will work the same. The data tag is read only as it's inside the game package and it can't be modified by the game itself.

I must clarify: $DATA$ tag reads all game assets from all registered asset paths:
- game dir (it may be a virtual directory depending on platform and installation method, e.g. APK on Android);
- game.ags;
- audio.vox;
- speech.vox;
- alternate audio and speech folders (when running from the Editor).

Joacim Andersson

Quote from: eri0o on Thu 26/12/2024 12:01:59The web only use a virtual file system, and files in the save directory are persisted through a domain dependant key value database in the browser itself
I'm guessing that Window.localStorage is used in the WASM since the save files are persisted even if I close the WebBrowser.

In any case, I'm not going to hack the Web Assembly just to be able to store some basic data files, so I guess I will do it some other way.

But as always, thank you both for your response.

SMF spam blocked by CleanTalk