pdmarsh Posted December 26, 2015 Posted December 26, 2015 If possible, I would like to calculate percentage of mission completion by dividing the value of one flag into that of another flag. Flag 1, for example, would be the total number of groups to be destroyed, while Flag 2 would count up as any given unit gets destroyed. Dividing Flag 2 by Flag 1 would give the percentage achieved. Is it possible to script something like this? In this particular multiplayer mission, the total number of things to be accomplished will vary depending on the number of players, so the value of Flag 1 will vary accordingly. Flag 2 will always simply count up as any given objective is achieved. At a certain point, the mission will end and the percent accomplished would be calculated. Thanks, Paul [sIGPIC][/sIGPIC] DCSFlightpanels - Utility for Saitek Pro Flight Panels for DCS World Custom Saitek B.I.P. Tiles for DCSFlightpanels Saitek Switch Panel Template for DCSFlightpanels
mwd2 Posted December 26, 2015 Posted December 26, 2015 You can extract the FLAG value with trigger.misc.getUserFlag(x) with x FLAG and trigger.action.outText(String, time) will display a String. Playing: DCS World Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof. Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh Ghost0815
pdmarsh Posted December 26, 2015 Author Posted December 26, 2015 @mwd2 -- Thank you for the function code. I'm having a little trouble finding examples of how to apply it. What I would need to do is the following: trigger.misc.getUserFlag(2) / trigger.misc.getUserFlag(1) = ? trigger.action.outText(?, time) I think I'm getting close to the answer, but I am very new to scripting and have a lot to learn. Thanks, Paul [sIGPIC][/sIGPIC] DCSFlightpanels - Utility for Saitek Pro Flight Panels for DCS World Custom Saitek B.I.P. Tiles for DCSFlightpanels Saitek Switch Panel Template for DCSFlightpanels
mwd2 Posted December 26, 2015 Posted December 26, 2015 Here a sample for the Trigger ONCE() // Time More(3600) // Do Script( a = trigger.misc.getUserFlag('1') b = trigger.misc.getUserFlag('2') c = b/a trigger.action.outText('Value:' ..tostring(c) ,20) ) FLAG #1 and FLAG #2 will check after 60min. and the value of FLAG 2 / FLAG 1 will display for 20 sec. Playing: DCS World Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof. Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh Ghost0815
pdmarsh Posted December 26, 2015 Author Posted December 26, 2015 Here a sample for the Trigger... @mwd2 -- Thank you very much! This is extremely helpful. Sincerely, Paul [sIGPIC][/sIGPIC] DCSFlightpanels - Utility for Saitek Pro Flight Panels for DCS World Custom Saitek B.I.P. Tiles for DCSFlightpanels Saitek Switch Panel Template for DCSFlightpanels
ajax Posted December 26, 2015 Posted December 26, 2015 You may want to ensure 'a' is non-zero before the division operation.
mwd2 Posted December 26, 2015 Posted December 26, 2015 if a == 0 then trigger.action.outText('All done.' ,20) else c = b/a trigger.action.outText('Value:' ..tostring(c) ,20) end Playing: DCS World Intel i7-13700KF, 64GB DDR5 @5600MHz, RTX 4080 ZOTAC Trinity, WIN 11 64Bit Prof. Squadron "Serious Uglies" / Discord-Server: https://discord.gg/2WccwBh Ghost0815
pdmarsh Posted December 27, 2015 Author Posted December 27, 2015 I got a chance to test this code in a mission this evening with my flying group and it worked like a charm. Thanks again. Paul [sIGPIC][/sIGPIC] DCSFlightpanels - Utility for Saitek Pro Flight Panels for DCS World Custom Saitek B.I.P. Tiles for DCSFlightpanels Saitek Switch Panel Template for DCSFlightpanels
Recommended Posts