PDA

View Full Version : One-way Block script



C-Dawg
10-26-2006, 05:48 PM
The FFC script for a one-way block seems really simple, so I gave it a whirl. Problem is, the compiler doesn't like the Link->DownPressed() function, or it's relatives. Tells me there is no such function. According to Jman's ZScript documentation, there is... am I missing something in the syntax?





// =====================================
// No_South: While on the tile that this
// FFC occupies, Link will not be able to
// move south.
// =====================================


ffc script no_south {

void run(){

if ((Link->X >= this->X - 8) && (Link->X <= this->X +8) &&
(Link->Y >= this->Y - 8) && (Link->Y <= this->Y +8) &&
(Link->UpPressed() == true) ){

Link->Y = Link->Y + 4;
}

} // end of void run
} // end of ffc script



// =====================================
// No_North: While on the tile that this
// FFC occupies, Link will not be able to
// move North.
// =====================================


ffc script no_north {

void run(){

if ((Link->X >= this->X - 8) && (Link->X <= this->X +8) &&
(Link->Y >= this->Y - 8) && (Link->Y <= this->Y +8) &&
(Link->DownPressed() == true) ){

Link->Y = Link->Y - 4;
}

} // end of void run
} // end of ffc script


// =====================================
// No_East: While on the tile that this
// FFC occupies, Link will not be able to
// move East.
// =====================================


ffc script no_east {

void run(){

if ((Link->X >= this->X - 8) && (Link->X <= this->X +8) &&
(Link->Y >= this->Y - 8) && (Link->Y <= this->Y +8) &&
(Link->RightPressed() == true) ){

Link->X = Link->X - 4;
}

} // end of void run
} // end of ffc script


// =====================================
// No_West: While on the tile that this
// FFC occupies, Link will not be able to
// move East.
// =====================================


ffc script no_west {

void run(){

if ((Link->X >= this->X - 8) && (Link->X <= this->X +8) &&
(Link->Y >= this->Y - 8) && (Link->Y <= this->Y +8) &&
(Link->LeftPressed() == true) ){

Link->X = Link->X + 4;
}

} // end of void run
} // end of ffc script


EDIT: I suppose I could just have one function that gets passed an argument from the FFC to tell it which directions are blocked instead. I'd still have the same problem.

NOTE: If people are making 2-D games, some script like this will help you make platforms, as in Mario 2, that you can jump up through but not fall down through.

Saffith
10-26-2006, 09:44 PM
Problem is, the compiler doesn't like the Link->DownPressed() function, or it's relatives. Tells me there is no such function. According to Jman's ZScript documentation, there is...
That documentation's out of date. It's no longer a function called DownPressed(), but a bool called InputDown.

DarkDragon
10-27-2006, 06:54 AM
See for instance http://www.armageddongames.net/showthread.php?t=93851, stickied at the top of this forum ;)

C-Dawg
10-27-2006, 09:15 AM
Ah, well, there we go. Thanks.

C-Dawg
10-27-2006, 09:55 PM
What the... now, when I code:

if (Link->InputDown == true)

or

if (Link->InputDown == 1)

I get an "error: cannot cast bool to float" error message.

Saffith
10-28-2006, 03:05 AM
I believe the == operator is currently only defined for numbers. Just use if(Link->InputDown) instead.