Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: AndersM on Fri 18/07/2003 17:58:27

Title: Variable scripting
Post by: AndersM on Fri 18/07/2003 17:58:27
What's wrong in my script? It's supposed to change 'output' everytime you click on the hotspot,
but I only manage to display the first one, or all at the same time. Help me!!



 // script for hotspot10: Interact hotspot

 int locker;  

 if (locker == 0) {
   Display("That's not your locker.");
 
 }
 if (locker == 1) {
   Display("Don't you know where your locker is?");

 }
 if (locker == 2) {
   Display("Don't mess around with other peoples lockers");

 }
 if (locker == 3) {
   Display("You actually don't know where it is, do ya?");

 }
 if (locker < 3) {
 locker += 3;
 }  

Title: Re:Variable scripting
Post by: scotch on Fri 18/07/2003 18:55:26
The locker int should be initialised at the top of the room script, not in the interact function. so put
int locker=0; at the top of the room script.

Also I made some changes to your interact script:

// script for hotspot10: Interact hotspot
 

if (locker == 0) {
Display("That's not your locker.");
}else
if (locker == 1) {
Display("Don't you know where your locker is?");
}else
if (locker == 2) {
Display("Don't mess around with other peoples lockers");
}else
if (locker >= 3) {
Display("You actually don't know where it is, do ya?");

}
if (locker < 3) {
locker++;
}

so that it adds one each time, instead of 3.
Title: Re:Variable scripting
Post by: AndersM on Fri 18/07/2003 20:15:06
Thanx. It works now, but can I ad something to make it cycle,
so that when it's given all the answers it goes back to the begining?
Title: Re:Variable scripting
Post by: scotch on Fri 18/07/2003 21:03:45
just change the end bit so it says:

blah blah..
....
if (locker < 3) {
locker++;
}  else locker=0;

that should do it
Title: Re:Variable scripting
Post by: AndersM on Fri 18/07/2003 21:18:00
Yes, that did it. Thanx.
Title: Re:Variable scripting
Post by: on Mon 21/07/2003 17:12:21
I need to have it so my variable will equal 2 so nobody can get the item more than once.
Title: Never mind.
Post by: on Mon 21/07/2003 17:15:06
I got it to work.  Here's the code for it (La is the variable I defined.)
La = 2;
Basicly, you can talk if La = 0, but it doesn't once you get the bomb.