//test add_struct
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////
typedef struct PERSO{
int age;
char* name;
char* nickname;
} PERSO;
PERSO* Person;
PERSO* new_person()
{
PERSO* new = sys_malloc(sizeof(PERSO));
memset(new,0,sizeof(PERSO));
new->nickname = "Toto_2"; // test name
new->age = 18;
add_struct(new,sizeof(PERSO));
return new;
}
TEXT* test =
{
strings = 2;
pos_x = 10;
pos_y = 10;
flags= SHOW;
}
function save()
{
if(game_save("save",1,SV_ALL) <= 0)
{
error("save not found");
}else{
error("save success");
}
}
function load()
{
if(game_load("save",1) <= 0)
{
error("Load save error");
sys_exit(NULL);
}else{
error("loaded save success");
}
}
function quit()
{
sys_exit(NULL);
}
function send()
{
Person.nickname = "Toto";
}
function main()
{
video_mode = 7;
video_depth = 32;
video_screen = 2;
level_load(NULL);
on_f2 = send ;
on_f3 = save;
on_f4 = load;
on_esc = quit;
on_close = quit;
Person = new_person();
while(1) {
str_cpy((test.pstring)[0], _str(Person.nickname));
wait(1);
}
}