horus0129 Posted November 11, 2013 Posted November 11, 2013 (edited) Hi, need some help about a text msg display script here. I have 4 active aircrafts, and want to check their status like this way - flag 1~4 are for checking each aircrafts' status(flag 1 is for AC 1, flag 2 is for AC 2....), values of flag 11~14 are status of each aircrafts, so if the checking flag is true, message will display the value of the status flag, but false, will display 'NA' For example, if the condition is flag 1 is true, value of flag 11 is 12 flag 2 is false, value of flag 12 is 32 flag 3 is true, value of flag 13 is 21 flag 4 is false, value of flag 14 is 15 then the text message will display all aircrafts' values at once AC 1 - 12 AC 2 - NA AC 3 - 21 AC 4 - NA I think it will be possible to do this via lua scripting, but don't have any idea how. Help me guys! Edited November 11, 2013 by horus0129
Zayets Posted November 11, 2013 Posted November 11, 2013 When do you want to check the status of each aircraft? If you check the status in a trigger then at the action you simply display the messages you posted in the last part, no need for a script. [sIGPIC]OK[/sIGPIC]
number3 Posted November 11, 2013 Posted November 11, 2013 To check the value of the flag via scripting you use http://wiki.hoggit.us/view/Part_1 number function trigger.misc.getUserFlag(string userFlagName) If you want to continuously check their status and act upon it, you may want to use this: http://wiki.hoggit.us/view/ScheduleFunction -- The following would schedule mist.groupToRandomZone to call and move 'myGroup' to a random point in zone every 900 seconds up till 3600 seconds after the function was first called. do mist.scheduleFunction(mist.groupToRandomZone, {'myGroup', 'myZone'}, timer.getTime() + 10, 900, timer.getTime() + 3600) end But all of this can be done in the Missions Editor. More information is required as to when do you want to check the status and what triggers it. 314-я смешанная авиационная дивизия 314th Mixed Aviation Division: The "Fighting Lemmings"- Forums: http://314thsquadron.enjin.com/ - ED Forum Group: http://forums.eagle.ru/group.php?groupid=119
horus0129 Posted November 11, 2013 Author Posted November 11, 2013 When do you want to check the status of each aircraft? If you check the status in a trigger then at the action you simply display the messages you posted in the last part, no need for a script. I want all values of the flags and true or false conditions to be displayed in a single msg field. This msg will be activated at any time through F10 radio menu.
Zayets Posted November 12, 2013 Posted November 12, 2013 (edited) OK, then if you have added your radio item for F10 menu you can do this - or something similar - at the Action side (Do Script) of the trigger : local statusMsg = '' for i = 1, 4 do if trigger.misc.getUserFlag(i) == true then statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(i) else statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A' end end trigger.action.outText(statusMsg,10) There may be an issue because a flag with a value can be considered true but that can be corrected. Try this first. LE: scratch that, I see that you want to display other flags and not 1-4. Luckily the notation you chose is pretty similar so you will have to change it like that local statusMsg = '' for i = 1, 4 do j = '1'..i if trigger.misc.getUserFlag(i) == true then statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(j) else statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A' end end trigger.action.outText(statusMsg,10) Edited November 12, 2013 by Zayets [sIGPIC]OK[/sIGPIC]
horus0129 Posted November 12, 2013 Author Posted November 12, 2013 OK, then if you have added your radio item for F10 menu you can do this - or something similar - at the Action side (Do Script) of the trigger : local statusMsg = '' for i = 1, 4 do if trigger.misc.getUserFlag(i) == true then statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(i) else statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A' end end trigger.action.outText(statusMsg,10) There may be an issue because a flag with a value can be considered true but that can be corrected. Try this first. LE: scratch that, I see that you want to display other flags and not 1-4. Luckily the notation you chose is pretty similar so you will have to change it like that local statusMsg = '' for i = 1, 4 do j = '1'..i if trigger.misc.getUserFlag(i) == true then statusMsg = statusMsg .. '\nAC ' .. i .. '-'..misc.getUserFlag(j) else statusMsg = statusMsg .. '\nAC ' .. i.. '- N/A' end end trigger.action.outText(statusMsg,10) Thanks Zayets! I'll try that soon.
Wrecking Crew Posted November 12, 2013 Posted November 12, 2013 This doc has a section at the bottom about displaying flag values -- https://drive.google.com/file/d/0BwHk38uryutrMXZBWlk5ZjdRbjQ/edit?usp=sharing WC Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.
Recommended Posts