User Tag List

Results 1 to 8 of 8

Thread: Deprecation notice: global variables

  1. #1
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,029
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.66%

    Deprecation notice: global variables

    In preparation for a planned overhaul of the ZScript language in 2.5, I have changed the syntax of global variables slightly, as per several of your suggestions. Global variables should now be declared at file scope, instead of at script scope.
    Old syntax:
    Code:
    ffc script foo {
       int a=3;
       //...
    }
    
    ffc script bar {
       void run() {
          this->X = foo.a+5;
       }
    }
    New syntax:
    Code:
    int a = 3;
    
    ffc script foo {
       //...
    }
    
    ffc script bar {
       void run() {
          this->X = a+5;
       }
    }
    This new syntax is recommended for all new scripts, and the old, script-scope syntax is deprecated. What does this mean?
    1) Quests containing scripts which are already compiled, and which will never need to be modified and recompiled, are completely unaffected.
    2) Incomplete quests containing scripts which do need to be recompiled will still compile - for now. The ZScript compiler will issue a warning pointing out where in your scripts you have used the old syntax, but will nevertheless compile your script.

    How long will the old syntax still work? Until I need to reuse that syntax for a new language feature (such as "class-scope" variables visible to all instances of a specific script), which certainly won't be until after b18.

    I apologize for this change, and the inconvenience of having to modify old scripts you wish to reuse, but unlike most other parts of ZQ, maintaining perfect backwards compatibility in the ZScript language is not feasible. I've tried and will try to minimize changes such as this one which require modification of old scripts, will give you as much of a "grace period" as possible to change over old scripts, and am happy to help anyone who has trouble porting their old scripts to the new syntax.

  2. #2
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,613
    Level
    25
    vBActivity - Bars
    Lv. Percent
    0.11%

    Re: Deprecation notice: global variables

    Good with me. I only use global variables in one script anyway, for now.

  3. #3
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,613
    Level
    25
    vBActivity - Bars
    Lv. Percent
    0.11%

    Re: Deprecation notice: global variables

    Your new global variables don't work, nor does 319 correctly run code compiled under previous versions. Download Zodiac over at the Quest forum and try running it under 319.

    (1) The jumping script does not function at all. Not sure what's going on with it.

    (2) I tried moving all the variables used by the jump function outside of script, as per your example. It doesn't compile. Gives me an error, saying that it didn't expect a declaration there.

  4. #4
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,029
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.66%

    Re: Deprecation notice: global variables

    I know the jumping doesn't work, but that has nothing to do with the global variables; grab the next-to-latest beta and you'll see. Actually, if you have any idea where I might start in investigating this bug, I'd be very thankful, as I want Zodiac to be one of the quests working perfectly in b18.

    Are you sure about the errors? I just copied and pasted the block of variable declarations to outside of the ffc declaration and it compiled with no warnings or errors.

  5. #5
    Wizrobe C-Dawg's Avatar
    Join Date
    Jan 2002
    Posts
    4,205
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,613
    Level
    25
    vBActivity - Bars
    Lv. Percent
    0.11%

    Re: Deprecation notice: global variables

    (1) If it's not the variable scope change, what is causing the script to malfunction in later betas? As near as I can tell, the jump script is just not ever getting out of the state where link's position is reset to offset _L_'s gravity. Normally this state stops once the airtime variable expires. For some reason, that's not happening. And until the player touches the ground again, the one_jump variable (preventing you from jumping, releasing the button to descend, and then hitting the button again to keep moving upwards because your airtime hadn't expired) doesn't reset and you can't continue jumping. If you end up on the same plane as a platform though, you can walk over to it, and then one_jump resets normally. So it's definitely a problem with the "okay the jump is done now let gravity take over" variable.

    Perhaps it's a bug with the sideview gravity, actually?

    (2) I didn't declare the variables with values; just int i; int j; that kind of thing. Is that allowed? If so, maybe there's a silly syntax error in there somewhere... I'll check.

  6. #6
    Administrator DarkDragon's Avatar
    Join Date
    Oct 2001
    Posts
    6,228
    Mentioned
    70 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    11,029
    Level
    31
    vBActivity - Bars
    Lv. Percent
    8.66%

    Re: Deprecation notice: global variables

    Yes, that should be allowed. Here's your scripts, after my modifications:

    Code:
    import "std.zh"
    	
    int jumpforce_maximum;		// The maximum force of the player's jump.
    int jumpforce_current = 0;	// The current foir
    int i = 0;			// Counters for smoothing top of jump
    int j = 0;
    int k = 0;			// switch for jump smoothing
    
    int floaty_maximum;	// Maximum value for floaty.
    int floaty = 0;			// This counter ensures the player floats
    						// briefly at the height of the jump.
    int dashing = 0;			// 0 = not dashing, 1 = dashing
    int MP_refill = 0;			// counter for continuous MP refill
    int airtime = 0;		// This counter controls the time of the jump.
    int airtime_current = 0;	// This is the player's present airtime.
    int resist = 0;			// conuter to increasing gravity
    
    int turnoffjump = 0;		// turns off jumping once player  
    						// releases the jump button in the air.
    int prev_jump = 0;		// was link jumping the frame before?
    
    int double_jumped = 0;		// keeps track of the number of jumps for double-jumping
    
    
    // =================================
    // Jump - This script handles the following:
    // Jumping, Dashing, Energy refill
    // Currently uses whistle for double jump,
    // Roc's Feather for high jump.
    // =================================
    
    ffc script Jump{
    
    
    	void run(){
    		
    	... rest of the code
    As you can see all I did was move the variables over and delete some tabs for readability.

    I will investigate in-depth why your jump script is failing.

  7. #7
    Lynel Majora's Avatar
    Join Date
    Mar 2006
    Age
    32
    Posts
    1,197
    Mentioned
    24 Post(s)
    Tagged
    7 Thread(s)
    vBActivity - Stats
    Points
    4,389
    Level
    20
    vBActivity - Bars
    Lv. Percent
    94.26%

    Re: Deprecation notice: global variables

    Sideview is broken in 319, and if I remember correctly, has been since 303 (I think)

  8. #8
    Developer
    ZC Developer

    Join Date
    Aug 2006
    Location
    Australia
    Age
    37
    Posts
    2,777
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    6,852
    Level
    25
    vBActivity - Bars
    Lv. Percent
    37.91%

    Re: Deprecation notice: global variables

    That it has been! But I fixed it just now. Now everything mentioned in this topic works again!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social