Coordinate Functions

From the CreationKit Wiki
Revision as of 13:00, 20 November 2020 by imported>Rasikko (Created page with "Putting my coordinate functions here since my personal pages are getting too big. <source lang="papyrus"> Int[] Function GetCellCoordinates(ObjectReference akRef) ; Retur...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Putting my coordinate functions here since my personal pages are getting too big.

Int[] Function GetCellCoordinates(ObjectReference akRef)
    ; Returns an array of this references' cell coordinates.
  
    int posX = akRef.GetPositionX() as int
    int posY = akRef.GetPositionY() as int
   
    if (posX < 0)
        posX = (posX / 4096) - 1
    else
        posX = posX / 4096
    endif
   
    if (posY < 0)
        posY = (posY / 4096) - 1
    else
        posY = posY / 4096
    endif
   
    Int[] CellCoordinates = new Int[2]
    CellCoordinates[0] = posX
    CellCoordinates[1] = posY
   
    return CellCoordinates
EndFunction