Page 1 of 1

Confirming text problem

PostPosted: Wed Apr 13, 2011 4:44 am
by PWNED
Hey everyone!
Yeah I know, I'm stuck again :oops: sorry about that.
so here is the problem.
I want the actor the identify the text given by the player and when he/she presses enter if it matches the text in the code it changes the Var. accordingly.
here is my code:

Code: Select all
if (zone_num = 1 & Entry_Box.text = go to town);
{
    Str.textNumber=25;
}

and the error message:
Error line 1: Incompatible types: cannot convert from ' const int' to 'ARY[256]char'


Please Help!

Re: Confirming text problem

PostPosted: Wed Apr 13, 2011 5:11 am
by skydereign
There are many things wrong with that if statement. First, if you want to check if zone_num is equal to zero, you need == instead of =. The & needs to be && if you want and. Next, you compare strings with strcmp. strcmp takes two strings, and if they are the same returns a zero. Lastly, you do not add a semicolon after an if statement, it will prevent end the if statement, meaning Str.textNumber will always be set to 25. Here's the fixed code.
Code: Select all
if(zone_num == 1 && strcmp(Entry_Box.text, " go to town"==0)
{
    Str.textNumber=25;
}

Re: Confirming text problem

PostPosted: Wed Apr 13, 2011 1:17 pm
by akr
One bracket was missing. Added it.

Code: Select all
if(zone_num == 1 && strcmp(Entry_Box.text, " go to town")==0)
{
    Str.textNumber=25;
}