Saving and loading of structs

Posted By: Fenriswolf

Saving and loading of structs - 01/24/08 08:23

Hello,

according to the manual game_save() can't save pointers in lite-C:
Quote:

SV_POINTERS
saves all pointers (C-Script only). In lite-C, use handles for saving references to objects.




How do I save user defined structs then?
Obviously, handle() works with predefined structs only.


Thanks
Posted By: ultranet

Re: Saving and loading of structs - 02/15/08 15:38

Yes, you can save struct.

Before you call game_save(), you must call the add_struct() to add an existing struct to it.

Example:
typedef struct STRUCTURE
{
var a;
int b;
}STRUCTURE;

STRUCTURE* mystruct={a=1; b=2;}

....

void main()
{
...
add_struct(mystruct,sizeof(STRUCTURE));
...
...
game_save("SAVE",1,SV_STRUCT);
}
© 2024 lite-C Forums