And it works, but there are some things not entirely right with it.
-When I put multiple carts on a screen, Link teleports from cart to cart and they all do not move properly. (This teleporting created inspiration for my next script :V)
-If you manage to leave the screen on a cart or while jumping out, all of the carts stop working, even the ones on other screens.
-How can I switch the ffc flag "Draw Over" to make it appear over Link while he's riding it?
Spoiler
CODE
const int CART_GRAPHIC=724; //Proper cart graphics not yet set, right now the cart just looks like the selected ffc. (Link also appears on top of it)
const int TRACK_FLAG=8; //The flag number of the track the cart will follow. Standard set to Raft Path. (Don't use docks)
const int CART_SPEED=1; //The speed of the cart.
const int ALLOW_SWORD=0; //Allows use of the sword while in the cart.
int riding=0;
int hspeed=0;
int vspeed=0;
int cartdirection=0;
ffc script MineCart{
void run(){
while(true){
int xlink=Link->X+8;
int ylink=Link->Y+8;
int xpos=this->X+8;
int ypos=this->Y+8;
if(ComboAt(xlink,ylink)==ComboAt(xpos,ypos) && riding==0){
EnterCart(xpos,ypos);
if(TrackAhead(1,xpos,ypos)==true){ cartdirection=1; }
else if(TrackAhead(2,xpos,ypos)==true){ cartdirection=2; }
else if(TrackAhead(3,xpos,ypos)==true){ cartdirection=3; }
else if(TrackAhead(4,xpos,ypos)==true){ cartdirection=4; }
}
if(riding==2){
Link->X=this->X;
Link->Y=this->Y;
this->Vx=hspeed;
this->Vy=vspeed;
if(this->Vy<0){ cartdirection=1; }
if(this->Vy>0){ cartdirection=2; }
if(this->Vx<0){ cartdirection=3; }
if(this->Vx>0){ cartdirection=4; }
if(ALLOW_SWORD==0){ Link->SwordJinx=2; }
int loopcount=0;
while(loopcount<5){
if(cartdirection==1){ //1 up -> 3 left -> 4 right
if(TrackAhead(1,xpos,ypos)==true){ vspeed=-CART_SPEED; }
else if(TrackAhead(1,xpos,ypos)==false){
vspeed=0;
if(TrackAhead(3,xpos,ypos)==true){ hspeed=-CART_SPEED; }
else if(TrackAhead(4,xpos,ypos)==true){ hspeed=CART_SPEED; }
}
}
if(cartdirection==2){ //2 down -> 4 right -> 3 left
if(TrackAhead(2,xpos,ypos)==true){ vspeed=CART_SPEED; }
else if(TrackAhead(2,xpos,ypos)==false){
vspeed=0;
if(TrackAhead(4,xpos,ypos)==true){ hspeed=CART_SPEED; }
else if(TrackAhead(3,xpos,ypos)==true){ hspeed=-CART_SPEED; }
}
}
if(cartdirection==3){ //3 left -> 2 down -> 1 up
if(TrackAhead(3,xpos,ypos)==true){ hspeed=-CART_SPEED; }
else if(TrackAhead(3,xpos,ypos)==false){
hspeed=0;
if(TrackAhead(2,xpos,ypos)==true){ vspeed=CART_SPEED; }
else if(TrackAhead(1,xpos,ypos)==true){ vspeed=-CART_SPEED; }
}
}
if(cartdirection==4){ //4 right -> 1 up -> 2 down
if(TrackAhead(4,xpos,ypos)==true){ hspeed=CART_SPEED; }
else if(TrackAhead(4,xpos,ypos)==false){
hspeed=0;
if(TrackAhead(1,xpos,ypos)==true){ vspeed=-CART_SPEED; }
else if(TrackAhead(2,xpos,ypos)==true){ vspeed=CART_SPEED; }
}
}
loopcount++;
if(loopcount==5 && hspeed==0 && vspeed==0){ riding=3; }
}
}
if(riding==3){
this->Vx=hspeed;
this->Vy=vspeed;
LeaveCart(cartdirection,xpos,ypos);
cartdirection=0;
}
Waitframe();
}
}
} //MineCart
void EnterCart(int xpos, int ypos){
riding=1;
Link->Jump=2;
for(int i=0; i<24; i++){
NoAction();
Waitframe();
}
riding=2;
} //EnterCart
void LeaveCart(int dir, int xpos, int ypos){
riding=4;
Link->Jump=2;
for(int i=0; i<16; i++){
if(dir==1){ Link->Y-=1; }
if(dir==2){ Link->Y+=1; }
if(dir==3){ Link->X-=1; }
if(dir==4){ Link->X+=1; }
NoAction();
Waitframe();
}
riding=0;
cartdirection;
} //LeaveCart
bool TrackAhead(int dir, int xpos, int ypos){
int xdir=0;
int ydir=0;
if(dir==1){ ydir=-(8+CART_SPEED); }
if(dir==2){ ydir=8+CART_SPEED; }
if(dir==3){ xdir=-(8+CART_SPEED); }
if(dir==4){ xdir=8+CART_SPEED; }
if(Screen->ComboF[ComboAt(xpos+xdir,ypos+ydir)]==TRACK_FLAG || Screen->ComboI[ComboAt(xpos+xdir,ypos+ydir)]==TRACK_FLAG){
return true;
}
else{ return false; }
} //TrackAhead
const int TRACK_FLAG=8; //The flag number of the track the cart will follow. Standard set to Raft Path. (Don't use docks)
const int CART_SPEED=1; //The speed of the cart.
const int ALLOW_SWORD=0; //Allows use of the sword while in the cart.
int riding=0;
int hspeed=0;
int vspeed=0;
int cartdirection=0;
ffc script MineCart{
void run(){
while(true){
int xlink=Link->X+8;
int ylink=Link->Y+8;
int xpos=this->X+8;
int ypos=this->Y+8;
if(ComboAt(xlink,ylink)==ComboAt(xpos,ypos) && riding==0){
EnterCart(xpos,ypos);
if(TrackAhead(1,xpos,ypos)==true){ cartdirection=1; }
else if(TrackAhead(2,xpos,ypos)==true){ cartdirection=2; }
else if(TrackAhead(3,xpos,ypos)==true){ cartdirection=3; }
else if(TrackAhead(4,xpos,ypos)==true){ cartdirection=4; }
}
if(riding==2){
Link->X=this->X;
Link->Y=this->Y;
this->Vx=hspeed;
this->Vy=vspeed;
if(this->Vy<0){ cartdirection=1; }
if(this->Vy>0){ cartdirection=2; }
if(this->Vx<0){ cartdirection=3; }
if(this->Vx>0){ cartdirection=4; }
if(ALLOW_SWORD==0){ Link->SwordJinx=2; }
int loopcount=0;
while(loopcount<5){
if(cartdirection==1){ //1 up -> 3 left -> 4 right
if(TrackAhead(1,xpos,ypos)==true){ vspeed=-CART_SPEED; }
else if(TrackAhead(1,xpos,ypos)==false){
vspeed=0;
if(TrackAhead(3,xpos,ypos)==true){ hspeed=-CART_SPEED; }
else if(TrackAhead(4,xpos,ypos)==true){ hspeed=CART_SPEED; }
}
}
if(cartdirection==2){ //2 down -> 4 right -> 3 left
if(TrackAhead(2,xpos,ypos)==true){ vspeed=CART_SPEED; }
else if(TrackAhead(2,xpos,ypos)==false){
vspeed=0;
if(TrackAhead(4,xpos,ypos)==true){ hspeed=CART_SPEED; }
else if(TrackAhead(3,xpos,ypos)==true){ hspeed=-CART_SPEED; }
}
}
if(cartdirection==3){ //3 left -> 2 down -> 1 up
if(TrackAhead(3,xpos,ypos)==true){ hspeed=-CART_SPEED; }
else if(TrackAhead(3,xpos,ypos)==false){
hspeed=0;
if(TrackAhead(2,xpos,ypos)==true){ vspeed=CART_SPEED; }
else if(TrackAhead(1,xpos,ypos)==true){ vspeed=-CART_SPEED; }
}
}
if(cartdirection==4){ //4 right -> 1 up -> 2 down
if(TrackAhead(4,xpos,ypos)==true){ hspeed=CART_SPEED; }
else if(TrackAhead(4,xpos,ypos)==false){
hspeed=0;
if(TrackAhead(1,xpos,ypos)==true){ vspeed=-CART_SPEED; }
else if(TrackAhead(2,xpos,ypos)==true){ vspeed=CART_SPEED; }
}
}
loopcount++;
if(loopcount==5 && hspeed==0 && vspeed==0){ riding=3; }
}
}
if(riding==3){
this->Vx=hspeed;
this->Vy=vspeed;
LeaveCart(cartdirection,xpos,ypos);
cartdirection=0;
}
Waitframe();
}
}
} //MineCart
void EnterCart(int xpos, int ypos){
riding=1;
Link->Jump=2;
for(int i=0; i<24; i++){
NoAction();
Waitframe();
}
riding=2;
} //EnterCart
void LeaveCart(int dir, int xpos, int ypos){
riding=4;
Link->Jump=2;
for(int i=0; i<16; i++){
if(dir==1){ Link->Y-=1; }
if(dir==2){ Link->Y+=1; }
if(dir==3){ Link->X-=1; }
if(dir==4){ Link->X+=1; }
NoAction();
Waitframe();
}
riding=0;
cartdirection;
} //LeaveCart
bool TrackAhead(int dir, int xpos, int ypos){
int xdir=0;
int ydir=0;
if(dir==1){ ydir=-(8+CART_SPEED); }
if(dir==2){ ydir=8+CART_SPEED; }
if(dir==3){ xdir=-(8+CART_SPEED); }
if(dir==4){ xdir=8+CART_SPEED; }
if(Screen->ComboF[ComboAt(xpos+xdir,ypos+ydir)]==TRACK_FLAG || Screen->ComboI[ComboAt(xpos+xdir,ypos+ydir)]==TRACK_FLAG){
return true;
}
else{ return false; }
} //TrackAhead

