Data stored in game.ini

Hello,


I would like a script that gives me the ability to store and read data from the game.ini file.


1) storestring_in_ini('keyname','datastring')


This script command (or something similiar) should check if a line with the keyname already exists in the ini-file.


If yes, rewrite the datastring to the new one, if not add the line and store the data there.


2) stringvar = readstring_in_ini('keyname')


This script command should check if the line with keyname exists, if yes it returns the stored datastring if not it returns an empty string.


Example:


Line in game.ini:


Titlepicture=second.png


(with keyname Titlepicture and datastring second.png)


And then that example can be used with a splashscreen script or other scripts to change the picture on the titlescreen depending on the last stored name (for example by story progress)


The Multilanguage-Addon for the SES external text script already stores the language setting into the game.ini - that script might be used as an example how to do this in a more general way:


http://forums.rpgmakerweb.com/index.php?/topic/6608-external-text-now-v22-get-text-eol-fix/


http://pastebin.com/732n2WRf
What about just regular text files?


Parsing an ini is fairly complex if you want to start getting into sections.


Unless you just want a simple key=value storage.
Zeriab provided a wrapper for that a while ago. Here's the post.

http://forums.rpgmakerweb.com/index.php?/topic/150-rubyrgssx-questions-that-dont-deserve-their-own-thread/?p=58709
@Tsukihime: I was interested only in simple storage.


I'll check the wrapper, it looks like that would be sufficient.
Interestingly enough it seems that with my wrapper you can modify the Game.ini file even if the game is located in a protected folder like C:\Program Files (x86)\MyGame

*hugs*

 - Zeriab
There is a script made by Napoleon called Napoleons Inifile which does exactly what you want (if I understood it right).

It has the ability of checking and changing things in the ini file.

Original thread: https://forums.rpgmakerweb.com/threads/data-stored-in-game-ini.29760/