DarkDragon
05-27-2007, 01:29 AM
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:
ffc script foo {
int a=3;
//...
}
ffc script bar {
void run() {
this->X = foo.a+5;
}
}
New syntax:
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.
Old syntax:
ffc script foo {
int a=3;
//...
}
ffc script bar {
void run() {
this->X = foo.a+5;
}
}
New syntax:
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.