ajax Posted June 16, 2013 Posted June 16, 2013 I'm fairly new to Lua scripting so this might be a question with a simple answer: How do you debug scripts? The only way I've found is to put multiple env.info() statements in the script and then read the log file. Is there a better way?
FishBike Posted June 16, 2013 Posted June 16, 2013 That is one way I've done it. Another is to use trigger.action.outText to display text on the screen, which makes it easier to tell when in the mission something happened.
Grimes Posted June 16, 2013 Posted June 16, 2013 I use the mist stuff to show a table on screen or written to a file to get an idea of what is going on. I also make a "debug" function that will display assorted data via outText. Here is an example screenshot of something I used to check the fuel load and approx fuel consumtion rate. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
ajax Posted June 16, 2013 Author Posted June 16, 2013 Nice, Grimes. Is the multiline outtext capability part of Mist?
Grimes Posted June 16, 2013 Posted June 16, 2013 Not exclusively, but the same basic concept is used within mist to allow for multiple messages to be displayed on screen at the same time. This isn't exactly an example from mist but it gives you an idea of how a message would be formatted. Basically each entry below "-----------' would be a unique message meant to be displayed for a given amount of time. The code for multi-line is pretty simple. I add entries to a table and then display the table. The following code is how I displayed that: \n within a string is a new line. local display = {} display[#display + 1] = '\n Num Entries: ' display[#display + 1] = #empty display[#display + 1] = '\n Su-25T Player Data \n' display[#display + 1] = 'Current Fuel: ' display[#display + 1] = f16empty display[#display + 1] = ' Average: ' display[#display + 1] = emptyAvg display[#display + 1] = '\n Su25T Loaded Data \n' display[#display + 1] = 'Current Fuel: ' display[#display + 1] = f16full display[#display + 1] = ' Average: ' display[#display + 1] = fullAvg display[#display + 1] = '\n Su-25T No Payload \n' display[#display + 1] = 'Current Fuel: ' display[#display + 1] = tanker display[#display + 1] = ' Average: ' display[#display + 1] = avg3 trigger.action.outText(table.concat(display), 2) The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
Recommended Posts