Original Post
I'm a bit confused here. Been digging through the manual, but I couldn't find a full document on this topic, only bits and pieces. So I'll just ask here. [sick] What's the proper way to spawn a class instance and initialize its variables to predefined values (using the engine API)? Suppose the Angelscript engine loads a few class declarations. We won't load any more script files from this point on so we can't have the script do the work for us. We'd like to have the engine read some user-specified data and create a number of class instances plus initialize the member variables according to user data (specified values for class member variables may be different for each class instance). This user-specified data is basically a list of objects to be created, and with values to be assigned. I think that asking for a full source code to handle all classes with built-in data parser is a bit over the edge, so I'll just ask for a simple example with a single class. Suppose we loaded a class: And our user specified this data (this is just a mockup): As you can see, not all variables have been specified (thanks to our lazy user who wrote this code). Unspecified vars should probably be set to their defaults. Now we'd like the engine to: A) Create these four instances of the "Bullet" class B) Initialize the class members with the specified values Now my questions are: What's the proper way to do A? What's the proper way to do B? Any hints? Thanks, Bismuth
class Bullet {
int32 x, y, z; // Location
int32 vx, vy, vz; // Speed
int32 damage;
}
[Bullet(x=133,y=415,z=0,damage=6)]
[Bullet(x=13,y=158,z=20,damage=3)]
[Bullet(x=0,y=0,z=0,vx=33,vy=16,damage=12)]
[Bullet(vx=0,vy=0,vz=100)]