I've just thought I add this sticky thread because I see the same questions asked all over again.

Frequent Mistake 1: Creating an object.

This won't do:

STRING *mystring = new STRING; // will crash as soon as you attempt to use that string!

Script objects like STRING, ENTITY, BMAP etc. have to be created with their _create functions. Merely allocating a struct won't do because that struct must be initialized and linked to the object manager. So, this is the correct way:

STRING* mystring = str_create("");


Frequent Mistake 2: Creating STRINGs for calling functions.

You'll soon run into memory problems when you create a STRING every time you just want to pass a text or name to a function! All engine functions also accept normal char* arguments. You also do not need _str() or the like. Just use:

char* animation = "walk";
ent_animate(me,animation,VAR_(percent),VAR_(mode));

or

ent_animate(me,"walk",VAR_(percent),VAR_(mode));


Frequent Mistake 3: Forgetting the VAR_() when passing non-VAR values to engine functions.

The engine does not automatically convert int/float/...-values passed to the engine to var.

Last edited by TWO; 11/17/07 16:07.