Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dualnames on Mon 01/04/2019 19:32:44

Title: ReadStringBack weird behavior (solved, feel free to mock me in a reply)
Post by: Dualnames on Mon 01/04/2019 19:32:44
File*output = File.Open("$SAVEGAMEDIR$/den.dat",eFileWrite);
  int i=25100;
  while (i < 30000)
  {
    if (ReadVariable(i)==null) output.WriteString("");
    else
    {
      Display("Writing %s",ReadVariable(i));
      output.WriteString(ReadVariable(i));//WriteRawLine(i);
    }
    i++;
  }
  output.Close();


This seems to write the values properly. My ReadVariable goes to an array that stores the text of dialogs
So, when the writing code executes the values in that display function are proper and perfect.


This is the reading part


File*output = File.Open("$SAVEGAMEDIR$/den.dat",eFileRead);
 
  int i=25100;
  if (output!= null)
  {
    while (i<30000)
    {
      Display(output.ReadStringBack());
      SaveVariable(output.ReadStringBack(), i);
      i++;
    }
    output.Close();
  }


This should return "Dialog 1 00100" then "Dialog 2 010010"  and so on whereas the 0 and 1 are the state of the options.
What it does is it skips intermissioned Dialogs like instead of going 1,2,3,4,5,6,7,8,9 it goes 1,3,5,7,9, I have no clue as to why.

Even when I replace the readvariables and just write the i counters, it writes 25100,25101,25102 etc till 25109 and read 25100,25102,25104
HELP ME
Title: Re: ReadStringBack weird behavior
Post by: Crimson Wizard on Mon 01/04/2019 19:53:47
Quote from: Dualnames on Mon 01/04/2019 19:32:44
This should return "Dialog 1 00100" then "Dialog 2 010010"  and so on whereas the 0 and 1 are the state of the options.
What it does is it skips intermissioned Dialogs like instead of going 1,2,3,4,5,6,7,8,9 it goes 1,3,5,7,9, I have no clue as to why.


You are calling it two times in a row?
Code (ags) Select

Display(output.ReadStringBack());
SaveVariable(output.ReadStringBack(), i);
Title: Re: ReadStringBack weird behavior
Post by: Dualnames on Mon 01/04/2019 19:58:14
Oh, wait let me see if thatis the case!
Title: Re: ReadStringBack weird behavior
Post by: Dualnames on Mon 01/04/2019 19:59:09
ROFLMAO WHAT IS WRONG WITH ME, yeah that was it!