You are viewing an old version of this page. Return to the latest version.
Difference between revisions of "LUA:GetDistance"
John Adams (talk | contribs) |
|||
| Line 6: | Line 6: | ||
=== Syntax === | === Syntax === | ||
| − | var = GetDistance(param1, param2) | + | var = GetDistance(param1, param2, [param3]) |
| Line 12: | Line 12: | ||
Required: ''param1'' (int) is the source object | Required: ''param1'' (int) is the source object | ||
Required: ''param2'' (int) is the destination object | Required: ''param2'' (int) is the destination object | ||
| + | Otional: ''param3''(int) include the collision radius in the calcs, 1 = yes | ||
Revision as of 16:11, 28 August 2013
LUA Functions: GetDistance(param1, param2)
Returns the distance in meters of param1 from param2. The parameter can be either the targeted player (Spawn) or the NPC.
Syntax
var = GetDistance(param1, param2, [param3])
Parameters
Required: param1 (int) is the source object Required: param2 (int) is the destination object Otional: param3(int) 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.