Hi!
I want to discuss ways to work with files with game settings. I have worked example from Lazarus.
For game world generation i made unit with two functions, who read *.txt file.
First function read file string by string and get text from they.
Second function get clear text from first function and use it for fill world array cells.
I use this basic Pascal functions:
...
AssignFile(f, 'comands.txt');
Reset(f);
while not EOF(f) do
...
And this example of map configuration from my file:
____________________LOCATION-1____________________
____________________Border____________________
Fill>
1 0 13 0 19
Bor
Fill>
1 1 12 1 18
Mea
____________________Zone-1____________________
Set>
1 1 3 1 5
> > > >
> > > >
> > > >
If program read “Fill>”, they go to the next string and look, what map cells they must edit. After then, function 1 extract cells modifier (Bor - border blocks of my map, Mea - Meadow ground in this example). This modifier uses by my second function to edit cells of map (they have special type). For example, they define what texture, name and access has this cell of map. In a future i want to add many cells parameters in this function.
Command “Set>” uses for filling map like 2D array.
Thus, the program reads all file line by line and builds a map.
I want to use this method for keep configuration and edit game map from text files.
How i can make it with CGE? Is “AssignFile” work here correct? Or i can choose some better way to use my configuration files here?