魔兽世界API函数汇总-商业技能,交易,技能训练,对象等
好东西!投票支持(3)
(编者注:魔兽世界的API接口函数库相当庞大,本类的整理将是一个长期的编辑过程,逐步汉化,同时欢迎对魔兽世界宏与UI有兴趣的各路高手加入本项百科计划!)
编译自:WOWWIKI
魔兽世界API
魔兽世界API是一整套由暴雪提供的,允许玩家通过插件与宏改善魔兽世界游戏用户界面的函数接口功能.
以下是几近完整的函数接口列表,由暴雪开放提供,您可以使用它们创建你自己的插件或者宏.
我们欢迎您将自己了解的更多知识与我们共享,将自己的心得发布上来
TradeSkill Functions (商业技能函数)
- CloseTradeSkill() - Closes an open trade skill window.
- CollapseTradeSkillSubClass(index) - Collapses the specified subclass header row.
- DoTradeSkill(index{,repeat}) - Performs the tradeskill a specified # of times.
- ExpandTradeSkillSubClass(index) - Expands the specified subclass header row.
- GetFirstTradeSkill() - Returns the index of the first non-header trade skill entry.
- GetNumTradeSkills() - Get the number of trade skill entries (including headers).
- GetTradeSkillCooldown(index) - Returns the number of seconds left for a skill to cooldown.
- GetTradeSkillIcon(index) - Returns the texture name of a tradeskill’s icon.
- GetTradeSkillInfo(index) - Retrieves information about a specific trade skill.
- GetTradeSkillInvSlotFilter(slotIndex) - ?.
- GetTradeSkillInvSlots() - Returns a list of the available inventory slot types.
- GetTradeSkillItemLink(index) - Gets the link string for a trade skill item.
- GetTradeSkillItemStats() - ?
- GetTradeSkillLine() - Returns information about the selected skill line.
- GetTradeSkillNumMade(index) - Gets the number of items made in a single use of a skill.
- GetTradeSkillNumReagents(tradeSkillRecipeId) - Returns the number of different reagents required.
- GetTradeSkillReagentInfo(tradeSkillRecipeId, reagentId) - Returns data on the reagent, including a count of the player’s inventory.
- GetTradeSkillReagentItemLink(index, reagentId) - Gets the link string for a trade skill reagent.
- GetTradeSkillSelectionIndex() - Returns the Id of the currently selected trade skill, 0 if none selected.
- GetTradeSkillSubClassFilter - ?.
- GetTradeSkillSubClasses() - Returns a list of the valid subclasses.
- GetTradeSkillTools(index) - Returns information about the tools needed for a tradeskill.
- GetTradeskillRepeatCount() - ?.
- IsTradeskillTrainer() - Returns 1 if trainer is for a tradeskill.
- IsTrainerServiceTradeSkill() - ?.
- SelectTradeSkill(index) - Select a specific trade skill in the list.
- SetTradeSkillInvSlotFilter(slotIndex,onOff{,exclusive} ) - Set the inventory slot type filter.
- SetTradeSkillSubClassFilter(slotIndex,onOff{,exclusive} ) - Set the subclass filter.
发现不支持的代码:
Trading Functions (交易功能函数)
- AcceptTrade() - A pending trade will be accepted.
- AddTradeMoney() - Adds the money dropped into the player’s trade frame.
- BeginTrade() - Begins the trade with the target.
- CancelTrade() - Declines the offer to trade with the other player.
- CancelTradeAccept - Cancels the trade attempt which required an accept.
- ClickTargetTradeButton(index)
- ClickTradeButton(index)
- CloseTrade - Closes the trade.
- GetPlayerTradeMoney - Returns the amount of money the player has in the trade window.
- GetTargetTradeMoney - Returns the amount of money in the trade frame of the target player.
- GetTradePlayerItemInfo(id) - Returns information about a trade item.
- GetTradePlayerItemLink(id) - Returns link to a trade item.
- GetTradeTargetItemInfo(id) - Returns information about a trade item.
- GetTradeTargetItemLink(id) - Returns link to a trade item.
- InitiateTrade(UnitId) - Asks the specified unit to trade.
- PickupPlayerMoney - Picks up an amount of money from the player.
- PickupTradeMoney(amount)
- ReplaceTradeEnchant - Confirm the replacement of an enchantment via trade.
- SetTradeMoney(amount)
发现不支持的代码:
Training Functions (技能训练功能函数)
- BuyTrainerService - ?.
- CloseTrainer - ?.
- CollapseTrainerSkillLine - ?.
- ExpandTrainerSkillLine - ?.
- GetNumTrainerServices() - Get the number of the trainer services.
- GetTrainerGreetingText() - Get the trainer’s greeting text.
- GetTrainerSelectionIndex() - Get the index of the selected trainer service.
- GetTrainerServiceAbilityReq - ?.
- GetTrainerServiceCost(index) - Returns the cost of a specific trainer service.
- 发现不支持的代码:GetTrainerServiceDescription(index) - Returns the description of a specific trainer service.
- GetTrainerServiceIcon - ?.
- GetTrainerServiceInfo - ?.
- GetTrainerServiceLevelReq - ?.
- GetTrainerServiceNumAbilityReq - ?.
- GetTrainerServiceSkillLine - ?.
- GetTrainerServiceSkillReq(index) - Returns a String and Variable for the requirements of a specific trainer service.
- GetTrainerServiceStepIncrease() - ?.
- GetTrainerServiceStepReq - ?.
- GetTrainerServiceTypeFilter - Returns the status of a skill filter in the trainer window.
- GetTrainerSkillLineFilter() - ?;
- GetTrainerSkillLines() - ?;
- IsTalentTrainer - ?.
- IsTradeskillTrainer() - Returns 1 if trainer is for a tradeskill.
- IsTrainerServiceLearnSpell(index)
- IsTrainerServiceSkillStep() - ?.
- IsTrainerServiceTradeSkill() - ?.
- OpenTrainer() - ?.
- SelectTrainerService - ?.
- SetTrainerServiceTypeFilter - ?.
- SetTrainerSkillLineFilter() - ?.
发现不支持的代码:
Unit Functions (玩家/对象 功能函数)
These are functions which act on one or more units. Units are identified by UnitIds.
- AssistUnit("unit") - Instructs your character to assist the specified unit.
- CheckInteractDistance("unit",distIndex)
- DropItemOnUnit("unit") - Drops an item from the cursor onto a unit.
- FollowUnit("unit")
- InviteToParty("unit") - Invite a unit to a party.
- IsUnotOnQuest(questIndex, "unit") - Determine if the a specific unit is on a given quest (NEW IN 1300).
- SpellCanTargetUnit("unit") - Returns true if the spell awaiting target selection can be cast on the specified unit.
- SpellTargetUnit("unit") - Casts the spell awaiting target selection on the specified unit.
- StartDuelUnit("unit") - Challenge a unit to a duel.
- TargetUnit("unit") - Selects the specified id as the current target.
- REMOVED TargetUnitsPet("unit") - Targets the specified unit’s pet, if one exists. (Removed in 1.6 -- Flickering 14:12, 17 Jul 2005 (EDT))
- UnitAffectingCombat("unit") - Returns 1 if unit is in combat or has aggro. Turns nil otherwise or on death.
- UnitArmor("unit") - Returns the armor statistics relevant to the specified unit.
- UnitAttackBothHands("unit") - Returns information about the unit’s melee attacks.
- UnitAttackPower("unit") - Returns the Unit’s melee attack power and modifiers.
- UnitAttackSpeed("unit") - Returns the unit’s melee attack speed for each hand.
- UnitBuff("unit", index) - Retrieves info about a buff of a certain unit.
- UnitCanAssist("unit", "otherUnit") - Returns true if the first unit can assist the second, false otherwise.
- UnitCanAttack("unit", "otherUnit") - Returns true if the first unit can attack the second, false otherwise.
- UnitCanCooperate("unit", "otherUnit") - Returns true if the first unit can cooperate with the second, false otherwise.
- UnitCharacterPoints("unit") - ?.
- UnitClass("unit") - Returns the class name of the specified unit (e.g., "Warrior" or "Shaman").
- UnitClassification("unit") - Returns the classification of the specified unit (e.g., "elite" or "worldboss").
- UnitCreatureFamily("unit") - Returns the type of creature of the specified unit (e.g., "Crab").
- UnitCreatureType("unit") - Returns the classification type of creature of the specified unit (e.g., "Beast").
- UnitDamage("unit") - Returns the damage statistics relevant to the specified unit.
- UnitDebuff("unit", index) - Retrieves info about a debuff of a certain unit.
- UnitDefense("unit") - ?.
- UnitExists("unit") - Returns true if the specified unit exists, false otherwise.
- REMOVED UnitFacing("unit") - Returns the direction in which the unit is facing (Counterclockwise radians, from North) - REMOVED IN 1300 -- Flickering 16:51, 22 Mar 2005 (EST)
- UnitFactionGroup("unit") - Returns the faction group id and name of the specified unit. (eg. "Alliance") - string returned is localization-independent (used in filepath) -~~
- UnitHealth("unit") - Returns the current health, in points, of the specified unit.
- UnitHealthMax("unit") - Returns the maximum health, in points, of the specified unit.
- UnitInParty("unit") - Returns true if the unit is a member of your party.
- UnitInRaid - ?.
- UnitIsCharmed("unit") - Returns true if the specified unit is charmed, false otherwise.
- UnitIsCivilian("unit") - Returns true if the "unit" is a civilian.
- UnitIsConnected("unit") - Returns 1 if the specified unit is connected or npc, nil if offline or not a valid unit.
- UnitIsCorpse("unit") - Returns true if the specified unit is a corpse, false otherwise.
- UnitIsDead("unit") - Returns true if the specified unit is dead, nil otherwise.
- UnitIsDeadOrGhost("unit") - Returns true if the specified unit is dead or a ghost, nil otherwise.
- UnitIsEnemy("unit", "otherUnit") - Returns true if the specified units are enemies, false otherwise.
- UnitIsFriend("unit", "otherUnit") - Returns true if the specified units are friends (PC of same faction or friendly NPC), false otherwise.
- UnitIsGhost("unit") - Returns true if the specified unit is a ghost, false otherwise.
- UnitIsPVP("unit") - Returns true if the specified unit is flagged for PVP, false otherwise.
- UnitIsPVPFreeForAll("unit") - Returns true if the specified unit is flagged for free-for-all PVP, false otherwise.
- UnitIsPartyLeader("unit") - Returns true if the unit is the leader of its party.
- UnitIsPlayer("unit") - Returns true if the specified unit is a player character, false otherwise.
- UnitIsPlusMob("unit") - Returns true if the specified unit is a mob, more powerful than its nominal level, false otherwise (e.g., "elite" mobs)
- UnitIsTapped("unit") - Returns true if the specified unit is tapped, false otherwise.
- UnitIsTappedByPlayer("unit") - Returns true if the specified unit is tapped by a player, false otherwise.
- UnitIsTrivial("unit") - Returns true if the specified unit is trivial (Trivial means the unit is "grey" to the player. --Antiarc 16:02, 30 Jan 2005 (EST)), false otherwise.
- UnitIsUnit("unit", "otherUnit") - Returns true if the two specified units refer to the same unit (e.g., "player" and "target" can refer to the same unit), false otherwise.
- UnitIsVisible("unit") - true/false
- UnitLevel("unit") - Returns the level of the unit referred to by the local naming schema.
- UnitMana("unit") - Returns the current mana (or energy,rage,etc), in points, of the specified unit.
- UnitManaMax("unit") - Returns the maximum mana (or energy,rage,etc), in points, of the specified unit.
- UnitName("unit") - Returns the name of the unit referred to by the local naming schema.
- UnitOnTaxi("unit") - Returns 1 if unit is on a taxi.
- UnitPVPName("unit") - Returns unit’s name with PvP rank prefix (e.g., "Corporal Allianceguy").
- UnitPVPRank("unit") - Get PvP rank information for requested unit.
- UnitPlayerControlled("unit") - Returns true if the specified unit is controlled by a player, false otherwise.
- UnitPowerType("unit") - Returns a number corresponding to the power type (e.g., mana, rage or energy) of the specified unit.
- UnitRace("unit") - Returns the race name of the specified unit (e.g., "Human" or "Troll").
- UnitRangedAttack("unit") - Returns the ranged attack number of the unit.
- UnitRangedAttackPower("unit") - Returns the ranged attack power of the unit.
- UnitRangedDamage("unit") - Returns the ranged attack speed and damage of the unit.
- UnitReaction("unit", "otherUnit") - Returns a number corresponding to the reaction (aggressive, neutral or friendly) of the first unit towards the second unit.
- UnitResistance("unit", "resistanceIndex") - Returns the resistance statistics relevant to the specified unit and resistance type.
- UnitSex("unit") - Returns a code indicating the gender of the specified unit, if known.
- UnitStat("unit", statIndex) - Returns the statistics relevant to the specified unit and basic attribute (e.g., strength or intellect).
- UnitXP("unit") - Returns the number of experience points the specified unit has in their current level.
- UnitXPMax("unit") - Returns the number of experience points the specified unit needs to reach their next level.
发现不支持的代码:
Who Functions (玩家查询功能函数)
- GetNumWhoResults()
- GetWhoInfo(index)
- SendWho("filter") - Send a who request to the server.
- SetWhoToUI(toUIFlag) - Indicate that who request results should be delivered as WHO_LIST_UPDATE instead of to chat.
- SortWho(sortType)
发现不支持的代码:
UI Provided Functions
These functions are not part of the basic API, but instead are provided in the standard FrameXML UI code. They’re considered important enough to appear here.
- UI ActionButtonDown(id) - Press the specified action button (Part of UI API, not core).
- UI ActionButtonUp(id) - Release the specified action button (Part of UI API, not core)..
- UI BonusActionButtonDown - Trigger the specified bonus(pet or minion) action button. (Part of UI API, not core).
- UI BonusActionButtonUp - Release the specified bonus(pet or minion) action button. (Part of UI API, not core).
- UI GetText()
- UI message("text") - Displays a message box with your text message and an "Okay" button.
- UI MouseIsOver - Determines whether or not the mouse is over the specified frame.
- UI SetItemRef(itemLink) - Displays an item link box.
- UI SetPortraitTexture(texture,"unit") - Paint a Texture object with the specified unit’s portrait.
- UI SetPortraitToTexture(x,x)
- UI TakeScreenshot - Takes a screenshot.
- UI ToggleBackpack - Toggles your backpack open/closed.
- UI ToggleBag - Opens or closes the specified bag.
- UI ToggleCharacter - Toggles the character pane to the specified frame.
- UI ToggleCombatLog - Opens/closes the combat log.
- UI ToggleFramerate - Show/Hide the FPS.
- UI ToggleFriendsFrame - Opens/closes the friends pane.
- UI ToggleGameMenu - Opens/closes the game menu.
- UI ToggleMinimap - Turns the minimap display on/off.
- UI ToggleQuestLog - Opens/closes the quest log.
- UI ToggleSpellBook("bookType") - Shows the spellbook. Can show your spells or your pet’s.
- UI ToggleWorldMap - Turns the world map on/off.
- UI _ERRORMESSAGE(value) - Displays the script error dialog with optional text
发现不支持的代码:
Removed Functions (已经移除的功能函数)
These functions have been removed from the API in a previous patch.
- REMOVED AddSendMailCOD() - This does not appear to exist any longer. --Bug 18:43, 4 Feb 2005 (EST)
- REMOVED AddSendMailMoney() - This does not appear to exist any longer. --Bug 18:54, 4 Feb 2005 (EST)
- REMOVED Duel - Duels a specified user by name. (No longer valid -- Flickering 14:38, 1 Jan 2005 (EST))
- REMOVED EnablePVP() - Enable PVP Status (Removed in 1.4.0 patch -- Flickering 23:12, 19 Apr 2005 (EDT))
- REMOVED GetDate - Returns date of last (major) patch to World of Warcraft as a string. - Removed in 1.3.0..
- REMOVED PickupSendMailCOD(amount) - This does not appear to exist any longer. --Bug 15:45, 6 Feb 2005 (EST)
- REMOVED PickupSendMailMoney(amount) - This does not appear to exist any longer. --Bug 15:45, 6 Feb 2005 (EST)
- REMOVED PlayVocalCategory("category") - REMOVED IN 1300 -- Flickering 16:43, 22 Mar 2005 (EST)
- REMOVED ReportBug("text") - REMOVED IN 1300 -- Flickering
- REMOVED ReportNote("text") - REMOVED IN 1300 -- Flickering
- REMOVED ReportSuggestion("text","category") - REMOVED IN 1300 -- Flickering
- REMOVED RunMacro - This does not appear to exist anymore Flickering 18:41, 1 Jan 2005 (EST).
- REMOVED SaveMacros() - Save all macros to WTF/Account/user/macros-local.txt. (Removed in 1.6, macros are saved on exit -- Flickering 14:15, 17 Jul 2005 (EDT))
- REMOVED SetInventoryPortraitTexture()
- REMOVED TargetUnitsPet("unit") - Targets the specified unit’s pet, if one exists. (Removed in 1.6 -- Flickering 14:12, 17 Jul 2005 (EDT))
- REMOVED UnitFacing("unit") - Returns the direction in which the unit is facing (Counterclockwise radians, from North) - REMOVED IN 1300 -- Flickering 16:51, 22 Mar 2005 (EST)
发现不支持的代码:
Unknown Functions
Add functions whose group is not clear to this section, please remember to follow the Example Function template!
- GetActiveLevel(index)
- GetActiveTitle(index)
- GetAvailableLevel(index)
- GetAvailableTitle(index)
发现不支持的代码:
User Defined Functions
- added by VelvetPaw -Place your user defined functions here to enhance MODs. Please follow the Example Function template for a clear layout. (I didn’t find a better place to add this...I hope some users will find this a good idea and will add some of their own functions. So please feel free to add...)
- Lore Functions:
- SetLang(Lang, ToParty, ShowParty) - This allows you to handle the different settings in Lore.
发现不支持的代码:发现不支持的代码: