PDA

View Full Version : Simple Script Help



The_Amaster
03-25-2008, 07:01 PM
I decided to write my very first original script, something simple and basic. Yet it isn't working.



ffc script test{
void run(float Xpos, float Ypos) {

Waitframes(200) ;
float X = Xpos;
Waitframes(100) ;
float Y = Ypos;
}
}

it just waits 20 frames, moves the FFC to x position D0, than waits ten, moves it to y position D1. I can't tell why it won't do anything.

Joe123
03-25-2008, 07:54 PM
ffc script test{
void run(float Xpos, float Ypos) {

Waitframes(200) ;
this->X = Xpos;
Waitframes(100) ;
this->Y = Ypos;
}
}

You, my friend, need pointers.

All the commands in ZScript.txt (apart from the first section) are accessed with pointers the same as the sub-section title.

'float X' is in the 'ffc' section, so it uses an ffc pointer for access.
'this->' is a pointer already loaded for the ffc you've got the script attached to.

The_Amaster
03-25-2008, 08:06 PM
Ahhh, gotcha. So what do I use if it's specifying something else onscreen, like in a global. (Or just a script interacting with other FFCs)
(I'm assuming Link uses Link->, and NPCs use NPC->. Do items use This-> or Item->?)

EDIT: Okay, browsing the Wiki helps. So you set NPCs and Items with "name"->.
EDIT 2: Man, it's creepy working on scripting while listening to the theme song from the new Charlie and the Chocolate Factory movie. It makes me feel like a mad scientist about to unleash his creation on the world.

pkmnfrk
03-27-2008, 07:37 PM
"this" refers to whatever thing happens to be running the script. Generally, this will be an FFC, but item scripts point to the item.

You can create your own pointers by using a few magical functions:



this->X = 123; //moves this particular FFC
FFC another;
another = Screen->LoadFFC(3);
another->X = 321; //moves FFC #3


You can do the same thing with NPCs (enemies) and items, but they have different "load" functions. check ZScript.txt for more details.

BTW, that "FFC another" line is declaring a variable named "another", of the type "FFC". That means you can only put FFCs in it.