Why doesnt this work??? :?

Game Editor comments and discussion.

Why doesnt this work??? :?

Postby GuitarManGuitar » Thu Jan 31, 2008 9:34 pm

this works fine...

COLLISION ANY SIDE OF ANY ACTOR
///WIZARD HAT PICK UP
{collide.itemtype = strcmp(collide.name, wizhat.name);

if(collide.itemtype==0)
ChangeParent("Collide Actor", "menu"),
collide.x=-30+(menuquan*2),
collide.y=-48,
menuquan=menuquan+10, wizhat.itemown=1;}


but this doesn't

MOUSE BUTTON DOWN (LEFT)
if(hatequip==1)
ChangeParent("Event Actor", "(none)"),
x=999999999,
itemown=0, hatequip=0,
y=Man.y,wizhat.x=Man.x;

if(hatequip==0)
if(itemown==1)
ChangeParent("wizhat", "Man"),
wizhat.x=0,
wizhat.y=-11,
menuquan=menuquan-10,hatequip=1;


the second script is supossed to move the hat from your inventory (menu) to your head (Man).
Can you tell me y it doesn't work and how to fix it?
GuitarManGuitar
 
Posts: 31
Joined: Thu Oct 25, 2007 11:57 pm
Score: 0 Give a positive score

Re: Why doesnt this work??? :?

Postby Super Pieman » Thu Jan 31, 2008 11:23 pm

you have to put a "{" after using an if statement.
the code should look like this
Code: Select all
MOUSE BUTTON DOWN (LEFT)
if(hatequip==1)
{
ChangeParent("Event Actor", "(none)"),
x=999999999,
itemown=0, hatequip=0,
y=Man.y,wizhat.x=Man.x;
}

if(hatequip==0)
{
if(itemown==1)
{
ChangeParent("wizhat", "Man"),
wizhat.x=0,
wizhat.y=-11,
menuquan=menuquan-10,hatequip=1;
}
}


for the second peice of code you have to if options so you have to end with 2 "}"s

EDIT: Nvmd I just realized what you were saying. Im not sure how to fix your problem
Current Projects:
*Lonely (2%)
**LinkSys (1%)

*To be made in GE, then ported to DS.
**To be made for the DS.
User avatar
Super Pieman
 
Posts: 57
Joined: Sat Nov 03, 2007 3:27 pm
Location: Manotick (Ontario, Canada)
Score: 2 Give a positive score

Re: Why doesnt this work??? :?

Postby GuitarManGuitar » Fri Feb 01, 2008 12:10 am

Super Pieman wrote:you have to put a "{" after using an if statement.
the code should look like this
Code: Select all
MOUSE BUTTON DOWN (LEFT)
if(hatequip==1)
{
ChangeParent("Event Actor", "(none)"),
x=999999999,
itemown=0, hatequip=0,
y=Man.y,wizhat.x=Man.x;
}

if(hatequip==0)
{
if(itemown==1)
{
ChangeParent("wizhat", "Man"),
wizhat.x=0,
wizhat.y=-11,
menuquan=menuquan-10,hatequip=1;
}
}


for the second peice of code you have to if options so you have to end with 2 "}"s

EDIT: Nvmd I just realized what you were saying. Im not sure how to fix your problem


Can anyone help me???
GuitarManGuitar
 
Posts: 31
Joined: Thu Oct 25, 2007 11:57 pm
Score: 0 Give a positive score

Re: Why doesnt this work??? :?

Postby pyrometal » Fri Feb 01, 2008 1:13 am

Are ending your instructions with (,) or (;) ?? A command must always be followed by a semicolon and not a comma. I'm noticing the way you wrote your lines in your text were ended in commas so I just want to make sure.
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Why doesnt this work??? :?

Postby GuitarManGuitar » Fri Feb 01, 2008 1:25 am

thats not it, when u try to wear the hat by clicking on it, it goes back to the menu and then disapears!
GuitarManGuitar
 
Posts: 31
Joined: Thu Oct 25, 2007 11:57 pm
Score: 0 Give a positive score

Re: Why doesnt this work??? :?

Postby pyrometal » Fri Feb 01, 2008 1:44 am

Code: Select all
MOUSE BUTTON DOWN (LEFT)
if(hatequip)
{
    ChangeParent("Event Actor", "(none)");
    hatequip=0;
    y=Man.y;
    x=Man.x;
}

else
{
    if(itemown)
    {
        x=Man.x;
        y=Man.y-11;
        ChangeParent("wizhat", "Man");
        menuquan=menuquan-10;
        hatequip=1;
    }
}
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Why doesnt this work??? :?

Postby GuitarManGuitar » Fri Feb 01, 2008 11:11 pm

didn't work.
GuitarManGuitar
 
Posts: 31
Joined: Thu Oct 25, 2007 11:57 pm
Score: 0 Give a positive score

Re: Why doesnt this work??? :?

Postby pyrometal » Sat Feb 02, 2008 2:23 am

Sorry, then I don't know the reason for your problem...
SPRITE WARRIOR:
Free, open-source & crossplatform pixel art editor (currently under construction).
User avatar
pyrometal
 
Posts: 706
Joined: Wed Nov 28, 2007 4:07 am
Location: Kingston, ON, Canada
Score: 86 Give a positive score

Re: Why doesnt this work??? :?

Postby Thanx » Sun Feb 03, 2008 11:01 am

I think if this doesn't work, then the problem will not be in this part of the code.

Code: Select all
if(hatequip==1)
{
    ChangeParent("Event Actor", "(none)"),
    x=999999999;
    itemown=0;
    hatequip=0;
    y=Man.y;
    wizhat.x=Man.x;
}

if(hatequip==0)
{
    if(itemown==1)
    {
        ChangeParent("wizhat", "Man"),
        wizhat.x=0;
        wizhat.y=-11;
        menuquan=menuquan-10;
        hatequip=1;
    }
}

I had if statement problems lately, and if that doesn't work, then let me give you a hint: You might have statements put in the wrong if statements, so they're done the wrong time, if at all, or you might have an if statement you don't need at all.
http://www.youtube.com/watch?v=XyXexDJBv58
http://www.youtube.com/watch?v=Be4__gww1xQ
These are me and playing the piano (second one with a friend/fellow student)
Hope you watch and enjoy!
User avatar
Thanx
 
Posts: 314
Joined: Sat Jan 26, 2008 10:07 pm
Location: Home sweet home! :)
Score: 24 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron