PDA

View Full Version : Scripts refuse to compile...



HylianGlaceon
01-18-2011, 06:15 PM
Trying to combine a few scripts, but it won't compile and isn't making sense..

The script is here: http://www.purezc.com/forums/index.php?showtopic=38916

error is: "LINE 289: SYNTAX ERROR, UNEXPECTED RBRACE, EXPECTING $END, ON TOKEN }"

Removing or adding a } doesn't do anything.

The line it's complaining about is the } between the dash check and global slot 3.


//Check whether Link can dash onto a combo
int DashCheck(int x, int y, bool xy){
int xoffset; int yoffset;
bool Solid;
if(xy) xoffset = 4;
else yoffset = 3;
if(Screen->isSolid(x-xoffset,y-yoffset) || Screen->isSolid(x+xoffset,y+yoffset)) Solid = true;
if(!Solid && !ComboFI(x-xoffset,y-yoffset,CF_DASH)
&& !ComboFI(x+xoffset,y+yoffset,CF_DASH)) return 0;
else if(Solid && (ComboFI(x-xoffset,y-yoffset,CF_DASH)
|| ComboFI(x+xoffset,y+yoffset,CF_DASH))) return 1;
else return 2;
}
}

global script Slot_3{
void run(){
UseBChu = 0;


I also have Bombchu and Bomb Arrow scripts mixed in there.

This is a bigger part of my script below, couldn't fit all of it.


//Pegasus Boots
void PegasusBoots(){
if(!PegasusCollision){
int loc = ComboAt(Link->X+8,Link->Y+8);
//Check if Link should be dashing
if(((StoreInput == 1 && !Link->InputA)
|| (StoreInput == 2 && !Link->InputB))
|| StoreHP < Link->HP
|| Screen->ComboT[loc] == CT_WATER){
PegasusDash = false;
DashCounter = 0;
}
//Stop all actions
NoAction();
//Movement
if(DashCounter > 10){
if(Link->Dir == 0 && DashCheck(Link->X+8,Link->Y+6,true) != 2){
Link->Y--;
Link->InputUp = true;
}else if(Link->Dir == 1 && DashCheck(Link->X+8,Link->Y+18,true) != 2){
Link->Y++;
Link->InputDown = true;
}else if(Link->Dir == 2 && DashCheck(Link->X,Link->Y+12,false) != 2){
Link->X--;
Link->InputLeft = true;
}else if(Link->Dir == 3 && DashCheck(Link->X+16,Link->Y+12,false) != 2){
Link->X++;
Link->InputRight = true;
}else{
PegasusCollision = true;
DashCounter = 0;
}
}
//Break Pegasus Blocks
if(ComboFI(Link->X+8,Link->Y+8,CF_DASH) && Screen->ComboS[loc] == 1111b){
Screen->ComboD[loc]++;
if(Screen->ComboF[loc] == CF_DASH) Screen->ComboF[loc] = 0;
Game->PlaySound(SFX_PEGASUSBREAK);
}
//Dust tile animation
lweapon Dust;
if(DashCounter%4 == 0){
for(int j=1;j<=Screen->NumLWeapons();j++){
Dust = Screen->LoadLWeapon(j);
if(Dust->ID != LW_SCRIPT10) continue;
if(Link->Dir < 1) Dust->Y-=3;
else if(Link->Dir < 2) Dust->Y+=3;
else if(Link->Dir < 3) Dust->X-=3;
else if(Link->Dir < 4) Dust->X+=3;
}
Dust = Screen->CreateLWeapon(LW_SCRIPT10);
Dust->OriginalTile = T_DUST;
Dust->CSet = DustCSet;
Dust->Y = Link->Y;
Dust->X = Link->X;
Dust->NumFrames = DustAFrames;
Dust->ASpeed = DustASpeed;
Dust->DeadState = DustAFrames*DustASpeed;
}
//Play SFX
if(DashCounter%DashSFXLength == 0) Game->PlaySound(SFX_DASH);
}else{
//Bounceback after hitting a wall
NoAction();
if(DashCounter == 1){
Screen->ClearSprites(SL_LWPNS);
Game->PlaySound(SFX_HITWALL);
Screen->Quake = 10;
}else if(DashCounter == 10){
PegasusDash = false;
PegasusCollision = false;
DashCounter = 0;
}
if(Link->Dir == 0 && DashCheck(Link->X+8,Link->Y+6,true) == 0) Link->Y++;
else if(Link->Dir == 1 && DashCheck(Link->X+8,Link->Y+18,true) == 0) Link->Y--;
else if(Link->Dir == 2 && DashCheck(Link->X+18,Link->Y+8,false) == 0) Link->X++;
else if(Link->Dir == 3 && DashCheck(Link->X-2,Link->Y+8,false) == 0) Link->X--;
if(DashCounter < 5) Link->Z++;
}
DashCounter++;
}
//Check whether Link can dash onto a combo
int DashCheck(int x, int y, bool xy){
int xoffset; int yoffset;
bool Solid;
if(xy) xoffset = 4;
else yoffset = 3;
if(Screen->isSolid(x-xoffset,y-yoffset) || Screen->isSolid(x+xoffset,y+yoffset)) Solid = true;
if(!Solid && !ComboFI(x-xoffset,y-yoffset,CF_DASH)
&& !ComboFI(x+xoffset,y+yoffset,CF_DASH)) return 0;
else if(Solid && (ComboFI(x-xoffset,y-yoffset,CF_DASH)
|| ComboFI(x+xoffset,y+yoffset,CF_DASH))) return 1;
else return 2;
}
}

global script Slot_3{
void run(){
UseBChu = 0;
PegasusDash = false;
PegasusCollision = false;

}
}

item script Bombchu{
void run(){
if(Game->Counter[CR_SCRIPT1] > 0) UseBChu++;
}
}
item script BombArrows{
void run(){
if(Game->Counter[CR_BOMBS] > 0 && Game->Counter[CR_ARROWS] > 0 && UseBombArrow == 0){
UseBombArrow++;
Game->Counter[CR_BOMBS]--;
Game->Counter[CR_ARROWS]--;
}
}
item script PegasusBoots{
void run(){
if(Screen->ComboT[ComboAt(Link->X+8,Link->Y+8)] == CT_WATER
|| ComboFI(Link->X+8,Link->Y+8,CF_DASH)) Quit();
PegasusDash = true;
if(Link->InputB && !Link->InputA) StoreInput = 2;
else if(Link->InputA && !Link->InputB) StoreInput = 1;
}
}
}

Colossal
01-18-2011, 07:35 PM
It looks to me like you have an extra } at the end of your script file (if that is the end). Have you tried removing that one? I think the compiler was expecting the end of file and ran into that }.

HylianGlaceon
01-19-2011, 12:27 AM
Yeah, that's the end, I tried removing it but it still gets hung up on that earlier area for some reason.

Thanks for that though, it's probably still wrong with that ending so I'll change that too. I really know close to nothing about scripts.

Colossal
01-19-2011, 02:48 PM
Alright, I took another look at it and found that the bomb arrows script has 3 opening braces, but only 2 closing braces. This can be fixed by adding another closing brace (}) to the end of the script, but before the pegasus boots item script.

If that doesn't fix the error, there is probably a point in the file where there is an extra closing brace that doesn't match up with an opening brace somewhere (that's why the compiler is expecting $end, I think). So at the given line, the number of closing braces exceeds the number of opening braces so far and the } on that line might need to be removed, if that helps.

HylianGlaceon
01-19-2011, 05:41 PM
Okay, I removed a few bracers and it finally compiles now, I didn't know that about the bracers before as the scripting language is still kind of gibberish to me.

Thanks a bunch!