WoW:API GetUnitSpeed: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
This is a work in progress...
{{wowapi}} __NOTOC__
Added with WoW 3.0 {{wotlk-inline}}


When the unit is not moving this returns 0<BR/>
==Usage==
When the unit is on a moving object such as a boat that's moving this returns 0<BR/>
Returns a value representing the moving speed of a unit.
When the unit is running at 100% (running on foot with no speed increase enhancements) this returns 7<BR/>
When the unit is running at 175% (Death Knight home city) this returns 12.25<BR/>
When the unit is running at 200% (Epic Mount) this returns 14


7 * 1.75 = 12.25 so apparently 7 = 100%, for example:
value = GetUnitSpeed("[[UnitId|unit]]")
 
== Parameters ==
=== Arguments ===
 
:;unit : String - The [[unitId]] for which the speed information is returned. This has not been tested with all units but does work for "Player" units.
 
=== Returns ===
 
:;value : Number - value of the unit speed
 
==== Examples ====
 
Player unit moving at 100% -- value = 7<BR/>
Player unit moving at 175% -- value = 12.25<BR/>
Player unit moving at 200% -- value = 14<BR/>
 
== Misc. Calculations ==
 
7 * 1.75 = 12.25 so apparently 7 = 100%
 
For example, the following will put the speed in % into the variable s.


  s = string.format("%d", (GetUnitSpeed("Player") / 7) * 100);
  s = string.format("%d", (GetUnitSpeed("Player") / 7) * 100);
will put the speed in % into the variable s.

Revision as of 17:34, 26 November 2008

WoW API < GetUnitSpeed

Added with WoW 3.0 Template:Wotlk-inline

Usage

Returns a value representing the moving speed of a unit.

value = GetUnitSpeed("unit")

Parameters

Arguments

unit
String - The unitId for which the speed information is returned. This has not been tested with all units but does work for "Player" units.

Returns

value
Number - value of the unit speed

Examples

Player unit moving at 100% -- value = 7
Player unit moving at 175% -- value = 12.25
Player unit moving at 200% -- value = 14

Misc. Calculations

7 * 1.75 = 12.25 so apparently 7 = 100%

For example, the following will put the speed in % into the variable s.

s = string.format("%d", (GetUnitSpeed("Player") / 7) * 100);