COMO GRABAR PARTIDA EN AGS

Started by FiufiuDuende, Mon 06/03/2023 19:30:05

Previous topic - Next topic

FiufiuDuende

Hola, estoy intentado que el programa pueda grabar partidas con una GUI. He hecho el menú, pero resulta que no me graba el archivo. No sé que estoy haciendo mal, alguien puede ayudarme?

He puesto todo esto y no me funciona, agradecería mucho una respuesta, soy principiante.

Gracias



function btnConfirmSave_OnClick(GUIControl *control, MouseButton button)
{
    int totalSaves = lstSaveGames.ItemCount; //number of saves on list
    String saveName = txtSaveName.Text; //holds value of txtSaveName
   
    //Check for a save name. If none, tell them.  Else, go on.
    if(saveName == "")
    {
      Display("Please enter a name for your saved game.");
      return;
    }
   
    //If there is no saved games yet, just save it.
    if(lstSaveGames.SelectedIndex == -1)
    {
      gSavegame.Visible = false;
      SaveGameSlot(totalSaves+1, saveName);
    }
    else
    {
      int checkSave = 0; //runs through the list and checks for double entries
      while(checkSave != totalSaves)
      {
        if(saveName == lstSaveGames.Items[checkSave]) // one matches, so overwrite it.
        {
          //if so, overwrite the selected save game
          gSavegame.Visible = false;
          SaveGameSlot(savegameindex[checkSave], saveName);
          return;
        }
        checkSave++;
      }
      //if we've made it here, then there is no match; just save to a new slot.
      if(totalSaves < 20)
      {
        gSavegame.Visible = false;
        SaveGameSlot(totalSaves+1, saveName);
      }
      else
      {
        Display("The maximum number of saved games has been reached; overwrite or delete some old ones.");
      }
    }
}

Nahuel

@FiufiuDuende primero que nada te van a cagar a pedos, porque el foro tiene reglas rules

QuotePost in English. This is one of Pumaman's (Chris Jones) rules, and should be followed here as well. 99% of the AGSers can speak English, so this is the main language of the forums. This is covered in the registration quiz as well.
QuoteDon't YELL! This goes for titles AND messages. Please refrain from using all CAPS and unnecessary colouring or formatting. Yelling will not make us answer your question any faster or any better.



Translation: First of all, they are not going to be happy with your post, because the forum has rules (see link)



Now, second of all, you can create a 2nd game from a template and check the code, there are several templates with savegames that can help you instead of starting from scratch, you can create a game from a basic template such as BASS that recovers a simple interface with 2 click options, and it's very simple to use.

Thirdly, use the code snippet option when posting your code. It will look much better, see below:

Code: ags
function btnConfirmSave_OnClick(GUIControl *control, MouseButton button)
{
    int totalSaves = lstSaveGames.ItemCount; //number of saves on list
    String saveName = txtSaveName.Text; //holds value of txtSaveName
   
    //Check for a save name. If none, tell them.  Else, go on.
    if(saveName == "")
    {
      Display("Please enter a name for your saved game.");
      return;
    }
   
    //If there is no saved games yet, just save it.
    if(lstSaveGames.SelectedIndex == -1)
    {
      gSavegame.Visible = false;
      SaveGameSlot(totalSaves+1, saveName);
    }
    else
    {
      int checkSave = 0; //runs through the list and checks for double entries
      while(checkSave != totalSaves)
      {
        if(saveName == lstSaveGames.Items[checkSave]) // one matches, so overwrite it.
        {
          //if so, overwrite the selected save game
          gSavegame.Visible = false;
          SaveGameSlot(savegameindex[checkSave], saveName);
          return;
        }
        checkSave++;
      }
      //if we've made it here, then there is no match; just save to a new slot.
      if(totalSaves < 20)
      {
        gSavegame.Visible = false;
        SaveGameSlot(totalSaves+1, saveName);
      }
      else
      {
        Display("The maximum number of saved games has been reached; overwrite or delete some old ones.");
      }
    }
}
Life isn't a game. Let's develop a life-like-game.

Khris

You need to actually link your button to the function: open the button's events pane (thunderbolt icon) and paste btnConfirmSave_OnClick into the 2nd column.

(Debe vincular su botón a la función: abra el panel de eventos del botón (icono de rayo) y pegue btnConfirmSave_OnClick en la segunda columna.)

SMF spam blocked by CleanTalk