Jump to content

Simple Math Formula Script -- Possible?


Recommended Posts

Posted

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

Posted

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

Posted

@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

Posted

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

Posted
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

  • Recently Browsing   0 members

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