The Struct:
 Code:
typedef struct { 
  int* opcode; 
  int* actor; 
  char* textstr[128];
} DIALOGUE;  // defines a struct type named "SPOT"


Using the Struct:
 Code:
var filehandle;

DIALOGUE* speechbank[10000];


The function:
 Code:
function loadtexts()
{
	var i = 0;	//Temp loop var
	var maxentries = 0;	//This is the number of dialogue entries to be read.
	filehandle = file_open_read("dialogue.txt"); // opens the file dialogue to read
	wait (100);
	maxentries = file_var_read(filehandle);		//how many entries are there in this file?
//		//Time for a loop
	while (i < maxentries)
{
	// First allocate the memory needed.
	speechbank[i] = (DIALOGUE*)malloc(sizeof(DIALOGUE));
	printf("Ok so far");
	speechbank[i].textstr = str_create("#128");
	// Then you can read the data and store it in the array.
	printf("Ok so far");
	speechbank[i].opcode = file_var_read(filehandle);
	printf("Ok so far");
	speechbank[i].actor = file_var_read(filehandle);
	printf("Ok so far");
	file_str_read(filehandle,speechbank[i].textstr); 
	printf("Ok so far kk"); 
	i++;
}
	file_close(filehandle); // closes the file 	
	return(1);
}


The data:
 Code:
3
1 0 This is a test
1 1 This is the second text
0 1 This is the third with close opcode


Also, if you have IRC or anything similar I would like to speak to you \:\)

Last edited by crumply; 04/18/08 00:24.