function initialize_save_data() { global.save_data = { player: { maxHP: 5, maxINK: 9, Credit: 0, abilities: { attack: false, accesscard : false, annotate: false, dash: false, wall_climb: false, double_jump: false }, corpse: { targetRoom: noone, xPos: -1, yPos: -1, droppedCredit: 0 }, }, world: { spRoom: "rTest1", spxPos: 192, spyPos: 864, activated_objects: {}, defeated_boss: {}, npc_flags: {} } }; initialize_dialogue(); var _npc_names = struct_get_names(global.dialogue); for(var i = 0; i < array_length(_npc_names); i++) { var _npc = _npc_names[i]; var _flags = [-1, 0]; for(var j = 2; j < array_length(_npc); j++) _flags[j] = -1; global.save_data.world.npc_flags[$ _npc] = _flags; } } function initialize_dialogue() { global.dialogue = { warden: [ [//idle "Have a nice day!" ], [//first [ "Good morning. " + "I haven't met you before! " + "Are you new here?", "By the way, my access card is lost, " + "so you probably can't leave the dorm right now. " + "I'm pretty sorry." ], [ "Tell me if you see it anywhere!" ] ], [//accesscard [ "Wow, thanks a lot! " + "Here, try this. ", "Oh, I can lend a card to you. " + "There may be other locked doors like these." ], [ "Are you leaving? " + "Remember to pay a visit when you have spare time. " + "I'm planning to sell some daily necessities." ] ] ] }; } function save_game_to_disk() { var _json_string = json_stringify(global.save_data); var _buffer = buffer_create(string_byte_length(_json_string) + 1, buffer_fixed, 1); buffer_write(_buffer, buffer_string, _json_string); buffer_save(_buffer, global.save_filename); buffer_delete(_buffer); if global.developer_mode show_debug_message("The game has been saved to " + global.save_filename); } function load_game_from_disk() { if !file_exists(global.save_filename) return; var _buffer = buffer_load(global.save_filename); var _json_string = buffer_read(_buffer, buffer_string); buffer_delete(_buffer); var _loaded_data = json_parse(_json_string); global.save_data = _loaded_data; room_goto(asset_get_index(global.save_data.world.spRoom)); global.in_game_manager = icl(oInGameManager); } function self_check_activated() { return struct_exists(global.save_data.world.activated_objects, uuid) } function autosave() { var _list = global.save_data.world.activated_objects; _list[$ uuid] = true; save_game_to_disk(); }