if problem

Non-platform specific questions.

if problem

Postby regine » Sat Mar 18, 2006 5:02 pm

I have a problem with an if-code.

Im use:

if(player.x = 72);
{
ChangePath("Event Actor", "noName", BOTH_AXIS);
}

But if i starting the game so the actor player will be go to place x 72.

Can you help me?
My project: Packs Adventure
Now finished: Packs Adventure Demo:http://game-editor.com/forum/viewtopic.php?f=4&t=3491
Demo features:
Level 1-3
Leveleditor
Full edition features:
50 Levels
Big Leveleditor
Bonus features
Fighting mode
...and more
regine
 
Posts: 109
Joined: Mon Aug 15, 2005 7:19 pm
Location: Germany
Score: 1 Give a positive score

Postby twobob » Sat Mar 18, 2006 7:54 pm

Use = to assign a value to a variable
Use == to compare values
In your case use the following:
if(player.x == 72);
{
ChangePath("Event Actor", "noName", BOTH_AXIS);
}
twobob
 
Posts: 33
Joined: Sat Sep 10, 2005 10:29 am
Location: England
Score: 2 Give a positive score

Postby Fuzzy » Sun Mar 19, 2006 12:15 am

= means make equal or assign. == means compare.

Its one of the most annoying things in programming, because even the masters mess up and do it, and its so innoculous that its hard to find.

The reason you can assign a value to a variable in C, inside an if statement, is because the creators of the language are sadists. Of course, if you ask me, I'll tell you its so you can baffle my mortal enemy, the if statement. Unfortunately, he gets you right back.

In reality(who lives there?) very odd and rare moments might require you to set values inside an if statement.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby regine » Sun Mar 19, 2006 10:12 am

I have maked with the strategy from twobob.

But:

Now, the Actor with the Script change the path if the the actor is on place x 72 or any other place.
My project: Packs Adventure
Now finished: Packs Adventure Demo:http://game-editor.com/forum/viewtopic.php?f=4&t=3491
Demo features:
Level 1-3
Leveleditor
Full edition features:
50 Levels
Big Leveleditor
Bonus features
Fighting mode
...and more
regine
 
Posts: 109
Joined: Mon Aug 15, 2005 7:19 pm
Location: Germany
Score: 1 Give a positive score

Postby regine » Sat Mar 25, 2006 10:26 am

Can anyone help me?
My project: Packs Adventure
Now finished: Packs Adventure Demo:http://game-editor.com/forum/viewtopic.php?f=4&t=3491
Demo features:
Level 1-3
Leveleditor
Full edition features:
50 Levels
Big Leveleditor
Bonus features
Fighting mode
...and more
regine
 
Posts: 109
Joined: Mon Aug 15, 2005 7:19 pm
Location: Germany
Score: 1 Give a positive score

Postby Fuzzy » Sat Mar 25, 2006 2:32 pm

Could you reword your new problem? It is a little unclear.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby regine » Sat Mar 25, 2006 4:06 pm

Now, the Actor have the script changes the path if the actor player is on place x 72 or not.

Better?
My project: Packs Adventure
Now finished: Packs Adventure Demo:http://game-editor.com/forum/viewtopic.php?f=4&t=3491
Demo features:
Level 1-3
Leveleditor
Full edition features:
50 Levels
Big Leveleditor
Bonus features
Fighting mode
...and more
regine
 
Posts: 109
Joined: Mon Aug 15, 2005 7:19 pm
Location: Germany
Score: 1 Give a positive score

Postby Fuzzy » Sun Mar 26, 2006 1:48 am

First of all, you should not use ; after the if statement. I just tested it, and it works either way, but thats not proper usage, and may cause bugs.

Can you post the section of code that is giving your problems? Show us a few lines before the if too, if possible, as well as several lines after if. Thanks, I hope I can help you.
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby regine » Sun Mar 26, 2006 9:07 am

Code:

if(player.x == 72);
{
ChangePath("Event Actor", "noName", BOTH_AXIS);
}


I need, if the player is on place x 72 the event actor changes the path. But he do changes the path if the player on place x 72 or on any other place.

What is false at the script?


Edit: Now, i have tested with no ; and now the event actor dont changes the path if the player is on place x 72 or not.
My project: Packs Adventure
Now finished: Packs Adventure Demo:http://game-editor.com/forum/viewtopic.php?f=4&t=3491
Demo features:
Level 1-3
Leveleditor
Full edition features:
50 Levels
Big Leveleditor
Bonus features
Fighting mode
...and more
regine
 
Posts: 109
Joined: Mon Aug 15, 2005 7:19 pm
Location: Germany
Score: 1 Give a positive score

Postby Fuzzy » Sun Mar 26, 2006 4:29 pm

Ok. this is tricky, and i must say, you are very patient. To learn to program in another language must be very hard! I am pleased that you try so hard.

I am writing this for my own sake too, because it is a very odd problem, and I want to understand it too. I hope it helps you as well.

When you put a ; at the end of the if, you are saying to GE that IF is finished. the {} brackets are a way to group commmands together, and they tie those commands to the IF.

Since you used ; GE goes ahead and does what comes next, and basically ignores what happened in the IF. It does the next lines all the time.

So when you take the ; away, it seems to be more broken, but its not. Its getting closer to being fixed!

Because we know the If line is fixed, we have to guess two things. perhaps player is not really at 72, or perhaps there is a problem with changepath.

First we will test to see if we get to 72 for sure.

Make a testing actor, and make it a text actor. Make the text say "NOT 72!" to start.

then we change your code a little bit!

if(player.x == 72) // no ;!
{
// stop this action for now. ChangePath("Event Actor", "noName", BOTH_AXIS);
Testingactor.textNumber = 72;
}

Try that. If it works, then we know the problem is somewhere in the ChangePath("Event Actor", "noName", BOTH_AXIS);

If it works, you will see right away! This trick works in all sorts of places for testing problems.

I'll check back as soon as I can! I want to get you past this. If anyone else sees, and wants to help before I do, go ahead! Lets get regine past this!

You can put the ; back to see what it does to the code. // means comment, and causes GE to not use that line, if you did not know. Its great for leaving notes!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby regine » Wed Mar 29, 2006 3:04 pm

Now, i have found the problem with your help.

Thanks!
My project: Packs Adventure
Now finished: Packs Adventure Demo:http://game-editor.com/forum/viewtopic.php?f=4&t=3491
Demo features:
Level 1-3
Leveleditor
Full edition features:
50 Levels
Big Leveleditor
Bonus features
Fighting mode
...and more
regine
 
Posts: 109
Joined: Mon Aug 15, 2005 7:19 pm
Location: Germany
Score: 1 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest