Hi,
I seem to have found some bug/problem in the order of variable initialization when using ScriptBuilder (#include directive).
Below is an example:
File 'Position.as' contains the following.
uint16 COORDINATE_DEFAULT = 15000;
class Position
{
// Default constructor
Position()
{
mX = uint16(15000);
mY = uint16(COORDINATE_DEFAULT);
}
// The position variables
uint16 mX;
uint16 mY;
}
File 'CtorTest.as' contains the following:
#include "Position.as"
Position globalPos;
void main()
{
Position localPos;
Trace("Global pos = " + globalPos.mX + ", " + globalPos.mY + "\n");
Trace("Local pos = " + localPos.mX + ", " + localPos.mY + "\n");
}
Running the script 'CtorTest.as' I get the following text reported by (my) Trace function:
----------------------------------------
Global pos = 15000, 0
Local pos = 15000, 15000
----------------------------------------
To me this indicates that the variable 'COORDINATE_DEFAULT' was not already initialized during the constructor call for the global object 'globalPos'. However, when constructing the local object 'localPos' everything is fine.
This problem only occurs when the variable COORDINATE_DEFAULT is located in the included file. If it is declared in the main file everything works fine for the global and for the local object.
I experienced the problem on AngelScript version 2.16.1 (May 9th, 2009)
Any thoughts on this?
Thanks and regards
[Edited by - Friggle on May 21, 2009 3:20:03 PM]