Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

Simultaneous Global Scripts

4 replies · 1,677 views · Started 26 September 2007

Why can I not run both:


global script roll {

void run() {

int counter;
bool justRolled = false;
int DustTile = 40; //the starting animation tile of the 5-frame dust animation.
int DustCSet = 7; //the CSet of the tile animation.
int xca; int xcb; int xcc; int xcd; int xce;
int yca; int ycb; int ycc; int ycd; int yce;
int DustFrame;

while(true) {
if(Link->MP <= 7) {}
else{
if(Link->InputL && Link->Action == LA_WALKING) {

Link->Jump = 20;
if(Link->MP == 0) {}
else{ Link->MP = Link->MP - 8;}
counter = 20;
DustFrame = 1;
xca = -1;
xcb = -1;
xcc = -1;
xcd = -1;
xce = -1;
yca = -1;
ycb = -1;
ycc = -1;
ycd = -1;
yce = -1;
Game->PlaySound(66); //Change/Disable SFX if needed

while(counter > 0) {

Link->Z = 0;
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputA = false;
Link->InputB = false;
Link->InputR = false;
Link->InputL = false;

if(Floor(counter/2) == counter/2) { //trigger animation

xce = xcd;
xcd = xcc;
xcc = xcb;
xcb = xca;

yce = ycd;
ycd = ycc;
ycc = ycb;
ycb = yca;

xca = Link->X;
yca = Link->Y;

if(DustFrame >= 5) {

xca = -1;
yca = -1;

} //end if

DustFrame ++;

} //end if

if(!(xca == -1) && !(yca == -1)) {Screen->DrawTile(2, xca, yca, DustTile, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xcb == -1) && !(ycb == -1)) {Screen->DrawTile(2, xcb, ycb, DustTile + 1, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xcc == -1) && !(ycc == -1)) {Screen->DrawTile(2, xcc, ycc, DustTile + 2, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xcd == -1) && !(ycd == -1)) {Screen->DrawTile(2, xcd, ycd, DustTile + 3, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xce == -1) && !(yce == -1)) {Screen->DrawTile(2, xce, yce, DustTile + 4, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}

if(Link->Dir == DIR_UP) {

if((Screen->ComboS[ComboAt(Link->X+8, Link->Y+6)] == 0) && (Screen->ComboF[ComboAt(Link->X+8, Link->Y+6)] != 97)) {Link->Y -= 2;}

} //end if

if(Link->Dir == DIR_DOWN) {

if((Screen->ComboS[ComboAt(Link->X+8, Link->Y+18)] == 0) && (Screen->ComboF[ComboAt(Link->X+8, Link->Y+18)] != 97)) {Link->Y += 2;}

} //end if

if(Link->Dir == DIR_LEFT) {

if((Screen->ComboS[ComboAt(Link->X-2, Link->Y+8)] == 0) && (Screen->ComboF[ComboAt(Link->X-2, Link->Y+8)] != 97)) {Link->X -= 2;}

} //end if

if(Link->Dir == DIR_RIGHT) {

if((Screen->ComboS[ComboAt(Link->X+18, Link->Y+8)] == 0) && (Screen->ComboF[ComboAt(Link->X+18, Link->Y+8)] != 97)) {Link->X += 2;}

} //end if

counter --;
justRolled = true;

Waitframe();

} //end while

} //end if
} //end else
if(justRolled) {

Link->Jump = 0;
justRolled = false;

}

Link->InputL = false;

Waitframe();

} //end while

} //end void run

} //end script

and:

global script jump {

void run() {

int counter;
bool justJumped = false;
int DustTile = 50; //the starting animation tile of the 5-frame dust animation.
int DustCSet = 7; //the CSet of the tile animation.
int xca; int xcb; int xcc; int xcd; int xce;
int yca; int ycb; int ycc; int ycd; int yce;
int DustFrame;

while(true) {
if(Link->MP <= 15) {}
else{
if(Link->InputR && Link->Action == LA_WALKING) {

Link->Jump = 12;
if(Link->MP == 0) {}
else{ Link->MP = Link->MP - 16;}
counter = 20;
DustFrame = 1;
xca = -1;
xcb = -1;
xcc = -1;
xcd = -1;
xce = -1;
yca = -1;
ycb = -1;
ycc = -1;
ycd = -1;
yce = -1;
Game->PlaySound(66); //Change/Disable SFX if needed

while(counter > 0) {

Link->Z = 16;
Link->InputUp = false;
Link->InputDown = false;
Link->InputLeft = false;
Link->InputRight = false;
Link->InputA = false;
Link->InputB = false;
Link->InputR = false;
Link->InputL = false;

if(Floor(counter/2) == counter/2) { //trigger animation

xce = xcd;
xcd = xcc;
xcc = xcb;
xcb = xca;

yce = ycd;
ycd = ycc;
ycc = ycb;
ycb = yca;

xca = Link->X;
yca = Link->Y;

if(DustFrame >= 5) {

xca = -1;
yca = -1;

} //end if

DustFrame ++;

} //end if

if(!(xca == -1) && !(yca == -1)) {Screen->DrawTile(2, xca, yca, DustTile, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xcb == -1) && !(ycb == -1)) {Screen->DrawTile(2, xcb, ycb, DustTile + 1, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xcc == -1) && !(ycc == -1)) {Screen->DrawTile(2, xcc, ycc, DustTile + 2, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xcd == -1) && !(ycd == -1)) {Screen->DrawTile(2, xcd, ycd, DustTile + 3, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}
if(!(xce == -1) && !(yce == -1)) {Screen->DrawTile(2, xce, yce, DustTile + 4, 1, 1, DustCSet, 1, 0, 0, 0, 0, true, 128);}

if(Link->Dir == DIR_UP) {

if((Screen->ComboS[ComboAt(Link->X+8, Link->Y+6)] == 0) && (Screen->ComboF[ComboAt(Link->X+8, Link->Y+6)] != 97)) {Link->Y -= 2;}

} //end if

if(Link->Dir == DIR_DOWN) {

if((Screen->ComboS[ComboAt(Link->X+8, Link->Y+18)] == 0) && (Screen->ComboF[ComboAt(Link->X+8, Link->Y+18)] != 97)) {Link->Y += 2;}

} //end if

if(Link->Dir == DIR_LEFT) {

if((Screen->ComboS[ComboAt(Link->X-2, Link->Y+8)] == 0) && (Screen->ComboF[ComboAt(Link->X-2, Link->Y+8)] != 97)) {Link->X -= 2;}

} //end if

if(Link->Dir == DIR_RIGHT) {

if((Screen->ComboS[ComboAt(Link->X+18, Link->Y+8)] == 0) && (Screen->ComboF[ComboAt(Link->X+18, Link->Y+8)] != 97)) {Link->X += 2;}

} //end if

counter --;
justJumped = true;

Waitframe();

} //end while

} //end if
} //end else
if(justJumped) {

Link->Jump = 0;
justJumped = false;

}

Link->InputR = false;

Waitframe();

} //end while

} //end void run

} //end script

simultaneously? If I run both at once, only the one in slot 2 will work, and the one in slot 3 will do nothing.

Actually, I'm not sure what global script slot 3 is for. To make both work, you have to include them in one script.

I don't know if that will work because of the while loop. They both use the same variables so why not combine them together. Also you can define all those as global vars and use one as an ffc script. That should work also.

-Although keep in mind i'm not quite an authority on global scripts. I just finished my first one a few days ago.

I'm not competent enough at it to combine them together like that. And I might just use that FFC script. But would it require any modification?

EDIT: This is no longer an issue for me. Thanks anyway.