Right now as far as I know ZScript has not the capability to read and edit text files. There is a handful of RPG mods including Unreal RPG mod for GZDoom and other mods that utilizes CVAR values instead for editing values. But for a serious RPG project this is a massive pain in the ass because CVAR values are severely limited in what type of variables can be saved. Sven Co-op uses AngleScript and AngleScript per default comes with file editing capabilities which is handy for RPG mods.
I have 2 large GZDoom mods one is a old project of mine which I worked on it almost a decade and another GZDoom mod which I worked on it relative recently with a much cleaner code base, I wanted to add some light RPG elements for my mod but I didn't bothered to do it because as I have mentioned before using CVAR values is really way too limited in capabilities for what I am going to do. So the only CVAR value I have saved is the amount of money the player has and nothing else
Here is some examples for Sven Co-op RPG mod. They utilize text files in order to save player information into a text file, so if GZDoom has similar or even better capbilities then this then it will be much appreciated.
https://github.com/jonnyboy0719/Sven-Coop-RPGMod
https://github.com/jonnyboy0719/Sven-Co ... od-Rewrite
And a GZDoom example which uses ACS+Decorate
https://www.moddb.com/mods/unreal-gold-remake-in-gzdoom
Allow reading and editing text files
Moderator: GZDoom Developers
-
- Posts: 73
- Joined: Thu Jan 21, 2016 2:25 am
Re: Allow reading and editing text files
I have a feeling that it is not allowed to write into file system because of security concerns.
However consider this:
You can read any loaded text file using Wads: https://zdoom-docs.github.io/staging/Api/Base/Wads.html
You can write relatively complex data structures into CVars using Dictionary: https://zdoom.org/wiki/Dictionary
I believe War Trophies does exactly that: viewtopic.php?t=67054
However consider this:
You can read any loaded text file using Wads: https://zdoom-docs.github.io/staging/Api/Base/Wads.html
You can write relatively complex data structures into CVars using Dictionary: https://zdoom.org/wiki/Dictionary
I believe War Trophies does exactly that: viewtopic.php?t=67054
-
- Posts: 47
- Joined: Thu Nov 05, 2020 12:43 pm
Re: Allow reading and editing text files
A pure text file wouldn't be able to contain malicious code anyway if its used only for Data storage such as YAML file format. https://www.redhat.com/en/topics/automa ... at-is-yaml . Some may say that JSON file format might be better but I beg to differ, my greatest issue with the JSON format is that it doesn't allow for comments which makes it for me not human friendly enough.
And how can I utilize this solution in order to save player data such as stats and inventory? I have never heard of you can use the Dictionary variable in order to save into CVAR, that is news to me.Proydoha wrote: ↑Thu Aug 10, 2023 4:26 pm However consider this:
You can read any loaded text file using Wads: https://zdoom-docs.github.io/staging/Api/Base/Wads.html
You can write relatively complex data structures into CVars using Dictionary: https://zdoom.org/wiki/Dictionary
I take a closer look as soon I went over my other code I am working on.Proydoha wrote: ↑Thu Aug 10, 2023 4:26 pm I believe War Trophies does exactly that: viewtopic.php?t=67054
-
- Lead GZDoom+Raze Developer
- Posts: 49188
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Allow reading and editing text files
This is beyond the scope of a Doom engine. If you need such a feature you'll have to implement it yourself.