GetObjectRotation: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetObjectRotation(object)}} {{FuncParameters}} {{FuncParam|object|__EDIT_ME__}} {{FuncReturnValue..." |
No edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{Info|Function|Server|1.0}} | {{Info|Function|Server & Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Gets the object rotation.}} | ||
{{FuncSyntax|GetObjectRotation(object)}} | {{FuncSyntax|GetObjectRotation(object)}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|object| | {{FuncParam|object|The object identifier.}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns 3 float values: pitch, yaw and roll}} | ||
== Example == | == Example == | ||
<syntaxhighlight lang="Lua"> | |||
function cmd_debugobject(player, object) | |||
if (object == nil) then | |||
return AddPlayerChat(player, "Usage: /debugobject <object>") | |||
end | |||
if (not IsValidObject(object)) then | |||
return AddPlayerChat(player, "Object (ID: "..object..") does not exist") | |||
end | |||
local x, y, z = GetObjectLocation(object) | |||
local rx, ry, rz = GetObjectRotation(object) | |||
local sx, sy, sz = GetObjectScale(object) | |||
local isAttached = IsObjectAttached(object) | |||
local attachType, attachId = GetObjectAttachmentInfo(object) | |||
local isMoving = IsObjectMoving(object) | |||
--local streamed = IsObjectStreamedIn(player, object) == true and 'True' or 'False' | |||
AddPlayerChat(player, '<span color="00ee00ff">Object (ID: '..object..')</>') | |||
AddPlayerChat(player, ' Loc: ' .. x .. ', ' .. y .. ', ' .. z) | |||
AddPlayerChat(player, ' Rot: ' .. rx .. ', ' .. ry .. ', ' .. rz) | |||
AddPlayerChat(player, ' Scale: ' .. sx .. ', ' .. sy .. ', ' .. sz) | |||
if isAttached then | |||
local attachTypeStr | |||
if attachType == ATTACH_PLAYER then | |||
attachTypeStr = "Player" | |||
else | |||
attachTypeStr = "Vehicle" | |||
end | |||
AddPlayerChat(player, ' AttachedTo: ' .. attachTypeStr .. ', ' .. attachId) | |||
end | |||
if isMoving then | |||
AddPlayerChat(player, ' Moving: ' .. isMoving) | |||
end | |||
end | |||
AddCommand("debugobject", cmd_debugobject) | |||
</syntaxhighlight> | |||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
* [[GetObjectCount]] | |||
* [[GetObjectModelCount]] | |||
* [[GetObjectModelGroup]] | |||
* [[GetObjectModelName]] | |||
* [[GetStreamedObjects]] | |||
* [[GetObjectModel]] | |||
* [[GetObjectLocation]] | |||
* [[GetObjectScale]] | |||
* [[GetObjectBoundingBox]] | |||
* [[GetObjectSize]] | |||
* [[EnableObjectHitEvents]] | |||
* [[GetObjectMass]] | |||
* [[SetObjectEditorSpeed]] | |||
* [[SetObjectEditable]] | |||
* [[SetObjectOutline]] | |||
* [[SetObjectCastShadow]] | |||
* [[SetObjectColor]] | |||
* [[SetObjectEmissiveColor]] | |||
* [[SetObjectTexture]] | |||
* [[SetObjectAnimatedTexture]] |
Latest revision as of 10:48, 1 September 2020
Description
Gets the object rotation.
Syntax
GetObjectRotation(object)
Parameters
- object
The object identifier.
Return Value
- Returns 3 float values: pitch, yaw and roll
Example
function cmd_debugobject(player, object)
if (object == nil) then
return AddPlayerChat(player, "Usage: /debugobject <object>")
end
if (not IsValidObject(object)) then
return AddPlayerChat(player, "Object (ID: "..object..") does not exist")
end
local x, y, z = GetObjectLocation(object)
local rx, ry, rz = GetObjectRotation(object)
local sx, sy, sz = GetObjectScale(object)
local isAttached = IsObjectAttached(object)
local attachType, attachId = GetObjectAttachmentInfo(object)
local isMoving = IsObjectMoving(object)
--local streamed = IsObjectStreamedIn(player, object) == true and 'True' or 'False'
AddPlayerChat(player, '<span color="00ee00ff">Object (ID: '..object..')</>')
AddPlayerChat(player, ' Loc: ' .. x .. ', ' .. y .. ', ' .. z)
AddPlayerChat(player, ' Rot: ' .. rx .. ', ' .. ry .. ', ' .. rz)
AddPlayerChat(player, ' Scale: ' .. sx .. ', ' .. sy .. ', ' .. sz)
if isAttached then
local attachTypeStr
if attachType == ATTACH_PLAYER then
attachTypeStr = "Player"
else
attachTypeStr = "Vehicle"
end
AddPlayerChat(player, ' AttachedTo: ' .. attachTypeStr .. ', ' .. attachId)
end
if isMoving then
AddPlayerChat(player, ' Moving: ' .. isMoving)
end
end
AddCommand("debugobject", cmd_debugobject)
See also
- GetObjectCount
- GetObjectModelCount
- GetObjectModelGroup
- GetObjectModelName
- GetStreamedObjects
- GetObjectModel
- GetObjectLocation
- GetObjectScale
- GetObjectBoundingBox
- GetObjectSize
- EnableObjectHitEvents
- GetObjectMass
- SetObjectEditorSpeed
- SetObjectEditable
- SetObjectOutline
- SetObjectCastShadow
- SetObjectColor
- SetObjectEmissiveColor
- SetObjectTexture
- SetObjectAnimatedTexture