I am making a dialogue system for my game and I am trying to load my text from a file. The file contains
the number of rows
opcode(number) actor(number) text(characters)
So I made a struct:
typedef struct {
int opcode;
int actor;
char textstr[100];
} DIALOGUE; // defines a struct type named "SPOT"
and then in my script, a bunch of them
DIALOGUE* speechbank[10000];
and then wrote a function to populate them from the file. Except I get an invalid pointer error!
Here's my function
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("%APPDIR%//dialogue.txt"); // opens the file dialogue to read
statustext = "File opened";
wait (100);
maxentries = file_var_read(filehandle); //how many entries are there in this file?
//Time for a loop
while (i < maxentries)
{
speechbank[i].opcode = file_var_read(filehandle);
speechbank[i].actor = file_var_read(filehandle);
file_str_read(filehandle,speechbank[i].textstr);
i++;
}
file_close(filehandle); // closes the file
}
Any help demisifying this one would be great.