-- called from engine! function on_key_press(dik,bind) if (level.present() and db.actor) then if (bind == key_bindings.kQUICK_SAVE) then return action_quick_save() elseif (bind == key_bindings.kQUICK_LOAD) then return action_quick_load() end SendScriptCallback("level_input_on_key_press",dik,bind) end return false end function action_quick_save() local lname = level.name() if not (db.actor:alive()) then return false end if (alife_storage_manager.get_state().enable_campfire_mode) and (level_weathers.valid_levels[level.name()]) then -- return true to stop the function from working if not (_G.ALLOW_SAVING) then SetHudMsg("st_you_cant_save",4) return true end end if db.actor then if (lname == "l03u_agr_underground") or (lname == "l04u_labx18") or (lname == "l08u_brainlab") or (lname == "l12u_control_monolith") or (lname == "l10u_bunker") or (lname == "l13u_warlab") or (lname == "jupiter_underground") or (lname == "labx8") or (lname == "l12u_sarcofag") then end end if savegame_conditions.check_and_apply("st_ui_save") then return true end if savegame_timer.check_and_apply("st_ui_save") then return true end -- if game isn't already paused, then force a pause here -- local force_pause -- if not (device():is_paused()) then -- device():pause(true) -- force_pause = true -- end -- get list of savegames with most recently modified first. local flist = getFS():file_list_open_ex("$game_saves$", bit_or(FS.FS_ListFiles,FS.FS_RootOnly),"*".. ui_load_dialog.saved_game_extension) local f_cnt = flist and flist:Size() or 0 local inc = 0 if (f_cnt > 0) then flist:Sort(FS.FS_sort_by_modif_down) for it=0, f_cnt-1 do local file_name = flist:GetAt(it):NameFull():sub(0,-6):lower() -- grab last modified quicksave increment count local d = tonumber(string.match(file_name,game.translate_string("quicksave") .. " " .. "(%d+)")) if (d) then inc = d break end end end inc = inc >= axr_main.config:r_value("mm_options","quicksave_cnt",2,5) and 1 or inc + 1 get_console():execute("save " .. (user_name() or "") .. " - " .. game.translate_string("quicksave") .. " " .. inc) if (alife_storage_manager.get_state().enable_timer_mode) then savegame_timer.timer_reset() -- reset timer end -- if (force_pause) then -- device():pause(false) -- end return true end function action_quick_load() local flist = getFS():file_list_open_ex("$game_saves$", bit_or(FS.FS_ListFiles,FS.FS_RootOnly),"*".. ui_load_dialog.saved_game_extension) local f_cnt = flist and flist:Size() or 0 if (f_cnt > 0) then flist:Sort(FS.FS_sort_by_modif_down) for it=0, f_cnt-1 do local file_name = flist:GetAt(it):NameFull():sub(0,-6):lower() -- grab last modified quicksave if (string.match(file_name,".*" .. "% - " .. game.translate_string("quicksave") .. " " .. "(%d+)")) then level.remove_cam_effector(50001) level.remove_cam_effector(38455) level.remove_cam_effector(80643) get_console():execute("load " .. file_name) return true end end end return true end