pet333r / pw-dev_script

Script for DCS World
http://pw-developer.com/
GNU Lesser General Public License v3.0
112 stars 11 forks source link

Problem with log files #28

Open srobert72 opened 2 years ago

srobert72 commented 2 years ago

Hello,

First of all thank you for your work. I use DCS UFC and DCS Nav. I have a little problem using the pw-dev_script script with other script like DCS Bios. I have a script that writes well to its log file when used alone. But if I launch it at the same time as DCS UFC then it can no longer write to its log file.

My Export.lua file only contains:

dofile(lfs.writedir()..[[Scripts\Export-SR.lua]])
pcall(function() local pw=require('lfs');dofile(pw.writedir()..[[Scripts\pw-dev_script\ExportInit.lua]]); end,nil);

My script uses its logs like this:

ExportSR.export_file_livedata = io.open(lfs.writedir().."Logs/Export-LiveData-SR.log", "w")
ExportSR.export_file_livedata:write(string.format("aircraft: %s\n\n", ExportSR.aircraft_name))

The second line fails when using DCS UFC with error:

2022-07-02 08:31:25.895 ERROR   Lua::Config: Call error LuaExportStart:[string "C:\Users\Stephane\Saved Games\DCS\Scripts\Export-SR.lua"]:93: attempt to index field 'export_file_livedata' (a nil value)
stack traceback:
    [C]: ?
    [string "C:\Users\Stephane\Saved Games\DCS\Scripts\Export-SR.lua"]:93: in function 'LuaExportStart'
    [string "C:\Users\Stephane\Saved Games\DCS\Scripts\pw-dev_script\ExportInit.lua"]:65: in function <[string "C:\Users\Stephane\Saved Games\DCS\Scripts\pw-dev_script\ExportInit.lua"]:59>.

Do you have an idea ? Thanks