Jump to content

How to get Waypoint x / y for unit


OzDeaDMeaT

Recommended Posts

Hi everyone,

 

I am using MOOSE currently and am trying to work out how to output to the log the set of waypoints for a unit to get the x / y. Does anyone know how to do this that could show me?

CPU: i9-12900K @ 4.9Ghz

M/B: MSI MEG z690 Ace

RAM: 128GB

Video Card: MSI RTX 4090 Suprim Liquid X

VR: Varjo Aero

Link to comment
Share on other sites

One way of doing it is by accessing the group template's route subtable in the mission database.

 

Here's an example (required field marked in red):

 BASE:TraceOnOff(true)
BASE:TraceAll(true)
BASE:TraceLevel(2)

BASE:T(_DATABASE:GetGroupTemplate("[color="Red"]name of the group in ME[/color]").route) [color="Blue"]-- This will dump the group's [i][b]route[/b][/i] subtable to dcs.log[/color]

BASE:TraceOnOff(false)

 

 

Keep in mind that the route subtable is a bit tricky to navigate, but you should be able to access x and y values like this:

route.points[[color="Red"]waypoint number[/color]].y
route.points[[color="red"]waypoint number[/color]].x

 

 

 

I've attached an output example from a group template with 6 waypoints

Route output.lua


Edited by Hardcard
Link to comment
Share on other sites

Hi

 

Installed Moose and run it at the begining of the mission.

 

Tested (both BASE:T and BASE:I) and doesn't seem to work but I might have misunderstood what it is supposed to do...

 

I am interested to get in game with a script the x and y coordinates of let's say waypoint 1 of a flight that was assigned a route dynamically in game (but I tested as well with a flght plan build in the ME).

Is that what we are speaking about ?

 

I do not see what the dcs.log has to do with that ?

 

Thanks

 

 

Edit: OK I see that the original message was speaking about dumping things in DCS log.

Anyway any idea about what I am looking for ?


Edited by CougarFFW04
Link to comment
Share on other sites

I do not see what the dcs.log has to do with that ?

[...]

Edit: OK I see that the original message was speaking about dumping things in DCS log.

 

Dodged a bullet there ;)

 

I am interested to get in game with a script the x and y coordinates of let's say waypoint 1 of a flight that was assigned a route dynamically in game

 

Here's a way of doing it, although I'm not sure it'll work with dynamic waypoints (required fields marked in red, at the bottom):

local function Get_WP_Vec2(Grp_Name , WP)
  
  if type(Grp_Name) == "string" and type(WP) == "number" and _DATABASE:GetGroupTemplate(Grp_Name) then
     
     local Group_Template = _DATABASE:GetGroupTemplate(Grp_Name)
     
     if Group_Template.route.points[WP] and Group_Template.route.points[WP].x and Group_Template.route.points[WP].y then
  
        local WP_Coord = { x = Group_Template.route.points[WP].x , y = Group_Template.route.points[WP].y }
     
        return WP_Coord
     end
  end
end

Get_WP_Vec2( "[color="red"]Name of the group in ME[/color]" , [color="Red"]waypoint number[/color] )

 

 

You can also create a custom WP table and fill it with the WP coordinates extracted from the group template (required fields marked in red):

 

local WP_Table = {}
  
  if _DATABASE:GetGroupTemplate("[color="Red"]name of the group in ME[/color]") then
     
     local Group_Template = _DATABASE:GetGroupTemplate("[color="red"]name of the group in ME[/color]")
     
     for i , Point_Table in ipairs(Group_Template.route.points) do
         
         local WP_Vec2 = { x = Point_Table.x , y = Point_Table.y }
         
         WP_Table[i] = WP_Vec2
     end
  end  
  
[color="Blue"]-- You can use [i][b]BASE:I(WP_Table)[/b][/i] to dump WP_Table in dcs.log. Keep in mind that the waypoint numbers will be increased by 1 in the table
-- Here's a dump example:[/color]

          WP_Table = {
                       [1]={ [color="blue"]-- WP 0 in ME[/color]
		     [y]=545843.86073905,
		     [x]=-311454.00582398,
                    },
	    
                [2]={ [color="blue"]-- WP 1 in ME[/color]
		     [y]=577249.58513531,
        	     [x]=-297108.18109976,
		    },
			
	        [3]={ [color="blue"]-- WP 2 in ME[/color]
		     [y]=608526.06786738,
		     [x]=-284959.46466664,
		    },
	    
	        [4]={ [color="Blue"]-- WP 3 in ME[/color]
		     [y]=647279.46875,
		     [x]=-281782.46875,
	            },
	       }

 


Edited by Hardcard
Link to comment
Share on other sites

  • Recently Browsing   0 members

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