Difference between revisions of "MIST hex hash"
From DCS World Wiki - Hoggitworld.com
(Created page with "{{Mission Scripting |fName= mist.hex.hash| |vNum = Mist 4.6 |desc= Converts a {q, r, s} table into a string of "q r s". Useful for indexing a table with the string name...") |
|||
| Line 34: | Line 34: | ||
local hexTable = {} | local hexTable = {} | ||
| − | + | ------------------------- | |
local listOfGroups = {"test1", "bob", "mav", "skeeter", "TwoThousandBMPTs", "an aircraft carrier"} | local listOfGroups = {"test1", "bob", "mav", "skeeter", "TwoThousandBMPTs", "an aircraft carrier"} | ||
| Line 42: | Line 42: | ||
local hash = mist.hex.hash(mist.hex.pointToHex(point)) | local hash = mist.hex.hash(mist.hex.pointToHex(point)) | ||
if not hexTable[hash] then | if not hexTable[hash] then | ||
| − | hexTable[hash] = {groups = { | + | hexTable[hash] = {} |
| + | hexTable[hash].groups = {} | ||
end | end | ||
| − | table.insert(hexTable[hash].groups, {[listOfGroups[i]] = | + | local entry = {point = point, hash = hash} |
| + | table.insert(hexTable[hash].groups, {[listOfGroups[i]] = entry}) | ||
end | end | ||
Latest revision as of 01:20, 1 September 2026
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 |
