ID:150805
 
okay, i know howta create a list, or array, and add stuff, ect.. but heres my problem. i need to create a list of astructure liek things(kinda similiar to a linke(or double-linked) list in c/c++). in c/c++ we did this:


struct char_data {
[tab] int health;
[tab] int max_health;
//zillions of other variables
[tab] char_data *next;
[tab] char_data *prev;
};

any way, that struct won't work cuz it is not odne right, but it gets my point across. i need to make somthing similiar to it in DM. like a list that has, say 5 things. and each one has it own seperate variable. you understand? and then i need to be able to add, or subract one, and walk through it(wich shoudln't be hard)

i'm probably making no sense at all, but if you can help in nay way, feel free to post while i am trying to figure it out.
On 7/23/01 6:26 pm XgavinX wrote:
struct char_data {
[tab] int health;
[tab] int max_health;
//zillions of other variables
[tab] char_data *next;
[tab] char_data *prev;
};

The objects in DM are classes, a.k.a structures
You are are dead set on using a list like this, you can make a datum.

Datum are derived from the root, so there should NOT be a tab in front of the first line of this code:

char_data
var
health = 0
max_health = 0
// et. al.
char_data/next
char_data/prev
In response to Shadowdarke
On 7/23/01 7:25 pm Shadowdarke wrote:
On 7/23/01 6:26 pm XgavinX wrote:
struct char_data {
[tab] int health;
[tab] int max_health;
//zillions of other variables
[tab] char_data *next;
[tab] char_data *prev;
};

The objects in DM are classes, a.k.a structures
You are are dead set on using a list like this, you can make a datum.

Datum are derived from the root, so there should NOT be a tab in front of the first line of this code:

char_data
var
health = 0
max_health = 0
// et. al.
char_data/next
char_data/prev


thank you, i really appreciate it.
In response to XgavinX
one more quick, Q. if i wanted to add a new one, how woudl I do it? same as using new()?
In response to XgavinX
On 7/23/01 7:37 pm XgavinX wrote:
one more quick, Q. if i wanted to add a new one, how woudl I do it? same as using new()?

Yep,
var/char_data/C = new()
will create a new char_data called C. I'll leave it up to you to walk the list and insert it in the right place ;)
In response to Shadowdarke
On 7/23/01 7:56 pm Shadowdarke wrote:
On 7/23/01 7:37 pm XgavinX wrote:
one more quick, Q. if i wanted to add a new one, how woudl I do it? same as using new()?

Yep,
var/char_data/C = new()
will create a new char_data called C. I'll leave it up to you to walk the list and insert it in the right place ;)

thanks. i'm sure i can figure the rest out. i really appreciate it.