Confirming text problem

Non-platform specific questions.

Confirming text problem

Postby PWNED » Wed Apr 13, 2011 4:44 am

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!
PWNED
 
Posts: 16
Joined: Wed Jul 21, 2010 10:17 pm
Score: 0 Give a positive score

Re: Confirming text problem

Postby skydereign » Wed Apr 13, 2011 5:11 am

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;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Confirming text problem

Postby akr » Wed Apr 13, 2011 1:17 pm

One bracket was missing. Added it.

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

If u are interrested in new features of apple or android ge engines check the engine support website game-editor.net regulary.
akr
 
Posts: 453
Joined: Thu Feb 25, 2010 7:56 pm
Location: Germany, Ulm
Score: 40 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest