Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: ScottDoom on Thu 01/07/2004 09:42:42

Title: Global Ints with Character Interaction Scripts
Post by: ScottDoom on Thu 01/07/2004 09:42:42
Since I'm still a newbie at scritping I'm just posting this in the beginners area, but I guess it could go in the advanced...

Anyways, I had a hotspot on my background with an interaction script like this:

Ã,  Ã,  if (rock == 0) {
Ã,  Ã,  AddInventory(1);
Ã,  }
Ã,  if (rock == 0) {
Ã,  rock += 1;
Ã,  }
Ã,  if (rock == 1) {
Ã,  Ã,  Display("MESSAGE ONE");Ã, 
Ã,  }
Ã,  if (rock == 2) {
Ã,  Ã,  Display("MESSAGE TWO");
Ã,  }
Ã,  if (rock < 2) {
Ã,  Ã,  rock += 1;
Ã,  }Ã, 

It worked out pretty good. But now I replaced the hotspot with a character, and I want this same script on the character. For that, I can no longer put int rock; at the top of the room script, but I need to put it in the global script somewhere...

I'm not sure where or how to insert the int into the game (without having it reset if the game is loaded).
Title: Re: Global Ints with Character Interaction Scripts
Post by: Ishmael on Thu 01/07/2004 10:55:39
I think putting

int rock;

in start of global script and

import int rock;

into the script header should do it, then you could use it for the character.
Title: Re: Global Ints with Character Interaction Scripts
Post by: ScottDoom on Thu 01/07/2004 11:35:00
That works. Thanks a lot. I wasn't sure on how to use the import thing... Isn't there also an export function? What's that used for?
Title: Re: Global Ints with Character Interaction Scripts
Post by: Ishmael on Thu 01/07/2004 11:49:21
eeer... yes, you need to

export rock;

in the end of the global script if you have done something with it in the global script, and want to use it in room scripts.
Title: Re: Global Ints with Character Interaction Scripts
Post by: ScottDoom on Thu 01/07/2004 11:50:08
Well, it worked without the export line... But I'll add it.
Title: Re: Global Ints with Character Interaction Scripts
Post by: TerranRich on Thu 01/07/2004 16:16:38
This is all in the BFAQ already. Did you read it?