MIST hex hash
From DCS World Wiki - Hoggitworld.com
mist.hex.hash
| Added with: Mist 4.6 |
| Description |
| Converts a {q, r, s} table into a string of "q r s".
Useful for indexing a table with the string name of a hex grid. |
| Syntax |
| string mist.hex.hash(table qrs ) |
| Valid Input Values: |
| Return value: |
| string |
| Return example: |
| Usage Examples: |
The following would convert a groups current point into a qrs value that is then hashed and stored in a bigger table of hexagons listing which groups are within them.
local hexTable = {}
-------------------------
local listOfGroups = {"test1", "bob", "mav", "skeeter", "TwoThousandBMPTs", "an aircraft carrier"}
for i = 1, #listOfGroups do
local someGroup = Group.getByName(listOfGroups[i])
local point = mist.getLeadPos(someGroup)
local hash = mist.hex.hash(mist.hex.pointToHex(point))
if not hexTable[hash] then
hexTable[hash] = {}
hexTable[hash].groups = {}
end
local entry = {point = point, hash = hash}
table.insert(hexTable[hash].groups, {[listOfGroups[i]] = entry})
end
|
| Notes: |
| Related Functions |
| to, getRadius, setRadius, add, subtract,scale, rotate_left, rotate_right, neighbor, getNeighborCount, diagonalNeighbor, length, distance, round, lerp, cubeScale, cubeRing, cubeSpiral, lineDraw, cubeToAxial, axialToCube, pointToHex, makeVek2, makeVec3, makeVec3GL, hash, hashToHex, draw |
