Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: on Fri 26/12/2003 15:44:32

Title: Telephone script
Post by: on Fri 26/12/2003 15:44:32
Hi there!

I would like to implement a "telephone" into my game which can be used to call NPCs. I used the inputbox command to let the player enter a number. I also tried to make an if/else statement to check if the player has entered an existing number and let the game react accordingly. However, the latter does not seem to work.

Here is the code I wrote:

string buffer;
InputBox("Enter number", number);
if (number == "1234") Display("Hello.");

Maybe anyone can help me? Many thanks in advance.
Title: Re:Telephone script
Post by: Barcik on Fri 26/12/2003 15:56:11
The string you declared is named 'buffer', and yet the string where you try to enter the number is called 'number'.
It should be:

string number;
InputBox("Enter number", number);
if (number == "1234") Display("Hello.");

Title: Re:Telephone script
Post by: on Fri 26/12/2003 15:59:53
You're right. That was a typo ;)... I previously used a string called "buffer". However, the script still does not work.
Title: Re:Telephone script
Post by: TerranRich on Fri 26/12/2003 16:10:20
That's because you can't compare strings with the == bit. You have to use StrComp() or something like that. :)
Title: Re:Telephone script
Post by: on Fri 26/12/2003 16:42:41
Thank you VERY much - StrComp did work...