====== ZeoScript compiler ====== Hi Everyone, In the latest build of L3DT Pro (v2.8 build 2, 10th of Dec '09), the [[bundywiki>plugins:general:ZeoScript|ZeoScript]] plugin has been updated to use a just-in-time (JIT) compiler. The effect of this compiler is to increase the speed of loops in ZeoScript, and that it has achieved. Map calculations in ZeoScript should now run at least **5x faster than before**. ===== Syntax changes ===== Users should also be aware that the syntax of the ZeoScript language has been revised for greater clarity and ease of use. I have updated the example scripts provided with the new installer, but if you use custom scripts, you may need to modify them to work with the new release. Below I have included a listing of all the major syntax changes: ====Nested function calls==== Function nesting, whereby one function's return value is fed into the argument list of another, was previously achieved using the operator. Now, the 'zs:' component is redundant, so nested functions are denoted simply by the < and > braces. The examples below show the old and new way of calling nested functions. Here, the values of //c// and //d// are added together, then multiplied by //b//, and finally //a// is assigned the resultant value: ^ Old | set a > | ^ New | set a > | By removing the 'zs:' component, the purpose of the code becomes more obvious, and this should make the language both easier to use and learn. ====Accessing maps, file formats and global variables==== Previously, to retrieve a map from the L3DT map project, one used the operator. This special operator has been replaced by the 'GetMap' function, which otherwise behaves in much the same fashion, as shown below: ^ Old | map.GetWidth | ^ New | map.GetWidth | Similarly, the operator for retrieving file format handlers was replaced by the 'GetFormat' function, and the operator for retrieving global variables was replaced by the 'GetVar' function. ====Casting variable types==== To cast a variable value from one type or another, it was necessary to use the operator. This has been replaced by a 'cast' function, but as it happens, the resulting syntax is almost identical: ^ Old | echo | ^ New | echo | [note that the ':' is no longer necessary] ====Pointer referencing and dereferencing==== In previous versions of ZeoScript, the interpreter would automatically reference variables and dereference pointers as required. In the new version, users now have responsibility to manage pointers, just as with C/C++. As an example, the code below shows the use of the function 'EditUI' which takes two arguments, the first of which is a pointer to a variable (a hvar), and the second is a string. In the new compiler, you must manually reference the variable using the & operator to get the hvar, like so: int i EditUI &i "Enter integer" // edit i (using & to get handle) In the old interpreter, you could pass any variable in as the first argument, and the interpreter would automatically reference the variable to get the hvar: int i EditUI i "Enter integer" By disabling automatic referencing/dereferencing, I hope to make it more obvious whether fucntion arguments are being passed by value or by reference. However, this behaviour may be more difficult to learn for scripters not familiar with pointers. Consequently, many examples are provided. ====elseif==== In addition to the 'if', 'else' and 'endif' statements, I have now added an 'elseif' statement to permit neater if/else chains. For example, the following code prints a different message depending on the value of an integer //i//. if echo "i is greater than 10" elseif echo "i is greater than 5 but less than or equal to 10" else echo "i is less than or equal to 5" endif In the old interpreter, the 'elseif' used above could only be achieved by nesting an if statement within an else statement, like so: if echo "i is greater than 10" else if // nested if in else, instead of an elseif echo "i is greater than 5 but less than or equal to 10" else echo "i is less than or equal to 5" endif endif By permitting 'elseif', we save on some unnecessary nesting, and simply the structure of the if/else chain. ====Future changes==== Any further development of ZeoScript will be focussed on improving the execution speed of the runtime engine, and extending the range of functions and features available. I do not anticipate making any any further changes to the syntax of the language, as I feel ZeoScript now meets its requirements with a minimum of fuss. Hence, scripts written for this new ZeoScript plugin should continue to work indefinitely with future releases of L3DT (that's the plan, anyhow.) ==== Documentation ==== I have not //yet// updated the [[bundywiki>plugins:general:ZeoScript:examples|examples]] or [[bundywiki>plugins:general:ZeoScript:reference|reference]] pages for ZeoScript, as those pages represent the state of ZeoScript in the current release-version of L3DT. These pages will be updated for the next release, which will likely be v2.8a, in the near-ish future. In lieu of updated documentation, I have updated all the scripts included with the installer, which provide examples for most of the scripting features. However, if you require additional information or help, please feel free to ask in the [[http://www.bundysoft.com/phpBB2/viewforum.php?f=11|plugins and scripts]] forum. Best regards, Aaron. {{tag>scripts}}