MinchinWeb's MetaLibrary v.11
Library functions for OpenTTD AI (and GS) writers.
|
Array. More...
Static Public Member Functions | |
function | Create1D (length) |
Creates a one dimensional (1-D) array. | |
function | Create2D (length, width) |
Creates a two dimensional (2-D) array. | |
function | Create3D (length, width, height) |
Creates a three dimensional (3-D) array. | |
function | ToString1D (InArray, DisplayLength=true, replaceNull=false) |
Converts a one dimensional array to a nice string format. | |
function | ToString2D (InArray, DisplayLength=true, replaceNull=false) |
Converts a two dimensional array to a nice string format. | |
function | ContainedIn1D (InArray, SearchValue) |
Searches an array for a given value. | |
function | ContainedIn2D (InArray, SearchValue) |
Searches a (two dimensional) array for a given value. | |
function | ContainedIn3D (InArray, SearchValue) |
Searches a (three dimensional) array for a given value. | |
function | ContainedIn1DIn2D (InArray2D, SearchArray1D) |
Searches a two dimensional array for a given one dimensional array. | |
function | Find1D (InArray, SearchValue) |
Searches an array for a given value. | |
function | Find2D (InArray, SearchValue) |
Searches an array for a given value. | |
function | Find3D (InArray, SearchValue) |
Searches an array for a given value. | |
function | RemoveValueAt (InArray, Index) |
Removes an element from the array. | |
function | InsertValueAt (InArray, Index, Value) |
Adds an element from the array. | |
function | ToStringTiles1D (InArrayOfTiles, ArrayLength=false, replaceNull=false) |
Converts a one dimensional array of tiles to a nice string format. | |
function | ToStringTiles2D (InArrayOfTiles, ArrayLength=false, replaceNull=false) |
Converts a one dimensional array of tiles to a nice string format. | |
function | FindPairs (InArray2D, SearchValue1, SearchValue2) |
Searches an array for a given pair of values. | |
function | ContainedInPairs (InArray2D, SearchValue1, SearchValue2) |
Searches an array for a given pair of values. | |
function | Compare1D (InArray1D, TestArray1D) |
Compares the two arrays item for item. | |
function | Append (Array1, Array2) |
Appends one array to another. | |
function | RemoveDuplicates (Array) |
Removes duplicates from an array. | |
function | ToAIList (Array) |
Turns an Array in an AIList. |
Private Attributes | |
main = null |
Array.
This is a collection of functions to make working with Arrays easier.
|
static |
Appends one array to another.
Array1 | the first array |
Array2 | the second array |
|
static |
Compares the two arrays item for item.
Returns true if every item pair matches.
InArray1D | one dimensional (1-D) array, that is considered 'known' |
TestArray1D | one dimensional (1-D) array, that is considered 'unknown' |
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be one dimensional (1-D)) |
SearchValue | what is searched for |
|
static |
Searches a two dimensional array for a given one dimensional array.
InArray | array to search (assumed to be two dimensional (2-D)) |
SearchValue | array to search for (assumed to be one dimensional (1-D)) |
|
static |
Searches a (two dimensional) array for a given value.
InArray | array to search (assumed to be two dimensional (2-D)) |
SearchValue | what is searched for |
|
static |
|
static |
Searches an array for a given pair of values.
The idea is to provide an array of arrays of pairs (e.g. tile x and tile y, starting and ending points, etc.), and find out if SearchValue1 and SearchValue2 are among the pairs. The order that SearchValue1 and SearchValue2 are in is not considered.
InArray2D | two dimensional (2-D) array |
SearchValue1 | value to search for |
SearchValue2 | value to search for |
|
inlinestatic |
Creates a one dimensional (1-D) array.
length | the desired length of the array |
|
static |
Creates a two dimensional (2-D) array.
length | the desired length of the array (in the first dimension) |
width | the desired length of the array (in the second dimension) |
|
static |
Creates a three dimensional (3-D) array.
length | the desired length of the array (in the first dimension) |
width | the desired length of the array (in the second dimension) |
height | the desired length of the array (in the third dimension) |
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be two dimensional (2-D)) |
SearchArray | array to search for (assumed to be one dimensional (1-D)) |
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be two dimensional (2-D)) |
SearchValue | what is searched for |
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be three dimensional (3-D)) |
SearchValue | what is searched for |
|
static |
Searches an array for a given pair of values.
The idea is to provide an array of arrays of pairs (e.g. tile x and tile y, starting and ending points, etc.), and find out if SearchValue1 and SearchValue2 are among the pairs. The order that SearchValue1 and SearchValue2 is not considered.
InArray2D | two dimensional (2-D) array |
SearchValue1 | values to search for |
SearchValue2 | values to search for |
|
static |
Adds an element from the array.
Adds Value to the InArray at the given Index. The rest of the array is shifted one place to the right. The returned array is thus one longer than InArray.
InArray | the array to add the element to |
Index | the index of where to add Value at |
Value | the element to add |
Add error check that an array is provided
Add error check that Index is reasonable
|
static |
|
static |
Removes an element from the array.
Removes the value at the index, and shifts the rest of the array to the left. The returned array is thus one shorter than the supplied array.
InArray | the array to remove the element from |
Index | the index of the element to remove |
|
static |
|
static |
Converts a one dimensional array to a nice string format.
This function was created to aid in the output of arrays to the AI debug screen.
InArray | one dimensional (1-D) array |
DisplayLength | whether to prefix the output with the length of the array |
replaceNull | (true or false) whether to replace null values with "-". Default is false. Note that the function will raise an error if set to false and a null value is encountered. |
|
static |
Converts a two dimensional array to a nice string format.
This function was created to aid in the output of arrays to the AI debug screen.
InArray | two dimensional (2-D) array |
DisplayLength | whether to prefix the output with the length of the array |
replaceNull | (true or false) whether to replace null values with "-". Default is false. Note that the function will raise an error if set to false and a null value is encountered. |
|
static |
Converts a one dimensional array of tiles to a nice string format.
This function was created to aid in the output of arrays of tiles to the AI debug screen.
InArrayOfTiles | one dimensional (1-D) array of Tiles |
ArrayLength | (true or false) whether to print the prefix noting the length of the array. Default is false. |
replaceNull | (true or false) whether to replace null values with "---". Default is false. Note that the function will raise an error if set to false and a null value is encountered. |
Add error check that an array is provided
Add a better error message if you try and feed it not a 1-D array
|
static |
Converts a one dimensional array of tiles to a nice string format.
This function was created to aid in the output of arrays of tiles to the AI debug screen.
InArrayOfTiles | two dimensional (2-D) array of Tiles |
ArrayLength | (true or false) whether to print the prefix noting the length of the array. Default is false. |
replaceNull | (true or false) whether to replace null values with "---". Default is false. Note that the function will raise an error if set to false and a null value is encountered. |
Add error check that an array is provided
Add a better error message if you try and feed it not a 2-D array