#include <acknex.h>
typedef struct {
int opcode;
int actor;
STRING* textstr;
} DIALOGUE; // defines a struct type named "SPOT"
var filehandle;
DIALOGUE* speechbank[10000];
function loadtexts()
{
var i = 0; //Temp loop var
var maxentries = 0; //This is the number of dialogue entries to be read.
filehandle = file_open_game("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));
speechbank[i].textstr = str_create("#128");
// Then you can read the data and store it in the array.
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
return(1);
}
void main()
{
loadtexts();
}