Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:Making a macro
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Advanced Scripting== ===What scripts ''can't'' do=== Scripts are very powerful tools that can make complex decisions based on a number of criteria. Because of this power, Blizzard has limited the types of things we're allowed to do with them in order to keep macros and AddOns from taking actions that should be controlled by the player. This section starts with what you can't do because you shouldn't to get your hopes up. While scripts do remain useful for quite a few purposes, you '''cannot use them to cast spells, use items, change your action bar page or affect your target in any way'''. You are limited to using the "secure" commands already shown for those tasks. ===Scripting=== The WoW UI is controlled by code written with the Lua scripting language. You can take advantage of this scripting system in a macro with the /run command (equivalent to /script--I use /run to save a few characters). The whole script must be on one line, though you can have multiple /run commands in a single macro. A full treatment of Lua and programming in general is well beyond the scope of this document. However, if you have some programming experience, you should head over to [http://www.lua.org/pil/ Lua.org] to learn the basics of Lua and if you don't have any programming experience, you may want to check out [http://pine.fm/LearnToProgram/ LearnToProgram] to get a foundation of the concepts used in scripts. Blizzard provides many functions (called the API) which the Lua scripts can use to control the UI. You can view the API and other features of the UI system over at [[Interface Customization]] (if you spend any considerable time with scripts and/or AddOns, WoWWiki will be indispensable). All the details of the UI environment can't be covered here, so some favorite scripts will be presented as an example. See the previously linked references and the [https://web.archive.org/web/20100429142618/http://forums.worldofwarcraft.com/thread.html?topicId=11381244&sid=1 old Mod author resources sticky]<ref names="modAuthorResources">{{ref web|work=Archive.org|url=http://forums.worldofwarcraft.com/thread.html?topicId=11381244&sid=1|title=0. Mod Author Resources|author=[http://us.battle.net/wow/en/character/draka/Cairenn/ Cairenn]|date=24-Aug-2006 01:57:29 PM PDT|archiveurl=https://web.archive.org/web/20100429142618/http://forums.worldofwarcraft.com/thread.html?topicId=11381244&sid=1|archivedate=29-Apr-2010}}</ref> for more information. The following macro (on which CCWarn AddOn is based on) will whisper everyone in your raid to change their targets if they have the same target as you. This is to help keep them from breaking the sheep that this macro casts as well. /cast Polymorph /run for i=1,GetNumRaidMembers()-1 do local u,t="raid"..i,"target"if UnitIsUnit(u..t,t)then SendChatMessage("Change targets! Trying to sheep...","WHISPER",nil,UnitName(u))end end<br /> There are two reasons that it looks as obfuscated as that. First, there is the 255 character limit (though there is a workaround in Part III); you often need to take certain shortcuts in order to get a script to fit in a macro. Second, you have to keep the entire script on one line. Under more ideal circumstances, that code would look more like: for i = 1, GetNumRaidMembers() - 1 do local unit = "raid"..i if UnitIsUnit(unit.."target", "target") then SendChatMessage("Change targets! Trying to sheep...", "WHISPER", nil, UnitName(unit)) end end
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)