Jump to content

Writing to log file


firefly2442
 Share

Recommended Posts

I'm having trouble using MIST and writing to the log file. I set the initialization script for mist.lua and I set Do Script File for my main.lua file to run after 2 seconds as recommended. I have the following code in main.lua:

 

do

   local function checktriggers()
   
       mist.scheduleFunction(checktriggers, {}, timer.getTime() + 5)
   end


   local function init()
       --runs once to initialize vars
       
       env.info("About to start smoke", true)
       trigger.action.smoke(smoke.point, 1)
       env.info("Smoke pos: "..tostring(smoke.point), true)
   end

   env.info("Scheduling functions", true)
   mist.scheduleFunction(init, {}, timer.getTime() + 2)
   mist.scheduleFunction(checktriggers, {}, timer.getTime() + 5)
end

However, after the mission, I open up the log file and I don't see anything logged. I tried exiting DCS (thinking it needed to flush the file) but that didn't help. Does anyone have any ideas? Do I need to compile the mission first or something? I'm just running it through the editor.

Link to comment
Share on other sites

If you are using 1.5 you can't use the initialization script file because it doesn't work. You have to put mist into a do script file via triggers.

 

The true variable isn't needed, its only for displaying a message box each time it will occur, which gets annoyed fast :)

 

trigger.action.smoke(smoke.point, 1) won't work because smoke.point isn't declared as a table anywhere, granted you could have declared it somewhere else, but that leads me to another point...

 

env.info("Smoke pos: "..tostring(smoke.point), true) won't work because tostring() will not display a table that is readable as text. You can use another mist function to get that functionality though: env.info(mist.utils.tableShow(smoke.point))

 

As for why they aren't showing up, make sure you are checking the right DCS.log file. With the file open in notepad++ you should get a message if you alt-tab back into np++ saying that "DCS.log has been modified, would you like to reload it?". Otherwise you can manually reload the file via File>Reload from Disk

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

I think MIST is now loading (after removing from initialization). It has this in the log.

 

SCRIPTING: Mist version 4.0.55 loaded.

"main.lua" is still setup to run after 2 seconds. However, I'm not getting anything from my script logged.

 

--doesn't work
env.info("Hello")

--doesn't work
do

   local function checktriggers()
   
       mist.scheduleFunction(checktriggers, {}, timer.getTime() + 5)
   end


   local function init()
       --runs once to initialize vars
       
       --env.info("About to start smoke", true)
       --trigger.action.smoke(smoke.point, 1)
       --env.info("Smoke pos: "..tostring(smoke.point), true)
   end

   env.info("Scheduling functions")
   mist.scheduleFunction(init, {}, timer.getTime() + 2)
   mist.scheduleFunction(checktriggers, {}, timer.getTime() + 5)
end

Link to comment
Share on other sites

To verify the main script file is running I'd simply add a trigger to display text along with the do script file trigger action. My best guess is you might be using something like Mission Start>Time More 2 > Do Script File(main.lua), which won't work. Change it to Once>Time More. Again thats just a guess, but its a common mistake that is made.

  • Like 1

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Mission Start is like using the "events" that are available with Once and Continuous trigger type. However as an event it can only occur once with the time of it occurring at exactly 0. So Time More doesn't work at all with it.

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Do you have any issues with the mission not reloading your modified LUA scripts? I just had to go into the trigger and "re-open" the same file via the editor in order to get changes that I made in NP++ to work in the mission. Seems to be the only way I can get it working.

 

Sorry for all the questions, thanks for responding. :)

Link to comment
Share on other sites

Thats how it works. When you set a sound file, script, or image as part of a trigger or briefing you are embedding the file directly into the mission file. So it isn't referencing it on your hard-drive. To update the file within the mission, you must re-load it in the mission editor.

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...