Read/Write a particular line from a file

Started by Cassiebsg, Wed 23/03/2016 22:11:24

Previous topic - Next topic

Cassiebsg

Sorry for asking but I've been reading the manual and previous forum posts to this question, and I either concluded that this can't be done the way I thought it could, or I just haven't found the answer yet. :-[

Am using Beta 3.4.0.6 and I want to be able to save some data into a file, so that the player, if they start a new game (by closing the game and opening it again) can have those choices set the same way they left it.
To be more specific, I have coded so the player can choose between default music, mp3 music or Audio CD (with track selection).

Like the ags config file, you have a "variable" name with a content that can be altered by setup, or by hand with notepad (if one knows what write in there). So that's basically what I want.
It can either be a line that just says "CD Intro = 1" or even just 1st line is "1", 2nd line is "4" etc.

I was going to use the File.Open, but can't figure out how to read the info I need from it.
From a previous post I got "write five eFileWrite, and then read five eFileRead to get the info from the 5th..." but that's rather inefficient, as it seems I would need to put a bunch of ifs, just to find the data am looking for. And since selection of tracks is not linear I have no way to know which data will be written first in file... (wtf)

Is it just me that is over complicating something simple????
I had thought that I could just check for the variable and then read the "int" or at least say something like "Write.To.File(3)" and then "Read.From.File(3)" where file could be the line number (or how ever AGS saves the data).

Is there a simple way to do this? Is there a command I have yet to find that can do this?
There are those who believe that life here began out there...

Scavenger

You might be wanting IniFile2 for that, that allows for reading and writing text files like you want.

Cassiebsg

There are those who believe that life here began out there...

SMF spam blocked by CleanTalk