Difference between revisions of "LUA:GetDistance"

 
Line 1: Line 1:
== LUA Functions: GetDistance(param1, param2) ==
+
== LUA Functions: GetDistance(param1, param2, [param3]) ==
 
Returns the '''distance''' in meters of ''param1'' from ''param2''. The parameter can be either the targeted player (Spawn) or the NPC.
 
Returns the '''distance''' in meters of ''param1'' from ''param2''. The parameter can be either the targeted player (Spawn) or the NPC.
  
Line 10: Line 10:
  
 
=== Parameters ===
 
=== Parameters ===
Required: ''param1'' (int) is the source object
+
; Required - ''param1'' (Spawn), ''param2'' (Spawn)
Required: ''param2'' (int) is the destination object
+
: ''param1'' is the source object
Otional: ''param3''(int) include the collision radius in the calcs, 1 = yes
+
: ''param2'' is the destination object
 +
; Otional - ''param3''(int8)
 +
: ''param3'' include the collision radius in the calcs, 1 = yes
  
  

Latest revision as of 21:18, 12 September 2013

LUA Functions: GetDistance(param1, param2, [param3])

Returns the distance in meters of param1 from param2. The parameter can be either the targeted player (Spawn) or the NPC.

Back to LUA Functions Index


Syntax

var = GetDistance(param1, param2, [param3])


Parameters

Required - param1 (Spawn), param2 (Spawn)
param1 is the source object
param2 is the destination object
Otional - param3(int8)
param3 include the collision radius in the calcs, 1 = yes


Notes

param1 and param2 must be one of the vars in the function params. In the example below, it would be either "NPC" or "Spawn"


Usage

 function hailed(NPC, Spawn)
   Say(NPC, "The distance between you and I is " .. GetDistance(NPC, Spawn) .. " meters.")
 end

This makes the NPC respond to the player who hails it with the distance the player is from the NPC in meters.