Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: kafka on Mon 03/04/2006 21:27:04

Title: Topic script
Post by: kafka on Mon 03/04/2006 21:27:04
I have a topic and a int variable. I want that, when the game has shown a dialog, it increases the int variables value.
Title: Re: Topic script
Post by: spook1 on Mon 03/04/2006 21:41:16
You can call a function from a dialog by e.g.
run-script(1)

This will call script number 1.
In my example script-1 will make the player character walk to 282,185.
script number 2 will end the game.

You can add a many scripts as you like.


To implement this you must add a function in the Global script:


function dialog_request (int parameter) {

  if (parameter == 1) {
    cEGO.Walk(282, 185);
}

  if (parameter == 2){
Display("GAME OVER!");
QuitGame(0);
  }
 
}
Title: Re: Topic script
Post by: kafka on Mon 03/04/2006 21:50:59
Thanks! How can I put variables in display: display("You have " money "$ in your pocket!");?
Title: Re: Topic script
Post by: Khris on Mon 03/04/2006 21:52:34
int money=100;
Display("You have %d & in your pocket!", money);

Oh and RTFM.
Title: Re: Topic script
Post by: kafka on Mon 03/04/2006 22:28:00
Thanks.  ;D Hmm. I have a hotspot in my room and i put in the interaction menu look a run script. How can i change the value of that variable in that room?
Title: Re: Topic script
Post by: Radiant on Tue 04/04/2006 00:37:00
Quote from: kafka on Mon 03/04/2006 22:28:00
Thanks.  ;D Hmm. I have a hotspot in my room and i put in the interaction menu look a run script. How can i change the value of that variable in that room?

You either declare the variable at the top of your room script (and it will only work in that room) or you put it in your global script, like this:

//top of global script
int thingy;

//bottom of global script
export thingy;

//global header file
import int thingy;