<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1869873787401507826</id><updated>2011-06-08T07:30:51.622-07:00</updated><title type='text'>World of Warcraft Script Tutorials</title><subtitle type='html'>&lt;center&gt;World of Warcraft Lua Script Tutorials.&lt;br&gt;
This website is a part of wow300.co.cc&lt;/center&gt;</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>9</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-8911771801267539211</id><published>2008-09-26T00:27:00.000-07:00</published><updated>2008-09-26T00:43:29.285-07:00</updated><title type='text'>nil value</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;Description&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;br /&gt;A nil value means nothing. None. Null. Blank. void. But NOT zero.&lt;br /&gt;&lt;br /&gt;For example, if you are not targeting a unit and you execute a macro with UnitHealth("target"), then it will return nil.&lt;br /&gt;&lt;br /&gt;Any usage, of undeclared variables as parameters will cause error and the whole script will not run.&lt;br /&gt;nil is not called with quote wrap. It is used like a variable(without wraps)&lt;br /&gt;&lt;br /&gt;If you use functions that will return nil in if then else end statements, it will return nil and perform the else functions instead. &lt;br /&gt;&lt;br /&gt;For example, if you &lt;u&gt;don't have a target&lt;/u&gt; and you use this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run local x if UnitExists("target") then x="You have a target!" else x="You don't have a target" end message(x)&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Because the UnitExists("target") will return nil,it will say "You don't have a target".&lt;br /&gt;&lt;br /&gt;But if you have a target, function UnitExists("target") will return 1. Yeah as in ONE. When this is returned, then it will put to local variable x "You have a target!".&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-8911771801267539211?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/8911771801267539211/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=8911771801267539211' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/8911771801267539211'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/8911771801267539211'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/09/nil-value.html' title='nil value'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-8198862941467734932</id><published>2008-09-26T00:19:00.000-07:00</published><updated>2008-09-26T00:24:58.121-07:00</updated><title type='text'>Local Variables</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;Introduction&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;Variables, as I said in my tutorials, have two kinds, a global and a local variable.&lt;br /&gt;&lt;br /&gt;And yes, you can guess it there difference by there name. Global variables will retain it's value after the script, while the local variables will be nil after the script.&lt;/div&gt;&lt;br /&gt;&lt;div class="wowlua-subtitle"&gt;Usage and Declaration&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;br /&gt;local variables are declared by adding "local" before the variable declaration&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run local x=1&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;to declare more than one local, instead declare them by commas&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run local x,y=1,2&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;DO NOT USE LONG CHARACTERS FOR LOCAL VARIABLES.&lt;br /&gt;ONE CHARACTER VARIABLES IS THE BEST.&lt;br /&gt;&lt;br /&gt;so instead of using &lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run local targethp=UnitHealth("target")&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;use&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run local h=UnitHealth("target")&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-8198862941467734932?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/8198862941467734932/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=8198862941467734932' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/8198862941467734932'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/8198862941467734932'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/09/local-variables.html' title='Local Variables'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-7243298403868068214</id><published>2008-09-25T23:40:00.000-07:00</published><updated>2008-09-26T00:19:13.188-07:00</updated><title type='text'>Global Variables</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;Introduction&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;Variables, as I said in my &lt;a href="http://wowlua.blogspot.com/2008/07/ii-variables.html" target="_blank" &gt;variable tutorials &lt;/a&gt;, have two kinds, a &lt;u&gt;global&lt;/u&gt; and a &lt;u&gt;local&lt;/u&gt; variable.&lt;br /&gt;&lt;br /&gt;And yes, you can guess it there diffrence by there name. Global variables will retain it's value after the script, while the local variables will be nil after the script.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wowlua-subtitle"&gt;Usage&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;br /&gt;As you might have guess, using global variables will be useful for storing information specially when you are trying to make a macro that will depend in every click.&lt;br /&gt;For example, you can make a macro that counts like a lil child like this&lt;br /&gt;&lt;blockquote&gt;/run if x==nil then x=1 else x=x+1 end SendChatMessage(x)&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wowlua-subtitle"&gt;Characters&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;br /&gt;Unlike local variables, &lt;u&gt;global can make WoW Addon errors&lt;/u&gt;. This is because if you declared a global variable that is same as an addon variable, it will record your declared variable as the new addon variable.&lt;br /&gt;&lt;br /&gt;For example, if you made a global variable like DamageDone=100000000000000 and an add-on uses it on a damage meter, then your it will show you that the damage done is 100000000000000.&lt;br /&gt;&lt;br /&gt;To prevent this problem, &lt;br /&gt;&lt;ul&gt;&lt;li&gt;Do not use unnecessary globals.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If you got enough space,Make global variables at least 3 characters long&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Do not make global variables too readable. This kind of variables are often used in add-ons&lt;/li&gt;&lt;br /&gt;&lt;li&gt;If it still errors out your add-on, it's your add-on's fault. add-ons should have long global variables. This is because they do not have character limit unlike macros.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;Now once you're good enough and proficient enough, you can now make &lt;br /&gt;&lt;blockquote&gt;/run if x==nil then x=1 else x=x+1 end SendChatMessage(x)&lt;/blockquote&gt;&lt;br /&gt;into&lt;br /&gt;&lt;blockquote&gt;/run if cou==nil then cou=1 else cou=cou+1 end SendChatMessage(cou)&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Always make sure that your 3-character variable can still give a clue of what you want. For example, I made "cou" variable in above example to give a clue that it will be used in counting. Do not use "xxx" "yyy" or anything that won't give a definite clue because: When you are making alot of macros, you can accidentally replace your own variables.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-7243298403868068214?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/7243298403868068214/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=7243298403868068214' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/7243298403868068214'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/7243298403868068214'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/09/global-variables.html' title='Global Variables'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-931638381558665065</id><published>2008-07-23T09:26:00.000-07:00</published><updated>2008-09-16T00:21:31.874-07:00</updated><title type='text'>VI: Arrays</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;Arrays is a variable that is divided into many sections and this sections can be called separately and is represented by &amp;lt;Variable Name&amp;gt;[&amp;lt;index&amp;gt;] the best advantage of arrays versus ordinary variables is indexes can be called with a variable or function, therefore making it easier to put condition or make many variables.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;h4&gt;Declaring an array:&lt;/h4&gt;&lt;br /&gt; Before you can call an array value, you should declare it first or else it will not work&lt;br /&gt;&lt;blockquote&gt;/run x={}&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Placing a value in the array:&lt;/h4&gt;&lt;br /&gt;To insert a data on the array right away at declaration, just make:&lt;br /&gt;&lt;blockquote&gt;/run x={&amp;lt;value1&amp;gt;,&amp;lt;value2&amp;gt;,&amp;lt;value3&amp;gt;}&lt;/blockquote&gt;&lt;br /&gt;now, variable x[1] will be equal to &amp;lt;value1&amp;gt;, x[2] equal to &amp;lt;value2&amp;gt;. x[3] is equal to &amp;lt;value1&amp;gt;&lt;br /&gt;Note: you can add more or less than 3 values&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;To insert a data on an index:&lt;/h4&gt;&lt;blockquote&gt;/run x={} x[1]="hello"&lt;/blockquote&gt;&lt;br /&gt;Note: you cannot call the array variable alone eg. SendChatMessage(x)&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;To call an indexed value:&lt;/h4&gt;&lt;blockquote&gt;/run x={} x[1]="hello" SendChatMessage(x[1])&lt;/blockquote&gt;&lt;br /&gt;This is same as:&lt;br /&gt;&lt;blockquote&gt;/run x={"hello"} SendChatMessage(x[1])&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;h4&gt;To call an indexed value using a variable on index:&lt;/h4&gt;&lt;blockquote&gt;/run x={} x[1]="hello" y=1 SendChatMessage(x[y])&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;To get the number of values in the array(how many is indexed)&lt;/h4&gt;&lt;blockquote&gt;/run x={} x[1]="hello" x[2]="hi" message("array x has"..table.getn(x).." Values")&lt;/blockquote&gt;&lt;br /&gt;Note: One of the most useful usage of array is using them on loops.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua2"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-931638381558665065?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/931638381558665065/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=931638381558665065' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/931638381558665065'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/931638381558665065'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/07/vi-arrays.html' title='VI: Arrays'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-2455159396159709528</id><published>2008-07-22T18:17:00.000-07:00</published><updated>2008-07-31T13:20:11.886-07:00</updated><title type='text'>V: Looping</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;&lt;h4&gt;Introduction&lt;/h4&gt;&lt;br /&gt;Looping is doing a group of functions repeatedly until certain declared condition is achieved. This is useful in WoW macros to do functions that can be repeatedly done &lt;u&gt;without delay&lt;/u&gt;.&lt;br /&gt;&lt;br /&gt;The reason is, functions done in loop(or any other macro) are done in a very microscopic time distances. In other words every commands/functions are executed one by one but too fast to have anything to be done in between them, almost no time gap.&lt;br /&gt;&lt;/div&gt;&lt;div class="wow-lua1"&gt;&lt;br /&gt;&lt;h4&gt;Three Kind of loops&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;h5&gt;for do end&lt;/h5&gt;&lt;br /&gt;/run for (variable name)=(starting value),(end value) do (block of codes) end&lt;br /&gt;&lt;br /&gt;&lt;h5&gt;while do end&lt;/h5&gt;&lt;br /&gt;/run (variable name)=(starting value) while (condition) do (block of codes) &lt;functions&gt; end&lt;br /&gt;&lt;br /&gt;&lt;/functions&gt;&lt;h5&gt;repeat until&lt;/h5&gt;&lt;br /&gt;/run repeat (block of codes) until (condition)&lt;br /&gt;&lt;functions&gt;&lt;br /&gt;&lt;/functions&gt;&lt;h4&gt;for do end loop examples&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;Counting to 3&lt;br /&gt;&lt;blockquote&gt;/run for x=1,3 do SendChatMessage(x) end&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;when loop executes x will be equal to the starting number which is 1&lt;br /&gt;then it will send the chat message to say the value of variable x which is 1 so it will say in chat: 1&lt;br /&gt;then it will increase x by one so now, value of x is 2&lt;br /&gt;then it will send the chat message to say the value of variable x which is 1 so it will say in chat: 2&lt;br /&gt;then it will increase x by one so now, value of x is 3&lt;br /&gt;then it will send the chat message to say the value of variable x which is 1 so it will say in chat: 3&lt;br /&gt;&lt;br /&gt;After that x reached the value of the end value, it will not return to the loop again.&lt;br /&gt;After the loop is over, &lt;u&gt;variable used for the loop will be nil&lt;/u&gt;&lt;br /&gt;so you cannot use x anymore unless you declare a new value&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;While do end Loop Examples:&lt;/h4&gt;&lt;br /&gt;/run x=1 while x&lt;=3 then SendChatMessage(x) x=x+1 end   simulation: &lt;ol&gt;&lt;li&gt;variable x will be equal to 1&lt;/li&gt;&lt;li&gt;if variable x is less than or equal to 3, do if not, go proceed to end(step 6)&lt;/li&gt;&lt;li&gt;SendChatMessage(x) ==&amp;gt; say: 1&lt;/li&gt;&lt;li&gt;variable x = variable x(which is equal to 1) +1 so (x=1+1) so x=2&lt;/li&gt;&lt;li&gt;repeat step 2&lt;/li&gt;&lt;li&gt;end&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;Note: you can still add command blocks after the "end"&lt;br /&gt;Advantage of using While Loop:&lt;br /&gt;While loops can be added with conditions.&lt;br /&gt;Counter used in while loops doesn't become nil after the loop&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;repeat until loop example&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;/run x=1 repeat SendChatMessage(x) x=x+1 until x&gt;=4 &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Unlike other loop methods, this one doesn't execute if the condition is true, instead, if the condition is false. In the example above, the loop will not break until x is greater or equal to 4&lt;br /&gt;&lt;ol&gt;&lt;li&gt;x is equal to 1&lt;/li&gt;&lt;li&gt;SendChatMessage(1) ==&amp;gt; say: 1&lt;/li&gt;&lt;li&gt;x=x+1; x=1+1 ; x=2&lt;br /&gt;&lt;/li&gt;&lt;li&gt;check condition: is x&gt;=4? ; False, continue loop (repeat step 2)&lt;br /&gt;&lt;/li&gt;&lt;li&gt;SendChatMessage(2) ==&amp;gt; say: 2&lt;/li&gt;&lt;li&gt;x=x+1;x=2+1; x=3&lt;/li&gt;&lt;li&gt;check condition: is x&gt;=4? ; False, continue loop (repeat step 2)&lt;/li&gt;&lt;li&gt;SendChatMessage(3) ==&amp;gt; say:3&lt;/li&gt;&lt;li&gt;x=x+1;x=3+1; x=4&lt;/li&gt;&lt;li&gt;check condition: is x&gt;=4? ; True: 4=4, break the loop, continue to next block(none)&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-2455159396159709528?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/2455159396159709528/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=2455159396159709528' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/2455159396159709528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/2455159396159709528'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/07/looping.html' title='V: Looping'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-8160145873086134188</id><published>2008-07-21T06:52:00.001-07:00</published><updated>2008-08-01T08:15:01.054-07:00</updated><title type='text'>IV: if then else</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;if then else is a Lua function. The syntax format is if &amp;lt;condition&amp;gt; then  &amp;lt;functions to be done if condition is right&amp;gt; else  &amp;lt;function to be done if the condition is not right&amp;gt; end&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Relational Operators&lt;/h4&gt;&lt;br /&gt;==        means "is equal to" Note: it doesn't mean x will be 1 in x==1 it is only used to compare if "x is equal to 1"&lt;br /&gt;~=               means "is not equal to"&lt;br /&gt;&amp;gt;  means "greater than"&lt;br /&gt;&amp;lt;=        means "less than or equal to "&lt;br /&gt;&amp;gt;=        "greater than or equal to "&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;determining if you have full HP&lt;br /&gt;&lt;blockquote&gt;/run p="Player" p=UnitHealth(p)*100/UnitHealthMax(p) if p==100 then SendChatMessage("I Have Full HP") else SendChatMessage("My Hp isn't full") end&lt;/blockquote&gt;Note: you don't have to make the "else" part if you don't have anything to put there, instead of adding it,  just make &lt;span style="font-weight: bold;"&gt;if then end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Determining if variable is not nil&lt;/h4&gt;&lt;br /&gt;you can make a condition in &lt;u&gt;if statement&lt;/u&gt; that will only allow the command run only if the variable has a value: like&lt;br /&gt;&lt;blockquote&gt;/run if y then SendChatMessage("Variable Y contains this value: "..y) else SendChatmessage("VariableY doesn't have any value") end&lt;br /&gt;&lt;/blockquote&gt;this will say the else code "VariableY doesn't have any value" if y has no value&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Using Functions&lt;/h4&gt;&lt;br /&gt;Functions like UnitIsDead(), UnitIsPlayer(), UnitIsVisible() returns nil if false and return 1 if true, therefore it is same as example above&lt;br /&gt;&lt;blockquote&gt;/run if UnitIsDead("player") then message("you're dead") else SendChatMessage("You're alive") end&lt;br /&gt;&lt;/blockquote&gt;Note: always remember to add end after &lt;span style="font-weight: bold;"&gt;else &lt;/span&gt;or &lt;span style="font-weight: bold;"&gt;then&lt;/span&gt;&lt;br /&gt;&lt;h4&gt;Adding more than one condition&lt;/h4&gt;Adding more than one condition on the script will require you to use logical operators:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Logical Operators&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;and -- Makes the code execute only if both of the condition is true&lt;br /&gt;or -- Makes the code execute if one of the condition is true&lt;br /&gt;not -- Makes the code execute if none of the condition is true&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Logical Operator:  And&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;/run if UnitIsDead("target") and UnitIsPlayer("target") and UnitCanAssist("target","player") then message(UnitName("target").." is dead, and is an allied player") end&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Logical Operator: OR&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;/stopmacro [noharm]&lt;br /&gt;/run if (UnitCreatureType("target") == "Humanoid") or (UnitCreatureType("target") == "Beast") then SendChatMessage("Casting Polymorph on %t! stop attacking!") end&lt;br /&gt;/cast polymorph&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua2"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-8160145873086134188?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/8160145873086134188/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=8160145873086134188' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/8160145873086134188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/8160145873086134188'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/07/iv-if-then-else.html' title='IV: if then else'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-7024969569219816945</id><published>2008-07-21T05:56:00.000-07:00</published><updated>2008-07-31T11:00:41.762-07:00</updated><title type='text'>III: Operators</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;&lt;h4&gt;Introduction&lt;/h4&gt;&lt;br /&gt;Addition, Subtraction, Multiplication and Division and other math operations can only be done in numeric values and if you try it with strings you will get error and script will not run.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;h4&gt;Basic Operators&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;+  -- Addition&lt;br /&gt;-   -- Subtraction&lt;br /&gt;*  -- Multiplication&lt;br /&gt;/  -- Division&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Simple Addition&lt;/h4&gt;&lt;br /&gt;Examples:&lt;blockquote&gt;/run x=1+2 SendChatMessage(x)&lt;br /&gt;&lt;/blockquote&gt;This will say in chat&lt;br /&gt;&lt;blockquote&gt;3&lt;/blockquote&gt;&lt;h4&gt;Simple Subtraction&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run x=10-6 message(x)&lt;br /&gt;&lt;/blockquote&gt;This will make a window with this message:&lt;blockquote&gt;4&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Simple Multiplication:&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run x=1*2 message(x)&lt;/blockquote&gt;&lt;br /&gt;This will open a window with message:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;2&lt;/blockquote&gt;&lt;h4&gt;Simple Division&lt;/h4&gt;&lt;blockquote&gt;/run  message(50/10)&lt;br /&gt;&lt;/blockquote&gt;This will open a window with message:&lt;br /&gt;&lt;blockquote&gt;5&lt;br /&gt;&lt;/blockquote&gt;&lt;h4&gt;Simple multiple operators&lt;/h4&gt;&lt;blockquote&gt;/run x=(10-4)*3 message(x)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;This will make a window with this message:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;18&lt;/blockquote&gt;Note: you can also add it directly as a parameter to a function, it is not necessary to make an operation on a variable, BUT if the value is used TWICE or more in the script, make it a variable instead of direct ly using it as parameter&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Function Operations&lt;/h4&gt;&lt;br /&gt;  Using operators for functions is the same as using them on variables, just a lil bit confusing tho.&lt;br /&gt;&lt;br /&gt;Getting HP % of your character&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run p="Player" h=UnitHealth(p)*100/UnitHealthMax(p) message(h.."% HP")&lt;br /&gt;&lt;/blockquote&gt;This will create a window with of your health % like:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;100% HP&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-7024969569219816945?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/7024969569219816945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=7024969569219816945' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/7024969569219816945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/7024969569219816945'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/07/iii-operators.html' title='III: Operators'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-6630020649600160777</id><published>2008-07-21T05:29:00.000-07:00</published><updated>2008-07-31T10:56:00.730-07:00</updated><title type='text'>II: Variables</title><content type='html'>&lt;blockquote&gt;&lt;/blockquote&gt;&lt;div class="wowlua-subtitle"&gt;&lt;h4&gt;Introduction&lt;/h4&gt;&lt;br /&gt;using variables is essential to save characters and prevent overflowing to 255 character limit. Variable names may contain numbers or letters but must start with a letter. Normal variables will remain at there value except redeclared or replaced, until you log out.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class="wow-lua1"&gt;&lt;h4&gt;Declaring a Variable&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run x=1&lt;br /&gt;&lt;/blockquote&gt;in this example, variable x will contain a value of 1&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Using a Variable&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run x=1 SendChatMessage(x)&lt;br /&gt;&lt;/blockquote&gt;In this example it will say in chat:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;1&lt;/div&gt;&lt;br /&gt;FAQ: what if you call an undeclared variable?&lt;br /&gt;it will return &lt;span style="font-weight: bold;"&gt;nil&lt;/span&gt;.&lt;br /&gt;What is &lt;span style="font-weight: bold;"&gt;nil&lt;/span&gt;?&lt;br /&gt;nil means &lt;span style="font-weight: bold;"&gt;null&lt;/span&gt;,&lt;span style="font-weight: bold;"&gt;none&lt;/span&gt;,&lt;span style="font-weight: bold;"&gt;nothing&lt;/span&gt;,&lt;span style="font-weight: bold;"&gt;void &lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;u&gt;BUT NOT ZERO&lt;/u&gt;. Any usage, of undeclared variables as parameters will cause error and the whole script will not run.&lt;br /&gt;nil is &lt;span style="font-weight: bold;"&gt;not &lt;/span&gt;called with quote wrap. It is used like a variable(without wraps)&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Making string(non-numeric characthers) variables&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run x="Hello World" message(x)&lt;br /&gt;&lt;/blockquote&gt;Note: you will wrap strings with quote to make them variables&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Making function variables.&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;Some functions returns values if they are used. Like UnitHealth("target") which returns the health of your target.&lt;br /&gt;&lt;blockquote&gt;/run x=UnitHealth("target") message(x)&lt;br /&gt;&lt;/blockquote&gt;This will make a warning window with the health of your target. Note: you mustn't wrap it with quotes&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Conjucting(connecting) variables&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run a="I" b="Am" c=UnitName("player")&lt;br /&gt;&lt;/blockquote&gt;To conjunct or connect variables or constants, just add double period and the next variable or constant&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;&lt;blockquote&gt;/run a="I" b="Am" c=UnitName("player") SendChatMessage(a.." "..b.." "..c)&lt;br /&gt;&lt;/blockquote&gt;Note that: you will still proper quotations&lt;br /&gt;&lt;br /&gt;This will make you say in chat:&lt;br /&gt;&lt;blockquote&gt;I am &amp;lt;yourname&amp;gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;h4&gt;Redeclaring Variables&lt;/h4&gt;&lt;br /&gt;&lt;blockquote&gt;/run x=1 x=x+1 message(x)&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;Value will be: 2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Creating a local variable(stays only in that script)&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;Creating local variables are useful for macros that will not be used later. Declaring local variable will make the variable volatile, and that variable will be nil after the script is done&lt;br /&gt;&lt;blockquote&gt;/run local msg="This is a local Variable, variable x will be nil after it is declared local and will also be nil after this script is over"&lt;br /&gt;&lt;/blockquote&gt;now after the macro, even you connect a "/run message(msg)" , it will not return the msg&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-6630020649600160777?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/6630020649600160777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=6630020649600160777' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/6630020649600160777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/6630020649600160777'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/07/ii-variables.html' title='II: Variables'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1869873787401507826.post-5589094925506768447</id><published>2008-07-21T05:00:00.001-07:00</published><updated>2008-08-03T22:01:10.606-07:00</updated><title type='text'>I: Basics</title><content type='html'>&lt;div class="wowlua-subtitle"&gt;&lt;h4&gt;Introduction&lt;/h4&gt;&lt;br /&gt;World of Warcraft is built with a programming language called LUA.&lt;br /&gt;Calling a function is done by /run &amp;lt;FunctionName()&amp;gt;. Every function is case sensitive and won't work if not cased properly. Most ( but not all ) functions ends with () like LeaveParty() .&lt;br /&gt;/run also works like /script, obviously, /run is shorter, so you must use it.&lt;br /&gt;&lt;br /&gt;Note: Many functions are removed like casting spells on /run commands this also includes movement functions, targeting functions and many more that can be used for bots.These restricted functions are only accessible by Blizzard User Interface.&lt;br /&gt;&lt;br /&gt;Note: Always remember  that WoW scripts are typed in one line unlike other programming languages. Any incorrect line breaks ( pressed enter) will cause the script to break and may not work right.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="wow-lua1"&gt;&lt;h4&gt;Calling a Basic Function&lt;/h4&gt;To call a basic function like leaving a group, just type or make a macro with this code:&lt;br /&gt;&lt;blockquote&gt;/run LeaveParty()&lt;br /&gt;&lt;/blockquote&gt;&lt;h4&gt;Adding Function Arguments&lt;/h4&gt;&lt;br /&gt;To call a function with parameter aka arguments, just put them inside the parenthesis:&lt;br /&gt;&lt;blockquote&gt;/run SendChatMessage("hello")&lt;br /&gt;&lt;/blockquote&gt;Note: Strings(non number characters are always wrap in quotes or double quote or else they will work as variable(next chapter)&lt;br /&gt;Note: Double quotes(") must be closed with double quote(") and single quote( ' ) must be closed with single quote( ' )&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Calling Multiple Functions&lt;/h4&gt;&lt;br /&gt;To call two or more function, just add space or semi colon and add the function on the &lt;u&gt;same line&lt;/u&gt;&lt;br /&gt;&lt;blockquote&gt;/run SendChatMessage("hello") DoEmote("hi")&lt;br /&gt;&lt;/blockquote&gt;Note: each functions are called one by one, one after the other in a very microscopic time difference.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4&gt;Adding Multiple Arguments&lt;/h4&gt;&lt;br /&gt;To call a function with more than one argument aka parameter, add comma between each parameters. Note that you will still wrap them in quotes&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;/run SendChatMessage("hello","yell")&lt;br /&gt;&lt;/blockquote&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1869873787401507826-5589094925506768447?l=wowlua.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://wowlua.blogspot.com/feeds/5589094925506768447/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1869873787401507826&amp;postID=5589094925506768447' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/5589094925506768447'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1869873787401507826/posts/default/5589094925506768447'/><link rel='alternate' type='text/html' href='http://wowlua.blogspot.com/2008/07/subtitle-content1-test-content2.html' title='I: Basics'/><author><name>Albert</name><uri>http://www.blogger.com/profile/15033068546062895195</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://bp2.blogger.com/_P4crm7H8MAs/R3yuOYs3NkI/AAAAAAAAALE/yryymAlIr7A/S220/Graphic+Pen+Zoom.jpg'/></author><thr:total>0</thr:total></entry></feed>
