Difference between revisions of "Talk:GetPositionY - ObjectReference"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Lisselli
(Added function for converting y position to the y coordinate the exterior cell is assigned to.)
 
imported>Lisselli
m (→‎GetCoordinateY: Fixed code to account for negative values.)
Line 2: Line 2:
<source lang="papyrus">
<source lang="papyrus">
Float Function GetCoordinateY(ObjectReference akRef)
Float Function GetCoordinateY(ObjectReference akRef)
     ; Converts the objects y position to the Y coordinate of the cell.
     ; Converts the objects' Y position to the Y coordinate of the cell.
     return Math.Floor(akRef.GetPositionY() / 4096.0)
     Float GetPosY = akRef.GetPositionY() / 4096.0
    If GetPosY >= 0.0
        Return GetPosY as Int
    Else
        Return Math.Floor(GetPosY)
    EndIf
EndFunction
EndFunction
</source>
</source>
Use this to get the exact Y coordinate for the cell. Use only for exterior cells. [[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-10-27T06:36:14 (EDT)
Use this to get the exact Y coordinate for the cell. Use only for exterior cells. Takes negative values into account. [[User:Lisselli|Lisselli]] ([[User talk:Lisselli|talk]]) 2017-10-27T12:18:47 (EDT)

Revision as of 11:18, 27 October 2017

GetCoordinateY

Float Function GetCoordinateY(ObjectReference akRef)
    ; Converts the objects' Y position to the Y coordinate of the cell.
    Float GetPosY = akRef.GetPositionY() / 4096.0
    If GetPosY >= 0.0
        Return GetPosY as Int
    Else
        Return Math.Floor(GetPosY)
    EndIf
EndFunction

Use this to get the exact Y coordinate for the cell. Use only for exterior cells. Takes negative values into account. Lisselli (talk) 2017-10-27T12:18:47 (EDT)