Method to get Terrain Type or Road? LOS?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

Method to get Terrain Type or Road? LOS?

Post 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

KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Method to get Terrain Type or Road? LOS?

Post by KnightHawk75 »

Terrain type can be obtained via the return values from World_GetLocation() function.
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: Method to get Terrain Type or Road? LOS?

Post 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.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Method to get Terrain Type or Road? LOS?

Post 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 }
User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Method to get Terrain Type or Road? LOS?

Post by michaelm75au »

Mmmm.
The entry for 'World_GetLocation()' only shows the original return table. I'll need to update that too.
Michael
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: Method to get Terrain Type or Road? LOS?

Post 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)

User avatar
michaelm75au
Posts: 12464
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: Method to get Terrain Type or Road? LOS?

Post 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.
Michael
tiag
Posts: 131
Joined: Thu Jun 21, 2018 8:33 am

RE: Method to get Terrain Type or Road? LOS?

Post by tiag »

FYI: Tested yesterday and it works as I wanted.
Post Reply

Return to “Lua Legion”