AreaToList
From Original War Support Wiki
AreaToList(Area:interger, i:integer)
This command returns an area as a list of coordinates.
Area must be the identifier for an area (area's name.)
i must be either 0 or 1. If it's 0, then the function returns a list with all coordinates in the area. If it's 1 then the function returns a list with the coodinates of the remotely controlled charges in the area.
If not specified, it is considered as 0.
Usage
mylist := AreaToList(area); mylist := AreaToList(area, 1);
Example code
function ShowMinesInArea(area,side); var mines,m; begin result := 0; mines := AreaToList(area; for m := 1 to mines[1]+0 do //+0 for obtaining the number of variables in the array. begin if MineAtPos(mines[1][m],mines[2][m]) then begin ViewMineAtPos(mines[1][m],mines[2][m],side); result := result +1; end; end; end;
This function creates a list with the x- and y-coordinates of an area. The list generally looks like this [[x-coordinates],[y-coordinates]]. Coordinates belonging together can be found in the same place in the two interior lists, that is [[x_coordinates][1],[y-coordinates][1]] is one hex in the area; [[x_coordinates][2],y-coordinates[2]] is another. In general [[x-coordinates[n],[y-coordinates][n]] where 'n' is a numbers equal to or less than the amount of values in the list.
The function can also just return the coordinates of the remotely controlled charges in the area.
Easier Example code
function ShowMinesInArea(area,side); var mines,m; begin result := 0; mines := AreaToList(area, 1); //Return coordinates of remotely controlled charges in area. for m := 1 to mines[1]+0 do //+0 for obtaining the number of variables in the array. begin ViewMineAtPos(mines[1][m],mines[2][m],side); result := result +1; end; end;
Example - How does it work
We have an area "spawn_area" which consists of the hexes [5,6] , [5,7] and [6,6]. "area_list" is a local or global variable. And remotely controlled charge is on [5,7] SAIL:
area_list = AreaToList(spawn_area,0);
Now area_list = [[5,5,6],[6,7,6]].
area_list = AreaToList(spawn_area,1);
Now area_list = [[5],[7]].
CF.
Function ListEnvironmentArea
--Sali 15:54, 25 September 2016 (UTC)