Advertisement
morrtz

SaveMission

Oct 26th, 2013
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.19 KB | None | 0 0
  1. function save_mis(text)
  2.     local fdir = lfs.writedir() .. [[Logs\Save_tool\]] .. text
  3.     local f,err = io.open(fdir,"w")
  4.         if not f then
  5.             local errmsg = 'Error: Need to create new folder in the Logs folder with the name' .. 'Save_tool . sample: C:\Users\youname\Saved Games\DCS\Logs\Save_tool'
  6.             trigger.action.outText(errmsg, 10)
  7.             return print(err)
  8.         end
  9.  
  10.     f:write('ALIVEDB = \n')
  11.     f:write(mist.utils.oneLineSerialize(mist.DBs.aliveUnits))
  12.     f:close()
  13.     timer.scheduleFunction(save_mis, name_miz .. timer.getTime() .. '.lua', timer.getTime() + 60)
  14.     trigger.action.outText('File saved to: ' .. lfs.writedir() .. [[Logs\Save_tool\]] .. text, 15)
  15. end
  16.  
  17. if env.mission then
  18.     if env.mission.sortie then
  19.         name_miz = env.mission.sortie
  20.         else
  21.         name_miz = 'save_mission_default.txt'
  22.     end
  23. else
  24.     name_miz = 'save_mission_default.txt'
  25. end
  26.  
  27. timer.scheduleFunction(save_mis, name_miz .. timer.getTime() .. '.lua', timer.getTime() + 60)
  28.  
  29. trigger.action.outText('End Load Save Tool' , 15)
  30. if lfs and io then
  31. else
  32.     local errmsg = 'Error: insufficient permission you must disable the sanitization of the io and lfs libraries in ./Scripts/MissionScripting.lua'
  33.     trigger.action.outText(errmsg, 10)
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement