PDA

View Full Version : Jumping between screens (Global Variables)



C-Dawg
12-11-2006, 09:51 PM
I've been tinkering with a combination of _L_'s sideview gravity flag and a script of my own to allow the player to jump using the L button, and to allow for variable jumping heights. This is working pretty well so far, but I've encountered one snag.

When Link jumps up off the top of a screen, he switches to a screen running a new FFC script. (I have FFCs running my jump script). Then, the gravity script takes over and yanks him down. So, in effect, he can't jump to a higher screen.

I imagine the solution here is to use a global variable to keep track of Link's jumping status. But when I tried declaring such a global variable (outside of FFC scripts in the buffer) I just got an error message. What gives?

DarkDragon
12-12-2006, 11:07 AM
Global variables will work that way eventually, but for now, variables in script scope are global:


ffc script foo {
int aglobal;
}

which can then be accessed as foo.aglobal.

C-Dawg
12-12-2006, 12:20 PM
Ah. So if I have the same FFC Script running on two screens, when I switch screens, the value in aglobal will transfer to the second FFC Script? Does the fact that the script will try to instantiate aglobal again cause a problem.

C-Dawg
12-12-2006, 06:21 PM
I'm also having problems with Link moving smoothly left and right after falling from a Jump. The gravity script switches Link's combo and pulls him straight down, giving the player little or no control over left and right movement.

I'd do away with the gravity flag entirely, except that I really like not having to worry about coding the enemies dropping due to gravity. _L_, do you have a ZScript version of your gravity code that can be applied though an FFC?

DarkDragon
12-13-2006, 11:08 AM
Ah. So if I have the same FFC Script running on two screens, when I switch screens, the value in aglobal will transfer to the second FFC Script?
Yes.

Does the fact that the script will try to instantiate aglobal again cause a problem.
No. Global variables are instatiated in the automatically-generated ~Init script, which runs when you first start a quest, and never again.

As for your gravity questions, I haven't gotten a chance to play around with the new gravity yet; you'll have to wait for _L_.