Telephone script

Started by JSE, Fri 26/12/2003 15:44:32

Previous topic - Next topic

JSE

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.

Barcik

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.");

Currently Working On: Monkey Island 1.5

JSE

#2
You're right. That was a typo ;)... I previously used a string called "buffer". However, the script still does not work.

TerranRich

That's because you can't compare strings with the == bit. You have to use StrComp() or something like that. :)
Status: Trying to come up with some ideas...

JSE

#4
Thank you VERY much - StrComp did work...

SMF spam blocked by CleanTalk