lazerwolf Posted July 14, 2019 Posted July 14, 2019 Greetings Pilots! Is there any way to have the coordinates displayed in the unit list or extract them from a file? Is there a mod that can do this? I want to put them in the kneeboard for my mission but don't want to manually add 60+ unit coordinates. Thanks and happy hunting.
lazerwolf Posted July 15, 2019 Author Posted July 15, 2019 I've found XY values like these below for each unit but not sure how to convert them to GPS coords. ["y"] = -123573.25864029, ["x"] = -31965.966372327,
Grimes Posted July 16, 2019 Posted July 16, 2019 Using the scripting engine it is pretty straight forward by using getPoint to find out the x, y, z a unit is at and then converting it via LOtoLL to get those values. So for instance if you knew the name of the groups for objects you want to find: Paste this into a do script call in the triggers for a mission. local groups = {'gp1', 'gp2', 'gp3'} for i = 1, #groups do if Group.getByName(groups[i]) then local point = Group.getByName(groups[i]):getUnit(1):getPoint() local lat, lon = coord.LOtoLL(point) env.info(groups[i] .. ' LAT: ' .. lat .. ' LON: ' .. lon) end end That code will iterate through the table named "groups" for groups named "gp1", etc. If it finds the group it will get the location of the first unit in the group. It will then convert that to lat lon coordinates, and finally it will print it to your DCS.log in the format of "groupname LAT: xyz LON: xyz" 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
lazerwolf Posted July 17, 2019 Author Posted July 17, 2019 A couple more questions please. 1. is there any way to have it report in degrees? My whole purpose here is to use the info to program guided munitions. 2. Instead of have to list every single group eg. gp #001, gp#002, gp#003, etc, is there a way to have it do a partial name search such as "gp" without the rest and report everything with a prefix of "gp"? Thanks!
Grimes Posted July 18, 2019 Posted July 18, 2019 (edited) 1. It is degrees, its just not formatted the same way as you would expect. You use the digits behind the decimal point to convert to minutes and again to seconds. For converting it some of this code might give you an idea: https://github.com/mrSkortch/MissionScriptingTools/blob/master/mist.lua#L1576 2. Yes. This assumes you want to get ground groups for the red coalition. local groups = coalition.getGroups(coalition.side.RED, Group.Category.Ground) for i = 1, #groups do if string.find(Group.getName(groups[i]), 'gp') == 1 and Group.getSize(groups[i]) > 0 then local point = Group.getByName(groups[i]):getUnit(1):getPoint() local lat, lon = coord.LOtoLL(point) env.info(groups[i] .. ' LAT: ' .. lat .. ' LON: ' .. lon) end end Edited July 18, 2019 by Grimes 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
lazerwolf Posted July 18, 2019 Author Posted July 18, 2019 Got an error. Spent and hour trying to figure it out but wasn't obvious to me. I tried! :) ERROR DCS: Mission script error: : [string "local groups = coalition.getGroups(coalition.side.RED, Group.Ca..."]:3: unexpected symbol near '['
Grimes Posted July 18, 2019 Posted July 18, 2019 Fixed maybe. 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
lazerwolf Posted July 18, 2019 Author Posted July 18, 2019 No more script errors but it's not reporting the expected information to the log.
lazerwolf Posted July 20, 2019 Author Posted July 20, 2019 Man, after spending almost 2 days trying my hand at coding this to no avail, I'm just going to put every single unit in that top script then cut and past each returned decimal to a website that will convert it to degrees. Thanks for getting me that far with the first script, it gives me something to work with. I wish I was decent enough at coding to get exactly what I need to save me tons of time and cutting and pasting. I need to learn 2LUA lol.
Recommended Posts