Difference between revisions of "GetEntityPosition"

From Nomad DB
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Retrieves a position from an [[Entity]].
+
{{Page_WD2}}
 +
Retrieves a position from an [[Entity|entity]].
  
 
== Syntax ==
 
== Syntax ==
 
<pre>
 
<pre>
GetEntityPosition(EntityId, index)
+
GetEntityPosition(entityId, component)
 
</pre>
 
</pre>
  
* [[EntityId]]
+
* '''entityID''' (string): [[EntityId|ID]] of the target entity
* '''index''' (number) 0 for x, 1 for y, 2 for z
+
* '''component''' (number): Coordinate component to return (0 = x; 1 = y; 2 = z)
 +
* '''Returns''' (number): position component
  
 
== Example ==
 
== Example ==
<pre>
+
<syntaxhighlight lang="lua">
 
local lplayerId = GetLocalPlayerEntityId()
 
local lplayerId = GetLocalPlayerEntityId()
 
if lplayerId ~= GetInvalidEntityId() then
 
if lplayerId ~= GetInvalidEntityId() then
Line 19: Line 21:
 
print("Position: ", x, y, z)
 
print("Position: ", x, y, z)
 
end
 
end
</pre>
+
</syntaxhighlight >
  
 
== Related Pages ==
 
== Related Pages ==

Latest revision as of 20:35, 27 October 2020

Retrieves a position from an entity.

Syntax

GetEntityPosition(entityId, component)
  • entityID (string): ID of the target entity
  • component (number): Coordinate component to return (0 = x; 1 = y; 2 = z)
  • Returns (number): position component

Example

local lplayerId = GetLocalPlayerEntityId()
if lplayerId ~= GetInvalidEntityId() then
	local x = GetEntityPosition(lplayerId, 0)
	local y = GetEntityPosition(lplayerId, 0)
	local z = GetEntityPosition(lplayerId, 0)
	
	print("Position: ", x, y, z)
end

Related Pages