WoW:API SetCurrentTitle: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
(random title marco)
m (Move page script moved page API SetCurrentTitle to API SetCurrentTitle without leaving a redirect)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{wowapi}} __NOTOC__
{{protectedhwapi|3.3}} {{wowapi}}
 
Changes your character's displayed title.
One line summary description of function.
SetCurrentTitle(titleId);


== Arguments ==
== Arguments ==
[[TitleId]]
; titleId : Number - ID of the title you want to set. The identifiers are global and therefore do not depend on which titles you have learned. Invalid or unlearned values clear your title. See [[TitleId]] for a list.
: Number - Index of the title you want to set.
 
== Returns ==
nil


== Example ==
== Example ==
  SetCurrentTitle(43);
  SetCurrentTitle(43);


This would set the title "Chef" if your character had earned the title, otherwise it removes any active title.
This sets the title "Elder" if your character had earned the title, otherwise it removes any active title.


  /script i=0 while (IsTitleKnown(i)==0) do i=random(GetNumTitles()) end SetCurrentTitle(i)
  /run local t={}; for titles=1,GetNumTitles()-1,1 do if IsTitleKnown(titles)==1 then table.insert(t,titles) end; end; local x=random(#t); print("Using title: "..GetTitleName(t[x])); SetCurrentTitle(t[x])


This will set a random title. (Warning: quick'n'dirty: may hang WoW if no title available. May cause lag if only few titles are available.)
This macro will iterate over the list of titles, grab the ones the user has, then choose a random one from that list.


== Details ==
== Details ==
*The last indexed value (currently 137) returns nil and removes the player's name completely (not available to players).
* The last indexed value (currently 143) returns nil and removes the player's name completely (not available to players).
*Title index -1 will clear titles from the player's name. (Option "None" from the Character frame's title dropdown menu.)
* [[API GetTitleName|GetTitleName]] can be used to find the name associated with the [[TitleId]].
*[[API GetTitleName|GetTitleName]] can be used to find the name associated with the [[TitleId]].

Latest revision as of 04:47, 15 August 2023

WoW API < SetCurrentTitle

Changes your character's displayed title.

SetCurrentTitle(titleId);

Arguments[edit]

titleId
Number - ID of the title you want to set. The identifiers are global and therefore do not depend on which titles you have learned. Invalid or unlearned values clear your title. See TitleId for a list.

Example[edit]

SetCurrentTitle(43);

This sets the title "Elder" if your character had earned the title, otherwise it removes any active title.

/run local t={}; for titles=1,GetNumTitles()-1,1 do if IsTitleKnown(titles)==1 then table.insert(t,titles) end; end; local x=random(#t); print("Using title: "..GetTitleName(t[x])); SetCurrentTitle(t[x])

This macro will iterate over the list of titles, grab the ones the user has, then choose a random one from that list.

Details[edit]

  • The last indexed value (currently 143) returns nil and removes the player's name completely (not available to players).
  • GetTitleName can be used to find the name associated with the TitleId.