Right.
Good start, it's nice to see people have a go for themselves.
You're quite a way off, but what you have got is quite promising.
Your scope is good, and you're using pointers which is quite often a basic error.
Let's have a look at your script though:
CODE
import "std.zh" //Good, we need this at the top of every script file. Remember to keep all scripts in the same file.
ffc script guarding_soldier{ //Declare the ffc script, and name it. So far, so good.
void run(){ //Start by calling 'void run(){'. All scripts start like this, so that's good.
//int ffc->X = Link->X; //Declare and integer called 'ffc->X' and set it's value to Link's X coordinate.
//I've noted out that line; this is what you meant:
this->X = Link->X; //Set the script's ffc's X coordinate to Link's X coordinate.
} //End void run()
}//Close script
Right.
So, with my modifications, what your script will do is:
When the screen loads, check Link's X coordinate, and then set the script's ffc's X coordinate to the same value, moving the ffc so it's in line with Link, then end.
Obviously not what you want, but it's a start.
Quite an important concept for you is the 'while' loop.
Your script runs only once, and you want it to run
every single frame while Link is on the screen.
You do that like this:
CODE
while(true){//Do something
Waitframe();
}
The while loop will keep repeating until the conditions within the parenthesis are broken. While loops running 'true' are never broken, and so will run every frame (that Link is on the screen).
However, that's a really great way to crash the system if you don't declare the 'Waitframe();' function within the loop.
Waitframe(); makes the system stop for one frame before running what's in the loop again, therefore you won't get a system crash.
So, a script to do something more like what you want could be this:
CODE
ffc script guard{
void run(){
while(true){
this->X = Link->X;
Waitframe();
}
}
}
Although, that script will always run wherever Link is on the screen, so the soldier will do some rather unusual things, such as walk through solid combos and the like, and will 'warp' when Link first walks onto the screen to his X coordinate.
So maybe, with a few modifications, you might want to try something like this:
CODE
ffc script guard{
void run(int left, int right){
while(true){
if(Link->X > left && Link->X < right){
this->X = Link->X;
}
Waitframe();
}
}
}
So I'll just run you through what I've done...
CODE
void run(int left, int right){
Here, I've declared two integers.
These integers, because they've been declared within void run(), will be D0 and D1 of the script's arguments.
Remember, if you're declaring argument integers or floats, they're seperated by a comma, not a semi-colon.
CODE
if(Link->X > left && Link->X < right){
this->X = Link->X;
}
Now, what I've done is create an 'if(){}'.
'if(){}' says 'run the functions within '{}' only if the conditions within '()' are true'
So, the script will only make the guard move to Link's X position
if Link's X co-ordinate is greater than (>) 'D0' and (&&) less than (<) 'D1' of the scripts arguments.
The soldier'll still warp to where Link is when he moves between D0 and D1, but that'd take a bit more thinking to code and I'm not in a thinking mood right now.
Anyway, hope that helps a little =)
It's nice to see new people learning.