Some Stuff I've been Wondering about Save Games

Started by Kurdt, Fri 25/08/2006 16:12:15

Previous topic - Next topic

Kurdt

I've got a post over in the Beginner Forum about creating a custom Save/Load GUI and I got a pretty good amount of help over there. CMK recently posted a tutorial in the AGS Wiki about it and that solved basically all anomalies. However, when overwriting a save game it only checks against the SelectedIndex save to see if they're the same name. If the save you want to overwrite isn't selected, it won't be overwritten and there will be two saves with the same name. Since this is ridiculously confusing and annoying, I'm trying to get this to go away.

This led me to thinking about the nature of save games. How exactly do they work? Rather, what is their nature? How do they save their name? How do they get called up? I was thinking if I better understood the fundamental nature of a save game that I could come up with my code better. I asked it in the previously mentioned thread, but it's been some time now and I was just thinking that maybe someone who frequented this forum as opposed to the n00b one might have an answer, or at least a theory.
"The reason why so few good books are written is that so few people who can write know anything."

monkey0506

#1
Well, IMO, you should be able to have as many save games as you want with the same name. To me it would be very annoying if I tried to save slot 2 as "John" when slot 1 was already saved to that name, and instead of saving it to slot 2 it overwrote slot 1. But that's just my opinion.

Anyway, if you really wanted to, you could do something like this:

Code: ags
// String SaveName - replace this with the save name String
// ListBox lstSaves - replace this with the script o-name of your ListBox
int i = 0;
int save_index = lstSaves.SelectedIndex;
while (i < lstSaves.ItemCount) { // compare each save game
  if (lstSaves.Items[i] == SaveName) { // if save game with name exists,
    save_index = i; // change the save index
    i = lstSaves.ItemCount; // and break the loop
    }
  i++;
  }
SaveGameSlot(save_index, SaveName); // save the game with the current index (selected index if save doesn't exist, existing index otherwise)

Kurdt

I think it just depends on what you want your game to be like. I'm striving for that classic Sierra GUI and this was how I always figured they'd done it. If I was to do it in a different style for one reason or another, I might choose to have multiple saves with the same name. However, at present that is not the way I roll.

I'm personally quite glad someone finally made a tutorial for this. For something so widely desired as a custom Save/Load GUI, it seems there's absolutely nowhere a n00b can learn how to do this. I was planning on writing a tutorial of my own when I had it down, and now I don't have to because there's a great one now.
"The reason why so few good books are written is that so few people who can write know anything."

monkey0506

Okay. I guess that makes more sense then.

However, what tutorial are you referring to? There are some out and about on the internet, but a lot of them use old-style code (2.62- code; non-OO code).

[EDIT:]

Oh...also...did my code work for you?

Kurdt

Well, since CMK updated his tutorial on the Wiki, I basically copied and pasted his code in there and got it working. I mean, I looked at it and made sure I understood exactly what the code was calling for, but that's the code I used. I didn't use yours because I'd already had CMK's by the time I saw it. I mean, I'll plug it in for a lark and see if it works if you'd like. I don't see any reason why not to if I've got time to kill and feel like nerding out on programming code. *shrug*
"The reason why so few good books are written is that so few people who can write know anything."

monkey0506

Okay...you don't have to worry about testing my code as it's essentially the same as the tutorial code...only...I forgot about turning off the GUI before saving...hahah...

SMF spam blocked by CleanTalk