For now, use a global variable or (better) a screen variable. I'll think about the problem but it boils down to a limitation in the ASM - though you can change FFC-specific variables of another FFC, it's not currently possible to set generic script variables like D0 of another script.
For good reason:
[begin technical ASM discussion]
Each script currently has variables FFCREF and ITEMREF, which contain an integer used to index into the screen's list of ffcs and items, respectively, whenever an ffc or item variable is to be read or modified. For instance, the code
Code:
SETV FFCREF, 1
SETV X, 20
would set the screen's second ffc's x position to 20. ZScript uses these REF variables internally to support item and ffc "pointers" when using LoadItem, LoadFFC, CreateItem, etc. They're also used to support the "this" pointer.
But what would happen if we added a SCRIPTREF variable too? We could then switch to using a different script's D0 registers, stack, etc, which sounds great until you realize there's now no way to go back... when using FFCREF, you can back up the old value of FFCREF into a register or the stack, change to the FFC you want to modify, then restore FFCREF to point to your own FFC; with SCRIPTREF you'd have no way of doing this.
[/end technical ASM discussion]
Here's how I would design a solution to your problem:
Code:
ffc script shooter {
//The first parameter is the screen data register reserved by this script. All instances
//of this script can share this index.
//The second parameter is this particular instance's unique integral ID.
void run(int index, int id)
{
//stuff...
//now it's time to shoot a projectile
Screen->D[index] = Screen->D[index] | (1<<id);
}
}
ffc script projectile {
void run(int index, int id)
{
while(true)
{
while(!(Screen->D[index] & (1<<id)))
Waitframe();
//fire away!
//now reset the projectile
Screen->D[index] = Screen->D[index] ^ (1<<id);
}
}
}