WildBillKelsoe Posted July 14, 2018 Posted July 14, 2018 So my learning curve is bad and I want to put some code like this to read wind-180 into a F10 message: io.read = n if n > 180 then a = -1*(180-n) else if n < 180 then a = 180-n print (a) end so what this does is to take a wind direction blowing to and converts it to winds coming from. :smilewink: I want to take the mission wind value from an unknown lua for ground level and that figure runs thru this code to get an upwind value. Better yet is there anyway to extract ground wind from mission file? AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.
Zayets Posted July 16, 2018 Posted July 16, 2018 Sure there is :atmosphere.getWind(table vec3 ) and atmosphere.getWindWithTurbulence(table vec3 ) [sIGPIC]OK[/sIGPIC]
Hardcard Posted July 17, 2018 Posted July 17, 2018 So my learning curve is bad and I want to put some code like this to read wind-180 into a F10 message: io.read = n if n > 180 then a = -1*(180-n) else if n < 180 then a = 180-n print (a) end so what this does is to take a wind direction blowing to and converts it to winds coming from. :smilewink: I want to take the mission wind value from an unknown lua for ground level and that figure runs thru this code to get an upwind value. Better yet is there anyway to extract ground wind from mission file? It would be cool if you could post the final script here once you get it working. Nice function to have in any mission :thumbup: [sIGPIC][/sIGPIC]
WildBillKelsoe Posted July 17, 2018 Author Posted July 17, 2018 Sure there is :atmosphere.getWind(table vec3 ) and atmosphere.getWindWithTurbulence(table vec3 ) where did you get this from? AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.
Zayets Posted July 18, 2018 Posted July 18, 2018 https://wiki.hoggitworld.com/view/DCS_func_getWind [sIGPIC]OK[/sIGPIC]
WildBillKelsoe Posted July 18, 2018 Author Posted July 18, 2018 https://wiki.hoggitworld.com/view/DCS_func_getWind thanks. the code works in LDT in Eclipse. Just want to limit input to 0-359 and output to 0-360. Any idea how to do it? local line repeat print("Input wind heading: "); line = io.read() -- read a line n = tonumber(line) -- try to convert it to a number k = tonumber(line) k = 180-n if n > 180 then print("Reciprocal heading is: ",-k) elseif n < 180 then print("Reciprocal heading is: ", n+180) else n = 180 print ("are you kidding me?") end print("do you want to convert again? y/n?") line = io.read() until line ~= "y" print("Goodbye") AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.
Wrench Posted July 19, 2018 Posted July 19, 2018 There's a chunk of code that does that in my carrier script, posted in the missions section. Feel free to yank it out. I can write a function for it if you'd like next time I sit down to do some scripting. Carrier Script.
WildBillKelsoe Posted July 20, 2018 Author Posted July 20, 2018 There's a chunk of code that does that in my carrier script, posted in the missions section. Feel free to yank it out. I can write a function for it if you'd like next time I sit down to do some scripting. That would be great. Thanks for the intel. AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.
Wrench Posted July 20, 2018 Posted July 20, 2018 One thing I need to know, readback reciprocal of wind direction at what point? by default, my script uses a unit's position (could be a unit you plonk somewhere to read wind from) This way, it'll work with both dynamic and static weather. anyway, here's the function. function wrench_get_wind_recip(unit1) local wind = {} local pos1 = Unit.getPosition(Unit.getByName(unit1)).p if pos1 ~= nil then pos1.y=pos1.y+1 --get wind info wind = atmosphere.getWind(pos1) windspeed = mist.vec.mag(wind) windspeed = windspeed * 1.94384 --get wind direction sorted local dir = math.atan2(wind.z, wind.x) * 180 / math.pi if dir < 0 then dir = dir + 360 --converts to positive numbers end if dir <= 180 then dir = dir + 180 else dir = dir - 180 end if dir > 360 then dir = dir - 360 end wind = math.floor(dir) windspeed = math.floor(windspeed) outstring = 'Wind is from ' .. wind .. ' at ' .. windspeed .. ' Knots.' trigger.action.outText(outstring, 2) else trigger.action.outText('unit not detected', 2) end end You can use a RADIO ITEM ADD and a SWITCHED CONDITION trigger to call the function. Something like the radio item sets flag 1 ON. Then a SWITCHED CONDITION activated by flag 1 will call the function (more on this in a second) and set flag 1 back to OFF. To call the function, simply use this line: wrench_get_wind_recip('unit1') but replace unit1 with the name of your unit (leave the single quotes.) Carrier Script.
WildBillKelsoe Posted July 21, 2018 Author Posted July 21, 2018 On landing back at base so I will set a trigger zone to activate say an hour into the mission and once unit is detected inside it, it shall prompt the wind reciprocal by request thru F10 radio. Thanks a bunch man! AWAITING ED NEW DAMAGE MODEL IMPLEMENTATION FOR WW2 BIRDS Fat T is above, thin T is below. Long T is faster, Short T is slower. Open triangle is AWACS, closed triangle is your own sensors. Double dash is friendly, Single dash is enemy. Circle is friendly. Strobe is jammer. Strobe to dash is under 35 km. HDD is 7 times range key. Radar to 160 km, IRST to 10 km. Stay low, but never slow.
Recommended Posts