
-----------------------------------
commandos
Thu May 01, 2008 9:50 pm

read from file question
-----------------------------------
I'm trying to make a RPG game and i want the user to be able to save the game and open it when they feel like it. So i have all the stats of the character saved on a save file. the layout of the save file is exactly like this

Level
1
Experience
25
Health
85
and so on...

When the user decides to open a saved game, I want the program to read every other line (the values) and put them as variables in the code. Any idea of how i can get the program to just read the values and take them as an array of integers?

-----------------------------------
TheFerret
Thu May 01, 2008 10:07 pm

RE:read from file question
-----------------------------------
Save just the numbers and just ignore the words... so it would be like:

1
25
85
and so on...

-----------------------------------
commandos
Thu May 01, 2008 10:18 pm

RE:read from file question
-----------------------------------
I was thinking of doing that but then it would make it harder for me to follow the text file since I'll probably have to play around with the numbers a bit. Is there any way to get the program to read every other line?

-----------------------------------
commandos
Thu May 01, 2008 10:34 pm

RE:read from file question
-----------------------------------
Nevermind i found a solution... may not bed the best but it works and thats good enough for me right now lol


open : stream_in, "stats-save.dat", get
for i : 1 .. 14
    get : stream_in, stats (i)
end for
for i : 1 .. 14
    if i mod 2 = 0 then
        a := a + 1
        statsvalue (a) := strint (stats (i))
    end if
end for


-----------------------------------
Mackie
Thu May 01, 2008 10:59 pm

RE:read from file question
-----------------------------------
Try this instead:

for i : 1 .. 14 by 2
     % All that other stuff.
end for

