62 lines
1.9 KiB
Plaintext
62 lines
1.9 KiB
Plaintext
/*
|
|
Copyright (c) 2018 Muresan Vlad Mihail
|
|
Contact Info muresanvladmihail@gmail.com murii@tilde.team
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely, subject to the following restrictions:
|
|
|
|
The origin of this software must not be misrepresented; you must not
|
|
claim that you wrote the original software. Shall you use this software
|
|
in a product, an acknowledgment and the contact info(if there is any)
|
|
of the author(s) must be placed in the product documentation.
|
|
This notice may not be removed or altered from any source distribution.
|
|
|
|
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT.
|
|
IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT,
|
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
import libc {...}
|
|
|
|
|
|
priv data:char* = """
|
|
player_coins=20;
|
|
player_life=0;
|
|
player_x=200;
|
|
player_y=300;
|
|
current_level=3;
|
|
""";
|
|
|
|
|
|
func main(argc:int, argv:char**):int {
|
|
save:save_data;
|
|
save_data_init(&save, "player.stat"); //Creates and overrides file "player.stat"
|
|
|
|
keys:char[1][16];
|
|
strcpy(keys[0],"player_bombs");
|
|
|
|
values:char[1][16];
|
|
strcpy(values[0],"120");
|
|
|
|
data2:char* = save_data_serialize((:char*)keys[0], (:char*)values[0]);
|
|
save_data_write(&save, data2, false);
|
|
|
|
save_data_write(&save, data2, false);
|
|
|
|
save_data_write(&save, data, true);
|
|
|
|
save_data_write(&save, data2, false);
|
|
|
|
// Read back what we have saved
|
|
save_data_read(&save);
|
|
|
|
for (i := 0; i < save.total; i++) {
|
|
printf("Pair: %s %s \n", save.keys[i], save.values[i]);
|
|
}
|
|
|
|
free(data2);
|
|
return 0;
|
|
}
|
|
|