Module Target_Controller
Targeting/LOS sub-system
Functions
| spawnRangeFinder (args) | Spawns a silouhette at the provided position and rotation. |
| clearFloatingNumbers () | Clears floating numbers from all miniatures on the table. |
| findAllEnemyMinis (args) | Returns all miniatures owned by the opposing team. |
| groupAllEnemyMinis (args) | Returns all miniatures owned by the opposing team, grouped into units. |
| computeDistance (args) | Returns the range, in game terms (e.g. |
| showRangeOfEnemyMinis (args) | Shows all ranges of enemy minis of the provided mini. |
Tables
| _RANGE_FINDERS | Data for creating the correct range finder projection. |
Local Functions
| toggleSIL () | Toggles silouhettes for all units in the play area. |
| _matrix2x1ToRadians (m) | Converts a `2x1` matrix `m` to radians. |
| _matrix2x1Subtract (a, b) | Returns a `2x1` matrix `a` subtracted by `b`. |
| _matrix2x1Multiply (m, p) | Returns a `2x1` matrix `m` multiplied by `p`. |
| _matrix2x1MultiplyByMatrix (a, b) | Returns a `2x1` matrix `a` multiplied by another matrix `b`. |
| _matrix2x1Divide (m, d) | Returns a `2x1` matrix `m` divided by `d`. |
| _matrix2x2x1DotBy2x1 (a, b) | Returns the dot product of a 2x2x1 matricies `a` by a 2x1 `b`. |
| _matrix2x1Dot (a, b) | Returns the dot product of 2x1 matricies `a` and `b`. |
| findLOS (_, color) | Does a LOS check for the selected unit leaders. |
Functions
- spawnRangeFinder (args)
-
Spawns a silouhette at the provided position and rotation.
Parameters:
- args The `position` and `rotation` to use.
Returns:
-
Handle to the spawned range finder.
Usage:
spawnRangeFinder({ position = {0, 0, 0}, rotation = {0, 0, 0}, }) - clearFloatingNumbers ()
- Clears floating numbers from all miniatures on the table.
- findAllEnemyMinis (args)
-
Returns all miniatures owned by the opposing team.
Parameters:
- args A table with the field `team` making the request.
Returns:
-
List of miniatures.
Usage:
local allEnemies = target.call('findAllEnemyMinis', { team: 'Blue', }) for _, mini in allEnemies do -- Do something. end
- groupAllEnemyMinis (args)
-
Returns all miniatures owned by the opposing team, grouped into units.
Parameters:
- args A table with the field `team` making the request.
Returns:
-
List of list of miniatures.
Usage:
local allEnemies = target.call('findAllEnemyMinis', { team: 'Blue', }) for _, unitGroup in allEnemies do local leader = unitGroup[1] -- Other units are not the leader. end
- computeDistance (args)
-
Returns the range, in game terms (e.g. 2D horizontal only), in inches.
Parameters:
- args A table with the field `from` and `to`, each with `position`, `rotation`, `bounds`.
Returns:
-
Distance, in inches.
Usage:
local distance = target.call('computeDistance', { from = { position = from.getPosition(), rotation = from.getRotation(), bounds = from.getBounds().size, }, to = { position = to.getPosition(), rotation = to.getRotation(), bounds = to.getBounds().size, } })
- showRangeOfEnemyMinis (args)
-
Shows all ranges of enemy minis of the provided mini.
Parameters:
- args A table with the field `origin`.
Usage:
target.call('showRangeOfEnemyMinis', { origin = myMini, })
Tables
- _RANGE_FINDERS
-
Data for creating the correct range finder projection.
Fields:
- Small
Usage:
local baseSize = 'Small' _RANGE_FINDERS[baseSize] -- "...unity3d"
Local Functions
- toggleSIL ()
- Toggles silouhettes for all units in the play area.
- _matrix2x1ToRadians (m)
-
Converts a `2x1` matrix `m` to radians.
Parameters:
- m Array with two elements, both numbers.
- _matrix2x1Subtract (a, b)
-
Returns a `2x1` matrix `a` subtracted by `b`.
Parameters:
- a Array with two elements, both numbers.
- b Array with two elements, both numbers.
Usage:
local result = _matrix2x1Subtract({4, 6}, {1, 2}) print(result) -- {3, 4}
- _matrix2x1Multiply (m, p)
-
Returns a `2x1` matrix `m` multiplied by `p`.
Parameters:
- m Array with two elements, both numbers.
- p Product.
Usage:
local result = _matrix2x1Multiply({2, 3}, 2) print(result) -- {4, 6}
- _matrix2x1MultiplyByMatrix (a, b)
-
Returns a `2x1` matrix `a` multiplied by another matrix `b`.
Parameters:
- a Array with two elements, both numbers.
- b Array with two elements, both numbers.
Usage:
local result = _matrix2x1MultiplyByMatrix({2, 3}, {4, 2}) print(result) -- {8, 6}
- _matrix2x1Divide (m, d)
-
Returns a `2x1` matrix `m` divided by `d`.
Parameters:
- m Array with two elements, both numbers.
- d Dividend.
Usage:
local result = _matrix2x1Divide({2, 4}, 2) print(result) -- {1, 2}
- _matrix2x2x1DotBy2x1 (a, b)
-
Returns the dot product of a 2x2x1 matricies `a` by a 2x1 `b`.
Parameters:
- a Array with two elements, both arrays with two number elements.
- b Array with two elements, both numbers.
See also:
Usage:
local result = _matrix2x1Dot({{1, 2}, {3, 2}}, {2, 4}) print(result) -- {9, 14} (1 * 2 + 2 * 4, 3 * 2 + 2 * 4)
- _matrix2x1Dot (a, b)
-
Returns the dot product of 2x1 matricies `a` and `b`.
The dot product is multiplying matching members, then summing them up.
Parameters:
- a Array with two elements, both numbers.
- b Array with two elements, both numbers.
Usage:
local result = _matrix2x1Dot({1, 2}, {2, 4}) print(result) -- 9 (1 * 2 + 2 * 4)
- findLOS (_, color)
-
Does a LOS check for the selected unit leaders.
Parameters:
- _ Unused
- color
Player color that clicks the button
For every selected object that is a unit leader, LOS is checked.