Jump to content

Photo

Mine cart


  • Please log in to reply
4 replies to this topic

#1 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Location:The Netherlands

Posted 19 April 2013 - 09:35 AM

I'm working on a mine cart script that drives over Raft flags, automatically turns around corners (prefers left over right) and throws you out when you hit a dead end.
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


#2 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 19 April 2013 - 10:55 AM

For draw over: I think that's FFC->Flags[FFCF_OVERLAY].

#3 Mr. Z

Mr. Z

    Old Bastard is back!

  • Members
  • Real Name:Erik
  • Location:The Netherlands

Posted 19 April 2013 - 01:03 PM

Okay, I fixed its layer and improved the code.

I still have the problem with the multiple carts though, any idea what causes that?

I also made some progress with the scrolling, but I can't find the proper function to stick the cart to Link as he scrolls between the screens. Right now, if you were to leave a screen at the bottom, the cart on the next screen will still appear at the bottom with Link in it, causing you to keep scrolling down until you hit the edge of the map.


Spoiler


#4 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 19 April 2013 - 02:03 PM

It can't help that you have the riding variables as global variables. I'm guessing that's what's causing your teleportation problem.

As for motion between screens, you enable "FFC carries over" on the minecart FFCs, as long as each screen the cart can visit has its FFC slot empty.

To place it on Link, store the current screen each frame, and when the screen changes, place the cart on Link's current position.

#5 aaa2

aaa2

    Wizard

  • Banned

Posted 19 April 2013 - 03:34 PM

How about i give you a fitting structure for your script in pseudo code
CODE

bool link_in_cart;
ffc script MineCart{
    void run(){

        while(true){
             if(link_in_cart){ //if you are in the cart when you change a screen the cart will be moved to link
                    position_cart_at_link();
                     cart();
                     cart_exit();
               }
              if(link_enters_cart()){
                    cart_entry();
                     cart();
                     cart_exit();
              }
              Waitframe();
        }
}
void cart_entry(){
    link_in_cart=true;  //make sure the game registers you entered the cart
    //the animation code for entering the cart goes here
}
void cart_exit(){
// the animation for when link exits the cart goes here
  link_in_cart=false; //make sure the game registers link is not a cart anymore
}
void position_cart_at_link(){
\\ this function should move the cart to link fast after you change screen if you are in the cart
}
void cart(){
     //here you should write what the minecart does while link is in it each frame
     Waitframe();
}
bool link_enters_cart(){
    bool b=false;
     //check here if link steps on the cart if he does set b to true
     return b;
}


With this structure your script should work fine and bugfree.


Things are always simpler if you write everything you want your script to do in the main function without filling in any details. That way you get a structure early and can recognize possible problems early on. Plus your code will be very easy to read an maintain.


Also note with this structure you will also not need to do complicated things like storing screen positions each frame like moscow modder suggested because the structure takes away the work.

Edited by aaa2, 19 April 2013 - 03:44 PM.



1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users