Difference between revisions of "Talk:GetPositionX - ObjectReference"

Jump to navigation Jump to search
→‎GetCoordinateX: Changed function to an array.
imported>Rasikko
(→‎GetCoordinateX: Corrected the math.)
imported>Rasikko
(→‎GetCoordinateX: Changed function to an array.)
Line 4: Line 4:
[[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]])[[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-10-06T11:57:52 (EDT)
[[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]])[[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-10-06T11:57:52 (EDT)


== GetCoordinateX ==
== GetCellCoordinates ==
<source lang="papyrus">
<source lang="papyrus">
Int Function GetCoordinateX(float afPosX)
Int[] Function GetCellCoordinates(ObjectReference akRef)
; Returns the X coordinate.  
    ; Returns an array of this references' cell coordinates.
 
int posX = afPosX as int
    int posX = akRef.GetPositionX() as int
 
    int posY = akRef.GetPositionY() as int
if (posX < 0)
return (posX / 4096) - 1
    if (posX < 0)
else
        posX = (posX / 4096) - 1
return posX / 4096
    else
endif
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
EndFunction
</source>
</source>
--[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2019-01-14T09:29:10 (EST)
To cut down on function calls, it does not check for interiors, so do not use this for references that are in an interior. Also the Z position was intentionally
omit, as the purpose of this function is to obtain only the X,Y coordinates as seen in the Cell View Window. --[[User:Rasikko|Rasikko]] ([[User talk:Rasikko|talk]]) 2019-01-15T04:04:35 (EST)
Anonymous user

Navigation menu