Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Davimee on Tue 14/06/2005 22:27:10

Title: conditional message
Post by: Davimee on Tue 14/06/2005 22:27:10
This probably has a simple solution, but as of yet I'm not finding it.  I didn't see this in the manual, but if it's there, please let me know and I will go back and look.

Is there a way to display a message with the condition of a player NOT visiting a certain room first?  I have a room with 3 exits/entrances.  He enters room 2 from room one.  In room 2 he has the option of going to room 1, 3, or 4.  But I don't want him to be able to go to room 4 until he has first visited room 3.  If he clicks on the door (object) to room 4, nothing happens.  If he first goes to room three, then back to room 2 and then clicks on the door to room 4, the door animates, and he goes to room 4.  All of that is working just fine.  My question is, is there a way to display a message if my player character has not been in room 3?  I know you can set a condition to display the message if a player has been in a certain room, but is there a way to display the message if he has not been in a certain room, then once the player goes to that room the message will no longer come up?  I want to let the player know why the door is not opening, that first he needs to visit the other room.

I apologize if this isn't making much sense, I think I've been staring at the computer too long. 
Title: Re: conditional message
Post by: strazer on Wed 15/06/2005 14:17:01
QuoteMy question is, is there a way to display a message if my player character has not been in room 3?

That's quite easy using scripting:


  if (HasPlayerBeenInRoom(3) == 0) { // if player has NOT been in room 3 yet
    Display("No!");
  }
  else { // if player has been in room 3
    NewRoom(4);
  }
Title: Re: conditional message
Post by: Davimee on Wed 15/06/2005 18:48:12
Ok, I tried using the code you have there, but when I tried to save my game I got an error that states:

There was an error compiling your script.Ã,  The problem was in 'Main Script':
Error (line 72): Parsor Error: unexpected 'if'
Do you want to fix the script now?Ã,  (Your game has not been saved).

I made sure this is outside all other functions.Ã,  Oh, after looking at the rest of the global script I'm guessing I need to have a line before this script.Ã,  Do I need to define the function?Ã,  I've looked this up in the manual, but I don't understand what it's saying about scripting.Ã,  I apologize if these are dumb questions.Ã,  Before I tried using AGS I had never even heard of scripting.Ã,  Ã, :-[
Title: Re: conditional message
Post by: strazer on Wed 15/06/2005 18:58:56
QuoteI made sure this is outside all other functions.

Wrong. Script code has to be put in functions, otherwise AGS won't know when to execute it. What function depends on when you want the message to be displayed.

Does the player have to interact with a door object that leads to room 4? If so, to create the function for this event, go to Room Editor -> Objects -> Select the door object -> "Interaction..." -> Double-click "Interact object" -> "Run script" -> "Edit script..." -> Paste above script
Title: Re: conditional message
Post by: Davimee on Wed 15/06/2005 21:03:05
Ok, that worked perfectly!  Thank you for your help!
Title: Re: conditional message
Post by: strazer on Wed 15/06/2005 21:11:44
My pleasure. :)