Variable scripting

Started by AndersM, Fri 18/07/2003 17:58:27

Previous topic - Next topic

AndersM

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;
 }  


scotch

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.

AndersM

#2
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?

scotch

just change the end bit so it says:

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

that should do it

AndersM

Yes, that did it. Thanx.

Davidi

I need to have it so my variable will equal 2 so nobody can get the item more than once.

Davidi

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.

SMF spam blocked by CleanTalk