From 13dbc9c0fec28c1005d89ea30619f039b70090e1 Mon Sep 17 00:00:00 2001 From: Khopa Date: Thu, 20 Aug 2020 01:09:10 +0200 Subject: [PATCH] Added error message in mission when state file can not be written. --- resources/scripts/dcs_liberation.lua | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/resources/scripts/dcs_liberation.lua b/resources/scripts/dcs_liberation.lua index a9476fa4..5c594d35 100644 --- a/resources/scripts/dcs_liberation.lua +++ b/resources/scripts/dcs_liberation.lua @@ -34,11 +34,24 @@ write_state = function() } fp:write(json:encode(game_state)) fp:close() - --logger.info("Done writing DCS Liberation state") - --messageAll("Done writing DCS Liberation state.") + -- logger.info("Done writing DCS Liberation state") + -- messageAll("Done writing DCS Liberation state.") end -mist.scheduleFunction(write_state, {}, timer.getTime() + 10, 60, timer.getTime() + 3600) + +write_state_error_handling = function() + if pcall(write_state) then + -- messageAll("Written DCS Liberation state to "..debriefing_file_location) + else + messageAll("Unable to write DCS Liberation state to "..debriefing_file_location.. + "\nYou can abort the mission in DCS Liberation.\n".. + "\n\nPlease fix your setup in DCS Liberation, make sure you are pointing to the right installation directory from the File/Preferences menu. Then after fixing the path restart DCS Liberation, and then restart DCS.".. + "\n\nYou can also try to fix the issue manually by replacing the file /Scripts/MissionScripting.lua by the one provided there : /resources/scripts/MissionScripting.lua. And then restart DCS. (This will also have to be done again after each DCS update)".. + "\n\nIt's not worth playing, the state of the mission will not be recorded.") + end +end + +mist.scheduleFunction(write_state_error_handling, {}, timer.getTime() + 10, 60, timer.getTime() + 3600) activeWeapons = {} local function onEvent(event)