Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Mantra of Doom on Wed 02/09/2009 18:36:15

Title: Question about RunAGSGame
Post by: Mantra of Doom on Wed 02/09/2009 18:36:15
In the manual for RunAGSGame, it has the code of

RunAGSGame ("MyGame.exe", 0, 51);

Where the last number is the int data where I can pass an in to the new game.

What confuses me is what exactly does the int data come from? Do I make an int in the new game and pass that 51 into it at the start of the game? Where does 51 come from and where do I put it once I have it?

I think I'm confusing myself just a little. I'm not to the part where I have to code this, I'm still in the planning phase and trying to think ahead a bit as to how I'm going to do certain parts of the game.
Title: Re: Question about RunAGSGame
Post by: Ishmael on Wed 02/09/2009 18:55:08
From the manual under the RunAGSGame section:

QuoteDATA allows you to pass an integer through to the next game. The value you pass here will be accessible to the loaded game by it reading the game.previous_game_data variable.

So whatever you pass there with the command will be in the next game, readable off that variable.
Title: Re: Question about RunAGSGame
Post by: Mantra of Doom on Thu 03/09/2009 00:31:56
So, is that variable a variable in the new game?

Could I pass any sort of variable through or just an int? I guess I'm not really sure what gets passed into the new game?

Where is that variable defined? In the previous game or in the new game?

I apologize for being dumb.
Title: Re: Question about RunAGSGame
Post by: Gilbert on Thu 03/09/2009 01:52:17
It's an int that is defined in the called game.

Two possible uses for this are:
1. The called game can behave differently according to what values you set it to, like:

    if (game.previous_game_data==0){
          //do this
    } else if (game.previous_game_data==1){
          //do that
   }

2. As a small security measure to prevent people to launch the (sub)game (be it a mini game or a "Chapter 2" of a game that you don't want people to access before finishing "Chapter 1", etc.) directly, so it can only run when the correct 'key' is passed to it, like:

    if (game.previous_game_data==34788){
        //blah bla bla
    } else {
        AbortGame("You cannot run this directly! Play the real game!");
    }


If you don't need this, you can simply pass any numbers to it and ignore it.
Title: Re: Question about RunAGSGame
Post by: Dualnames on Thu 03/09/2009 10:43:38
Pretty much the same way I've used on SecureFile, important when you place the two games, they share the same winsetup file.