Difference between revisions of "Talk:GetPositionX - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
(→‎GetCoordinateX: Fixed code to account for negative values.)
imported>Lisselli
Line 6: Line 6:
== GetCoordinateX ==
== GetCoordinateX ==
<source lang="papyrus">
<source lang="papyrus">
Float Function GetCoordinateX(ObjectReference akRef)
Int Function GetCoordinateX(ObjectReference akRef)
     ; Converts the objects' position to the X coordinate of the cell.
     ; Converts the objects' position to the X coordinate of the cell.
     Float GetPosX = akRef.GetPositionX()
     Float GetPosX = akRef.GetPositionX()

Revision as of 11:25, 27 October 2017

Getting Cell Coordinates

Ever wondered how you can use the Cell View window's coordinates in game? Simple. You take the two values and you multiply them by 4096. If you want to convert an object's in game coordinates to use in the Cell View window, you divide the X and Y values by 4096 and cast as int to remove the decimals. Lisselli (talk)Lisselli (talk) 2017-10-06T11:57:52 (EDT)

GetCoordinateX

Int Function GetCoordinateX(ObjectReference akRef)
    ; Converts the objects' position to the X coordinate of the cell.
    Float GetPosX = akRef.GetPositionX()
    If GetPosX >= 0.0
        Return GetPosX as int
    Else
        Return Math.Floor(GetPosX)
    EndIf
EndFunction

Use this to get the exact X coordinate for the cell. To be used only for exterior cells. Takes negative values into account. Lisselli (talk) 2017-10-27T12:22:34 (EDT)