A struct doesnt actually 'do' anything. Its just a group of variables and
pointers you are lumping together for ease of access.
Heres a rough interpretation of what your trying to do, even though I cant
see why you'd want to, at least this way. There are many easier ways to do
what I THINK you want, which I'll post if you ask.
typedef struct
{
var lifetime;
ENTITY* model;
} box;
function i_am_fly(box* ThisBox)
{
ThisBox.lifetime -= 1;
if (ThisBox.lifetime < 1)
{
ent_remove(ThisBox.model);
// Add the following line ALSO if you want to remove BOX struct too
//ptr_remove(ThisBox);
}
}
function new_box()
{
box my_box;
my_box.model = ent_create("a.mdl",vector(0,0,0),NULL);
//my_box.function = i_am_fly(); //<<<<<< replaced lower down
/* some 3d object set up stuff */
my_box.lifetime = 100;
c_setminmax(my_box.model);
wait(1);
/* some object physics set up stuff */
i_am_fly(my_box); //<<<<<<<<<< only new line in new_box()
num_box=num_box+1;
...
Any questions? Please ask.
PS please try to enclose large hunk of coding in the "code" blocks as I
have here. Its under the "#" toolbutton on the "Posting" toolbar.