Targeting - uosagas/assistant GitHub Wiki

Overview

Targeting.Target(Serial)
Targeting.TargetSelf()
Targeting.TargetLast()
Targeting.WaitForTarget(Timeout in Milliseconds)
Targeting.SetLastTarget(Serial)
Targeting.SetSelectedTarget(Serial)
Targeting.GetNewTarget()
Targeting.GetNewTarget(Timeout in Milliseconds)

Attributes

Attribute Type Description
LastTarget Serial The serial number of the last target.
SelectedTarget Serial The serial number of the selected target.

Target

Targeting.Target(Serial)

Parameters
Serial: Numeric value of the serial of an entity

Returns
Boolean: true on success, false on failure

Example

-- Find the mobile
friendplayer = Mobiles.FindByName('Herald')
-- If mobile is not found stop the script
if friendplayer == nil then
   return
end
-- Cast a spell 
Spells.Cast('Heal')
-- Wait for target by timeout of 2 seconds and on fail stop the script
if not Targeting.WaitForTarget(2000) then
   return
end
-- Target friend player
Targeting.Target(friendplayer.Serial)

TargetSelf

Targeting.TargetSelf()

Returns
Boolean: true on success, false on failure

Example

-- Cast a spell 
Spells.Cast('Heal')
-- Wait for target by timeout of 2 seconds
if Targeting.WaitForTarget(2000) then
   Targeting.TargetSelf()
end

TargetLast

Targeting.TargetLast()

Returns
Boolean: true on success, false on failure

Example

-- Cast a spell 
Spells.Cast('Heal')
-- Wait for target by timeout of 2 seconds
if Targeting.WaitForTarget(2000) then
   Targeting.TargetLast()
end

WaitForTarget

Targeting.WaitForTarget(Milliseconds)

Parameters
Numeric: Timeout as numeric value in milliseconds

Returns
Boolean: true on success, false on failure

Example

-- Find the mobile
friendplayer = Mobiles.FindByName('Herald')
-- If mobile is not found stop the script
if friendplayer == nil then
   return
end
-- Cast a spell 
Spells.Cast('Heal')
-- Wait for target by timeout of 2 seconds and on fail stop the script
if not Targeting.WaitForTarget(2000) then
   return
end
-- Target friend player
Targeting.Target(friendplayer.Serial)

SetLastTarget

SetLastTarget is used to set the last target for the player. This is useful when you want to quickly re-target the last target without having to search for it again.

Targeting.SetLastTarget(Serial)

Parameters
serial: Numeric value representing the serial number of the target

Example

Targeting.SetLastTarget(123456)

SetSelectedTarget

SetSelectedTarget is used to set the currently selected target.

Targeting.SetSelectedTarget(Serial)

Parameters
serial: Numeric value representing the serial number of the target

Example

Targeting.SetSelectedTarget(123456)

GetNewTarget

A target cursor will occure and the function will return the serial of the target on select. This has a default timeout of 10s.

Targeting.GetNewTarget()
Targeting.GetNewTarget(Timeout in Milliseconds)

Returns
serial: the serial number of the selected target by cursor

Parameters
[optionally] numeric: Numeric value representing a timeout for selection in milliseconds

Example

local myTarget = Targeting.GetNewTarget() --or
local myTarget = Targeting.GetNewTarget(5000)

Messages.Print(myTarget)
⚠️ **GitHub.com Fallback** ⚠️