Question about RunAGSGame

Started by Mantra of Doom, Wed 02/09/2009 18:36:15

Previous topic - Next topic

Mantra of Doom

In the manual for RunAGSGame, it has the code of

Code: ags
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.
"Imitation is the sincerest form of imitation."

Ishmael

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.
I used to make games but then I took an IRC in the knee.

<Calin> Ishmael looks awesome all the time
\( Ö)/ ¬(Ö ) | Ja minähän en keskellä kirkasta päivää lähden minnekään juoksentelemaan ilman housuja.

Mantra of Doom

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.
"Imitation is the sincerest form of imitation."

Gilbert

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:
Code: ags

    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:
Code: ags

    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.

Dualnames

Pretty much the same way I've used on SecureFile, important when you place the two games, they share the same winsetup file.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

SMF spam blocked by CleanTalk