Odd TableSaving Behavoir

I’m trying to save the data of a few objects to a table, this includes their position as a vector and their current size so that it can be used when reopening the program. However when using the code below, instead of getting five lines with the wanted data, I get five lines with the 4th being empty. Any help is of course welcome.

void exit() {

for (int i = 0; i < 5; i++) {
Monster m = monsters.get(i);

if (i == 1) {

  YRow.setString("xpos", "[" + m.pos.x + "]");
  YRow.setString("ypos", "[" + m.pos.y + "]");
  YRow.setString("size", "[" + m.size + "]");
}

if (i == 2) {
  RRow.setString("xpos", "[" + m.pos.x + "]");
  RRow.setString("ypos", "[" + m.pos.y + "]");
  RRow.setString("size", "[" + m.size + "]");
}

if (i == 3) {

  BRow.setString("xpos", "[" + m.pos.x + "]");
  BRow.setString("ypos", "[" + m.pos.y + "]");
  BRow.setString("size", "[" + m.size + "]");
}

if (i == 4) {

  GRow.setString("xpos", "[" + m.pos.x + "]");
  GRow.setString("ypos", "[" + m.pos.y + "]");
  GRow.setString("size", "[" + m.size + "]");
}

if (i == 5) {

  PRow.setString("xpos", "[" + m.pos.x + "]");
  PRow.setString("ypos", "[" + m.pos.y + "]");
  PRow.setString("size", "[" + m.size + "]");
}

}

saveTable(Data, “data/Data.csv”);
}

1 Like

Hello,

you forgot

if (i == 0) {

as first entry

1 Like