Talk:GetPositionX - ObjectReference
Jump to navigation
Jump to search
I was bored. Local positions is the an objects getpositionXYZ converted into positions in the cell that they're in. For example if the an object's X was 13,000 then their local X is 712. Basically it's how far along the object is on the x and y axis 'of the cell', not the global x and y axis..
Float[] Function GetLocalPositions(Float afPosX =0.0, Float afPosY=0.0, Float afPosZ=0.0)
; return an array of an object's LOCAL positions within a single cell.
; Optionally can be used to plug in known x, y, z GLOBAL positions.
; Note: If you're in the origin cell, your global and local positions are equal.
Float[] LocalPositions = new Float[3]
LocalPositions[0] = GetLocalPositionX(afPosX)
LocalPositions[1] = GetLocalPositionY(afPosY)
LocalPositions[2] = GetLocalPositionZ(afPosZ)
return LocalPositions
EndFunction
Float Function GetLocalPositionX(Float posX)
if posX < 0
return posX - ((posX / 4096) as int * 4096 * -1)
endif
return posX - ((posX / 4096) as int * 4096)
EndFunction
Float Function GetLocalPositionY(Float posY)
if posY < 0
return posY - ((posY / 4096) as int * 4096 * -1)
endif
return posY - ((posY / 4096) as int * 4096)
EndFunction
Float Function GetLocalPositionZ(Float posZ)
if posZ < 0
return posZ - ((posZ / 4096) as int * 4096 * -1)
endif
return posZ - ((posZ / 4096) as int * 4096)
EndFunction