AKA_Clutter Posted October 8, 2021 Posted October 8, 2021 I have the following long line of test I would like to print via a script. "There is a column of M2A2 Bradley IFVs in front of you. Fly through the center of them and that will point you towards the hot LZ area. Once you are within 1 mile of the LZ, two flares will be popped marking the LZ. As you approach, more flares will be popped at 10 and 20 seconds. Additionally, there is a burning HMMWV Jeep near the hot LZ" I know how to do it, as long as all of the text is on a single line. I also know you can output text in using the multi line format of print [[ "A multi-line text message. However each line appears on a line when printed"]] I think you could do this by assigning portions of the sentence to temporary variables and then concatenating the variables (e.g., print (a .. b .. c), but that seems like a inefficient way of doing it. So my question is there a way to break this up so that all the text doesn't have to appear on a single line? ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Grimes Posted October 8, 2021 Posted October 8, 2021 Some of the special characters for formatting in lua work in DCS. Specifically \n inserts a new line. If you have a known string you can just add \n anywhere you want in there. Concatenating a string together also works well, either with \n being its own value or part of a string. If it is going to be more than half a dozen values I don't like doing a .. b .. c as it is just easier add everything to a table and then use table.concat(m) to build the string. Supposedly it is also faster or more efficient. So for example this is copied from a mission that displays target coordinates for an objective. Iterates the list of coordinates and adds a new line if there is another coordinate to display. if nMsg.tgtCoords then m[#m+1] = findFile(s, 'Standby for coordinates') m[#m+1] = ', ' m[#m+1] = findFile(s, 'Over') m[#m+1] = '.' m[#m+1] = '\n\n' m[#m+1] = 'Target Information and Coordinates \n' for j = 1, #nMsg.tgtCoords do m[#m+1] = nMsg.tgtCoords[j] if j < #nMsg.tgtCoords then m[#m+1] = '\n' end end m[#m+1] = '\n\n' end 1 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
AKA_Clutter Posted October 9, 2021 Author Posted October 9, 2021 (edited) Grimes - Thanks for the reply. I still learning and don't know much about tables, yet. I didn't express my question very well at all. It is more of an editor issue. If I enter a wall of text in the DCS ME MESSAGE action, it wraps around and easy to see. If I enter the same text in a DCS script, it all appears on one line in the editor. THAT makes it difficult for me to read and edit. The example below would appear on a single line in the editor. trigger.action.outTextForGroup(Helo_Group_ID, "There is a column of M2A2 Bradley IFVs in front of you. Fly through the center of them and that will point you towards the hot LZ area. Once you are within 1 mile of the LZ, two flares will be popped marking the LZ. As you approach, more flares will be popped at 10 and 20 seconds. Additionally, there is a burning HMMWV Jeep near the hot LZ") So my question is if there is a way to break this up so that it is easier to read in the editor. I thin I found the answer to my question in lua, but haven't yet tested in DCS. Here is what I found print ("this is the first part on this one line. " .. "This is to see if this is on the same line." .. " And a third line just to see if this is the limit") The results of this is this is the first part on this one line. This is to see if this is on the same line. And a third line just to see if this is the limit Which solves my issue. Now to see if it works in DCS. That or see if the IDEs I use has something like word wrap in notepad. This doesn't makes sense as it would me very confusing. NOTE - This works in Lua 5.4.2, not sure about 5.3.1 or earlier versions. Again, thanks for the help. I know I will use it in the future once I learn about tables and now to read files from within LUa/DCS. Edited October 9, 2021 by AKA_Clutter ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Grimes Posted October 9, 2021 Posted October 9, 2021 Oh something like notepad++. Most of them do have word wrap but it is a factor of the size of text and monitor resolution. You could have over 200 characters on a line easily unless you make the window take up less horizontal space. Just combining it like you did there works best. 1 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
AKA_Clutter Posted October 9, 2021 Author Posted October 9, 2021 1 hour ago, Grimes said: Just combining it like you did there works best. Do you mean as a single line/set of text rather than doing something fancy. Also, I have been using Eclipse LDT and VS Code as IDE for learning Lua. I do have Notepad++ as well. Will have to look into them for word wrapping ability. And thanks once again. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
AKA_Clutter Posted October 9, 2021 Author Posted October 9, 2021 @Grimes Thanks once again. I have a history (and a LONG one) of making things more difficult than necessary. I found the "Word Wrap" feature ( and a feature to display line numbers. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
UncleZam Posted October 9, 2021 Posted October 9, 2021 T 18 hours ago, AKA_Clutter said: I thin I found the answer to my question in lua, but haven't yet tested in DCS. Here is what I found print ("this is the first part on this one line. " .. "This is to see if this is on the same line." .. " And a third line just to see if this is the limit") This is usually the preferred way in programming. Coding conventions often restrict the max line length to 80-160 chars to make it readable in all editors (and without wrapping or scrolling). 1
AKA_Clutter Posted October 10, 2021 Author Posted October 10, 2021 5 hours ago, UncleZam said: T This is usually the preferred way in programming. Coding conventions often restrict the max line length to 80-160 chars to make it readable in all editors (and without wrapping or scrolling). Thanks! That is good to know. Just starting my "learn to program" effort. Or should I say starting for the umphteen time. 1 ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
HC_Official Posted October 11, 2021 Posted October 11, 2021 my_text = [[ this is line 1 this is line 2 this is line 3 ]] lua allows multi line text as shown above No more pre-orders Click here for tutorials for using Virpil Hardware and Software Click here for Virpil Flight equipment dimensions and pictures. .
AKA_Clutter Posted October 11, 2021 Author Posted October 11, 2021 6 hours ago, HC_Official said: my_text = [[ this is line 1 this is line 2 this is line 3 ]] lua allows multi line text as shown above Thanks. I knew of this, but each line within [[ ...]] prints on a separate line. I was looking for something that appeared on separate lines in the editor but appeared on the same line when printed out in DCS text window. With that said, it is nice to know all the ways/formats of the print statement. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Wizxrd Posted October 11, 2021 Posted October 11, 2021 (edited) If I’m understanding right, you want to be able to write out individual lines in your script, but want them all wrapped into a single message that appears in game. If so this might be what your looking for: local messageList = { "here is the first line, ", "here is the second line, ", "here is the third line.", } local inGameMsg = table.concat(messageList) trigger.action.outText(inGameMsg, 15) This is just a super basic example of how you could go about doing it, give it a test and let me know if it’s what you were looking for Edited October 11, 2021 by Wizxrd
AKA_Clutter Posted October 11, 2021 Author Posted October 11, 2021 @Wizxrd Thanks! I haven't yet learned much about tables, but will give this a shot. This should give me a different method to do what I am wanting to do. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
AKA_Clutter Posted October 11, 2021 Author Posted October 11, 2021 1 hour ago, Wizxrd said: If I’m understanding right, you want to be able to write out individual lines in your script, but want them all wrapped into a single message that appears in game. If so this might be what your looking for: local messageList = { "here is the first line, ", "here is the second line, ", "here is the third line.", } local inGameMsg = table.concat(messageList) trigger.action.outText(inGameMsg, 15) This is just a super basic example of how you could go about doing it, give it a test and let me know if it’s what you were looking for I haven't tried this yet, but have a question. In the message I want to print out it will also contain variables concatenated in the middle of the text. Below is an example of what it is I'm trying to do. Bolded text are the variables. trigger.action.outTextForGroup(Helo_Group_ID, '\n\n' .. Player_Callsign .. 'You ' .. 'are now more than 1 mile from the hot LZ.\n\nYou can try again by ' .. 'returning to the hot LZ location. The results of your last attempt ' .. 'are:\n\nYour time ' .. Flag_Time .. ' seconds versus the goal time ' .. 'of ' .. Goal_Time .. ' seconds.' .. 'n\n Your Avg Speed Goal Avg Speed' .. '\n ' .. Avg_kn .. ' kn' .. ' ' .. GAvg_kn .. ' k' .. 'n\n ' .. Avg_mph ..' mph' .. ' ' .. GAvg_mph .. ' mph' .. '\n ' .. Avg_kph .. ' kph' .. ' ' .. GAvg_kph .. ' kmh', 15) ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
cfrag Posted October 11, 2021 Posted October 11, 2021 (edited) That will work as long as the variables are of type string or number. Bool and Table won't work, nor variables that are nil or undefined. Edited October 11, 2021 by cfrag
AKA_Clutter Posted October 11, 2021 Author Posted October 11, 2021 21 minutes ago, cfrag said: That will work as long as the variables are of type string or number. Bool and Table won't work, nor variables that are nil or undefined. Thanks. ---------------- AKA_Clutter Win 10 Pro, Intel i7 12700k @4.6 GHz, EVGA RTX 3080 FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, HP Reverb G2, TM Warthog HOTAS with Virpil warBRD base, MFG Rudder Pedals, Virpil TCS Rotor Base with AH-64Dcollective, TrackIR 5 Pro w/Vector Expansion, PointCTRL.
Recommended Posts