create one struct child of ENTITY

Posted By: amadeu

create one struct child of ENTITY - 09/21/07 20:52

Hallo

I would like to create one struct child of ENTITY because I want to create more parameters in the ENTITY.
I tryed create this struct but did nor work:
typedef struct OBJECTS {
var number;
char *node;
struct ENTITY* parent;
} OBJECTS;

Some body could help me?
Posted By: TWO

Re: create one struct child of ENTITY - 09/21/07 22:04

typedef struct
{
var number;
char *node;
ENTITY* parent;
} OBJECTS;
Posted By: amadeu

Re: create one struct child of ENTITY - 09/22/07 08:17

hi

I created this struct but the follow code did not work becouse my Struct did not inherit from ENTITY: I would like tho create one struct with more parameters from Entity struct.
typedef struct
{
var number;
char *node;
ENTITY* parent;
} OBJECTS;

OBJECTS* av1;
void main()
{
video_mode = 7;
video_screen = 2;
level_load("VAH.wmb");
wait(2);
av1 = ent_create("av2all.mdl", vector(-175,101,0), NULL);
av1.number = 1;
av1.pan = 180; /// donīt work /////
}

the error said " pan is not a member from OBJECTS"

What is wrong in my code?
Posted By: TWO

Re: create one struct child of ENTITY - 09/22/07 08:42

There's no native inherition in Lite-C, you have to use sth like this:

Code:

typedef struct
{
var number;
char *node;
ENTITY* parent;
} OBJECTS;

OBJECTS* av1;
void main()
{
video_mode = 7;
video_screen = 2;
level_load("VAH.wmb");

wait(2);

av1 = new(OBJECTS); // Reserve memory for the struct

av1.parent = ent_create("av2all.mdl", vector(-175,101,0), NULL);
av1.number = 1;
av1.parent.pan = 180;
}


Posted By: amadeu

Re: create one struct child of ENTITY - 09/22/07 08:53

Hi

There is one problem:

av1 = new(OBJECTS); // Reserve memory for the struct

The "new" function did not work.

How is the code for "new" function?
Posted By: TWO

Re: create one struct child of ENTITY - 09/22/07 08:57

Ah sorry, I'm using the macros stated here: http://www.coniserver.net/ubbthreads/showflat.php/Cat/0/Number/778566/an/0/page/0
Posted By: amadeu

Re: create one struct child of ENTITY - 09/22/07 09:11

Ok

thx,

It works.
© 2024 lite-C Forums