Page 1 of 1
Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 5:00 am
by tiag
Hi Michael,
I have been working on an AI to control ground units but have faced some issues when making decisions on how to position and move units. Two infos are missing for the AI: Terrain type and LOS.
I was wondering how difficult would be for you to export a Lua Method to obtain information on terrain type like "croplands", "forest", "urban"? That would help to position ground units in a better way.
Similarly, are you planning to export a method that calculates the "LOS from point X to Y at given height", for example?
Regards
Tiago
RE: Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 9:11 am
by KnightHawk75
Terrain type can be obtained via the return values from World_GetLocation() function.
RE: Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 9:19 am
by tiag
I admit I did not test it, and I never found anything explaining what it does. But it makes sense, should have thought about it. Thank you! Will test it tonight.
RE: Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 9:31 am
by KnightHawk75
Your welcome. Returns a table of details about the location (cover,slope, and altitude). An example of the table returned:
local pt = World_GetLocation({latitude='16.9590719752589', longitude='-97.8607273429979'})
print(pt)
{ cover = { value = 8, text = 'Land: Woody Savannas ' }, slope = 25, altitude = 816 }
RE: Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 9:32 am
by michaelm75au
Mmmm.
The entry for 'World_GetLocation()' only shows the original return table. I'll need to update that too.
RE: Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 9:52 am
by tiag
? Not clear for me what you mean by "original return table".....are the returns invalid?
(I hope not, because this is exactly what I need)
RE: Method to get Terrain Type or Road? LOS?
Posted: Wed Jul 08, 2020 10:08 am
by michaelm75au
The doc shows just this:
World_GetLocation (location)
Returns table of details at a given position
Parameters
location Point The position to find the details of
Returns
table
From memory, the 'table' only showed 'altitude' originally whereas now it shows much more.
Take that back, this method has always shown the details in the table. Getting it confused with an old function that only returned altitude at the location. I created this new method back in Dec 2019 to give more information around the location.
Just need to add some information about what the table holds on return.
RE: Method to get Terrain Type or Road? LOS?
Posted: Fri Jul 10, 2020 6:18 am
by tiag
FYI: Tested yesterday and it works as I wanted.