MinchinWeb's MetaLibrary
v.9
Library functions of OpenTTD AI writers.
|
Array. More...
Static Public Member Functions | |
function | Create1D (length) |
Creates a one dimensional (1-D) array. More... | |
function | Create2D (length, width) |
Creates a two dimensional (2-D) array. More... | |
function | Create3D (length, width, height) |
Creates a three dimensional (3-D) array. More... | |
function | ToString1D (InArray, DisplayLength=true, replaceNull=false) |
Converts a one dimensional array to a nice string format. More... | |
function | ToString2D (InArray, DisplayLength=true) |
Converts a one dimensional array to a nice string format. More... | |
function | ContainedIn1D (InArray, SearchValue) |
Searches an array for a given value. More... | |
function | ContainedIn2D (InArray, SearchValue) |
Searches a (two dimensional) array for a given value. More... | |
function | ContainedIn3D (InArray, SearchValue) |
Searches a (three dimensional) array for a given value. More... | |
function | ContainedIn1DIn2D (InArray2D, SearchArray1D) |
Searches a two dimensional array for a given one dimensional array. More... | |
function | Find1D (InArray, SearchValue) |
Searches an array for a given value. More... | |
function | Find2D (InArray, SearchValue) |
Searches an array for a given value. More... | |
function | Find3D (InArray, SearchValue) |
Searches an array for a given value. More... | |
function | RemoveValueAt (InArray, Index) |
Removes an element from the array. More... | |
function | InsertValueAt (InArray, Index, Value) |
Adds an element from the array. More... | |
function | ToStringTiles1D (InArrayOfTiles, ArrayLength=false) |
Converts a one dimensional array of tiles to a nice string format. More... | |
function | ToStringTiles2D (InArrayOfTiles, ArrayLength=false) |
Converts a one dimensional array of tiles to a nice string format. More... | |
function | FindPairs (InArray2D, SearchValue1, SearchValue2) |
Searches an array for a given pair of values. More... | |
function | ContainedInPairs (InArray2D, SearchValue1, SearchValue2) |
Searches an array for a given pair of values. More... | |
function | Compare1D (InArray1D, TestArray1D) |
Compares the two arrays item for item. More... | |
function | Append (Array1, Array2) |
Appends one array to another. More... | |
function | RemoveDuplicates (Array) |
Removes duplicates from an array. More... | |
function | ToAIList (Array) |
Turns an Array in an AIList. More... | |
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 |
Array2
appended to the end of the items of Array1
MyArray.append(Item)
to append individual items to an 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' |
true
if the InArray1D
and TestArray1D
equal each other for the comparison of each pair of elements. false
otherwise. InArray == TestArray
to work this way...
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be one dimensional (1-D)) |
SearchValue | what is searched for |
true
if found at least once, false
if not. null
if InArray
is null
.
|
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)) |
true
if found at least once, false
if not. null
if InArray
is null
.
|
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 |
true
if found at least once, false
if not. null
if InArray
is null
.
|
static |
Searches a (three dimensional) array for a given value.
InArray | array to search (assumed to be three dimensional (3-D)) |
SearchValue | what is searched for |
true
if found at least once, false
if not. null
if InArray
is null
.
|
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 |
true
if the search values are found at least once, false
otherwise. null
if InArray2D
is null
.
|
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)) |
SearchValue
is found (as an integer), false
if not. null
if InArray
is null
.
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be two dimensional (2-D)) |
SearchValue | what is searched for |
SearchValue
is found (as an two dimensional array, of the from [i, j]
), false
if not. null
if InArray
is null
.
|
static |
Searches an array for a given value.
InArray | array to search (assumed to be three dimensional (3-D)) |
SearchValue | what is searched for |
SearchValue
is found (as an three dimensional array, of the from [i, j, k]
), false
if not. null
if InArray
is null
.
|
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 |
null
if InArray2D
is null
.
|
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 |
InArray
, now with the element Value
at Index
, the elements beyond it shifted to the right. 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 |
InArray
sans the element at Index
, the elements beyond it are shifted to the left.
|
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 | whether the replace null values with '-' |
The array is 3 long. 3 4 5
. null
if InArray
is null
.
|
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 | two dimensional (2-D) array |
DisplayLength | whether to prefix the output with the length of the array |
The array is 2 long. 3 4 / 5 6
. null
if InArray
is null
.
|
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 . |
The array is 3 long. 12,45 62,52 59,10
. null
if InArrayOfTiles
is null
. 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 . |
The array is 2 long. 12,45 62,52 / 59,10 5,37
. null
if InArrayOfTiles
is null
. Add error check that an array is provided
Add a better error message if you try and feed it not a 2-D array