A problem with creating an actor using script.

Non-platform specific questions.

A problem with creating an actor using script.

Postby Garfield501 » Fri Oct 09, 2009 7:29 pm

Hello,
I have a problem with creating an actor with a script.

When my "game" starts up, it shows to pics. No problem here.
Then it goes to the "main menu" of the game.

Here it is supposed to check if variable "Save_game_excists" is equal to 0 or 1.
And if it's 1, it is supposed to create the actor "Load_Game".
Here it goes wrong.
It create's the actor "Load_Game" anyway.
Even when I put this code before the If-Then part.
Code: Select all
Save_game_excists = 0;


This is the complete code I am using.
Code: Select all
view.x = 160;
view.y = -120;
CreateActor("Main_menu_pointer_left", "icon", "(none)", "(none)", 0, 0, false);
CreateActor("Main_menu_pointer_right", "icon", "(none)", "(none)", 0, 0, false);
CreateActor("Quit", "icon", "(none)", "(none)", 0, 0, false);
Main_menu_pointer_left.x = New_game.x - 40;
Main_menu_pointer_left.y = New_game.y;
Main_menu_pointer_right.x = New_game.x + 90;
Main_menu_pointer_right.y = New_game.y;
Quit.y = New_game.y + 68;
Quit.x = New_game.x + 20;
if (Save_game_excists == 1);
{
    CreateActor("Load_Game", "icon", "(none)", "(none)", 0, 0, false);
    Load_Game.y = New_game.y + 34;
    Load_Game.x = New_game.x - 3;
}



How can I make it work my way.
I want to create actor "Load_Game" only, when "Save_game_excists'' is equal to 1.


Thanks in advance,
Mark
Garfield501
 
Posts: 25
Joined: Tue Sep 22, 2009 5:45 pm
Score: 0 Give a positive score

Re: A problem with creating an actor using script.

Postby skydereign » Fri Oct 09, 2009 7:51 pm

Okay, the problem is after your if statement, you put a semicolon. The ; will end the if statement. So what you are doing is checking if the variable equals 1 do nothing. Then it has the create. Here is what it should be.

Code: Select all
view.x = 160;
view.y = -120;
CreateActor("Main_menu_pointer_left", "icon", "(none)", "(none)", 0, 0, false);
CreateActor("Main_menu_pointer_right", "icon", "(none)", "(none)", 0, 0, false);
CreateActor("Quit", "icon", "(none)", "(none)", 0, 0, false);
Main_menu_pointer_left.x = New_game.x - 40;
Main_menu_pointer_left.y = New_game.y;
Main_menu_pointer_right.x = New_game.x + 90;
Main_menu_pointer_right.y = New_game.y;
Quit.y = New_game.y + 68;
Quit.x = New_game.x + 20;
if (Save_game_excists == 1)
{
    CreateActor("Load_Game", "icon", "(none)", "(none)", 0, 0, false);
    Load_Game.y = New_game.y + 34;
    Load_Game.x = New_game.x - 3;
}
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: A problem with creating an actor using script.

Postby Kalladdolf » Fri Oct 09, 2009 7:53 pm

Oh, you just beat me to it. One second too late.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: A problem with creating an actor using script.

Postby Garfield501 » Sat Oct 10, 2009 11:39 am

Okay, thank you.

I really must learn where to put a ; and where not.
Garfield501
 
Posts: 25
Joined: Tue Sep 22, 2009 5:45 pm
Score: 0 Give a positive score

Re: A problem with creating an actor using script.

Postby MrJolteon » Sat Oct 10, 2009 7:50 pm

in the first code, you wrote exist wrong. Read 7 words from the arrow<-- that's how you write it lol
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: A problem with creating an actor using script.

Postby Kalladdolf » Sat Oct 10, 2009 7:58 pm

That doesn't affect the code though and therefore doesn't have any relevance.
User avatar
Kalladdolf
 
Posts: 2427
Joined: Sat Sep 08, 2007 8:22 am
Location: Germany
Score: 120 Give a positive score

Re: A problem with creating an actor using script.

Postby MrJolteon » Sat Oct 10, 2009 7:59 pm

@kall I was just mentioning it.
Join us on Discord!
Game Editor 2
These are the best ways to reach me these days


Your local Community Janitor, always lurking in the shadows...
User avatar
MrJolteon
 
Posts: 2326
Joined: Sat Aug 09, 2008 3:25 pm
Location: Stranded under endless sky
Score: 105 Give a positive score

Re: A problem with creating an actor using script.

Postby Hblade » Mon Oct 12, 2009 2:21 pm

In your if statments, be sure to have 2 = signs, for example
Code: Select all
if (var1 == 0)
{
code here
}

With 1 equal sign, it acts as if It's setting the variable rather then reading it.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: A problem with creating an actor using script.

Postby Garfield501 » Mon Oct 12, 2009 6:23 pm

Yes, thank you all for the advice.
It's working fine now.
Garfield501
 
Posts: 25
Joined: Tue Sep 22, 2009 5:45 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron