Difference between revisions of "LUA:GetOwner"

(Created page with "= LUA Functions: AddHate() = Adds hate to ''param2'' from ''param1'' ==== Syntax ==== AddHate(param1, param2, param3) ==== Parameters ==== ; Required - ''param1'' (Spawn), ''...")
 
 
Line 1: Line 1:
= LUA Functions: AddHate() =
+
= LUA Functions: GetOwner() =
Adds hate to ''param2'' from ''param1''
+
Gets the owner of the given pet
  
  
 
==== Syntax ====
 
==== Syntax ====
AddHate(param1, param2, param3)
+
GetOwner(param1)
  
  
 
==== Parameters ====
 
==== Parameters ====
; Required - ''param1'' (Spawn), ''param2'' (Spawn), ''param3'' (sint32)
+
; Required - ''param1'' (Spawn)
: ''param1'' is the spawn that is adding hate
+
: ''param1'' is the spawn who's owner we want to get
: ''param2'' is the spawn recieving the hate
 
: ''param3'' is the amount of hate to add
 
  
 
==== Usage ====
 
==== Usage ====
 
<pre>
 
<pre>
function cast(Caster, Target)
+
function hailed(NPC, Spawn)
     -- Add 50 hate to the target
+
     if IsPet(NPC) then
    AddHate(Caster, Target, 50)
+
        local owner = GetOwner(Spawn)
 +
        if owner ~= nil then
 +
            Say(NPC, "My owner is " .. GetName(Owner) .. ".")
 +
        end
 +
    end
 
end
 
end
 
</pre>
 
</pre>
  
This is a simple taunt spell that adds 50 hate to the target.
+
This spawn script will respond with the name of its owner if it is a pet.
  
 
== Notes ==
 
== Notes ==
If this is called from a spell script then the target/targets will be determined by the spell data(encounter AE, true AE, single target, etc...), the param is still required though.
+
While not required it is good practice to make sure you are dealing with a pet before calling this function.

Latest revision as of 17:18, 28 August 2013

LUA Functions: GetOwner()

Gets the owner of the given pet


Syntax

GetOwner(param1)


Parameters

Required - param1 (Spawn)
param1 is the spawn who's owner we want to get

Usage

function hailed(NPC, Spawn)
    if IsPet(NPC) then
        local owner = GetOwner(Spawn)
        if owner ~= nil then
            Say(NPC, "My owner is " .. GetName(Owner) .. ".")
        end
    end
end

This spawn script will respond with the name of its owner if it is a pet.

Notes

While not required it is good practice to make sure you are dealing with a pet before calling this function.