MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides

Homepage Register FAQ Members Mark Forums Read Advertise Marketplace FPSowned


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > WoW Emulator Server > Emulator Server Guides
Reload this Page Beginners LUA Guide From Nub to Expert [updating]
Emulator Server Guides Guides for working with World of Warcraft Emulator servers. Learn how to create a WoW Server here.
[NO QUESTIONS HERE]

Reply
 
LinkBack Thread Tools
Beginners LUA Guide From Nub to Expert [updating]
(#1)
Old
mager1794's Avatar
mager1794 is Offline
Contributor
Rep Power: 1
Reputation: 125
mager1794 will become famous soon enoughmager1794 will become famous soon enough
 
Posts: 317
Join Date: Feb 2008
Beginners LUA Guide From Nub to Expert [updating] - 06-19-2008

Mager1794's LUA Script Tutorial

Chapter 1 Beging LUA
Intro
Supplies
What is LUA
What is it for

Chapter 2 A First Look at LUA Script
My First Script
Described
It Wont Work

Chapter 3 Peeking at the Registers
What it does
How to do it
Explained alot!

Chapter 4 Script an AI
Whats an AI
Making the script(in detail)





Chapter 1

Intro

Hi There im Mager1794 you might now me from assisting you in Emulator discusion or one
of my past guides. Well here i am making another guide to help you master LUA as fast
as possible follow this guide and you'll be good enough to call yourself a dev in no time
maybe you will be contributing to MMowned who knows now lets begin

Supplies

All you trully need is a World of warcraft server with LUA enabled and a notepad
you could also use a one of the few LUA compilers but it wont matter anyway just
make sure you save as name.LUA files

What is LUA

LUA is a extremely basic programming language that is created through C++ the functions
in LUA will react with the C++ to create the script that you are writing its
pretty much an easy version of C++

What is it for

LUA can be used for many different things for one say you have an addon?? that is made
with LUA and some XML i believe also a great thing about LUA is scripting bosses quest
event and more the powers of lua are limitless if your DLL file is made for it : )


Chapter 2

My First Script

lets begin writing our very first script now with most programming languages they always do
the little hello world thing and i dont like to be the one to break traditions so..

lets begin

[please type this rather than copy& paste from personal expieriance i feel it helps the
language sink in a little better]

Code:
function firstscript_OnCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Hello World")
 end
end
Described

now lets break it down a bit

function
firstscript_OnEnterCombat(pUnit, Event)
pUnit:SendChatMessage(14, 0, "Hello World")
end
end

excellent now its broken down... wait thats no help

here we go

function - its the starting command for mostly every script you will ever write with out you
just have a notpad with a weird file extension

firstscript_OnEnterCombat(pUnit, Event) - its the name of the your function
(except the pUnit, Event part) the OnEnterCombat and Event work together to create the
function to happen on a certain event in this case it is on entering combat

pUnit:SendChatMessage(14. 0, "Hello World") - its your command in this function cause it to
speak the 14 is how it will be said(yell, whisper, broadcast etc) the 0 is the language
which will be your common langauge to use cause all races can understand it and the "Hello World"
is the message to be stated

end
end - there just ending the function kinda obvious

It Wont Work

Well if you already know a little about LUA then you should know why its not working
the function isn't registered yet all you have is a function no mob set for it or nothing
so we have to register it im not gonna go into it cuase that is gonna be the next chapter
but
Code:
RegisterUnitEvent(123456,1,"firstscript_OnEnterCombat:)
Chapter 3 : Peeking at the Registers

What it does

The Registers of course keep track of all the money we get from people at our
convienient store... wait...this is LUA right ooops

The Registers are what enable us to have the functions declared onto
mobs and NPC etc for now im just going to show RegisterUnitEvent but later
in the guide there will be more so be ready

How to do it

its really simple type this with me

"R" "e" "g" "i" "s" "t" "e" "r"

then erase and type

RegisterUnitEvent(

thats the basic function for the registering a unit
but for it to work you need (npc spawn ID,EventNumber,"Name_Event")

let me help you figure this stuff out

Explained Alot

EVENTNUMBER!!! *GASP*
ZOMG!! WHATS THAT
well its the number for the event
here is what i know (theres probably more)

1 - EnterCombat = It Sets the function off when it enter combat
2 - LeaveCombat = Its Set off the function when it leave combat
3 - KillTarget = Sets the function off whne it kill the target
4 - Died = Sets the function off when it dies
5 - AItick = Sets off the function when its AI (pretty much any spell used) ticks
6 - Spawn = Sets off the function on spawn
7 - Gossip = Sets the function off on gossip which is when you speak to it
8 - Waypoint = Sets off when a waypoint is reached
9 - leavelimbo = I believe its on the targets revival
10 - playerenter= When the player enters the targets area

now just insert the NPC Spawn ID and the event name and wha lah you got a
function and its registered

Chapter 4 Scripting an AI

What is AI?

AI stand for Artificial Intelligence now im not saying that i teach you this and you can
go program a robot with it or something becuase well we all know that only SectorSevens
that awesome lol. But you can program your bosses/mobs etc. with it whats the fun of a
fight if all they do is attack wheres the excitement ill tell you where on my server
with fully scripted instances its unfair for you so heres your shot to have you instances
script

Making the script(in detail)

Lets begin with a normal function

Code:
function mob_spell(unit)
notice how i used non of the identifiers from the previous chapter why is that..
its because this a pretty much a phase and i wont register it with RegisterUnitEvent
it will be done with RegisterEvent (we'll get there dont worry)

now after we do that lets make him speak with it so add

Code:
function mob_spell(unit)
Unit:SendChatMessage(12,0,"Eat the Fire")
ok so now we have him talking a fire so we dont want him to do frost or shadow or something
so always watch for that now lets make him cast the spell

Code:
function mob_spell(unit)
Unit:SendChatMessage(12,0,"Eat the Fire")
Unit:CastSpell(40255)
great that is done lets just add the end

Code:
function mob_spell(unit)
Unit:SendChatMessage(12,0,"Eat the Fire")
Unit:CastSpell(40255)
end
great were finished now were just making a mob script here so im having only one spell
but you can put as many as you wish (practice as much as you want)

ok so we have that now lets just make a simple OnCombatScript

Code:
function mob_OnEnterCombat(unit, event)
ok so we have that set up now here is where we shall register the spell

Code:
function mob_OnEnterCombat(unit, event)
Unit:RegisterEvent("function name",how often it will be done, 0)
ok so we have that now change the function name to
mob_spell
and the how often we want to be 7 seconds and since its in miliseconds just add 3 0's to
the end of it

and there ya have it its registered
now just add a SendChatMessage if you want and your done

Heres a Full Script (of that mob) Example

Code:
function mob_spell(unit)
Unit:SendChatMessage(12,0,"Eat the Fire")
Unit:CastSpell(40255)
end

function mob_OnEnterCombat(unit, event)
Unit:RegisterEvent("mob_spell",7000, 0)
end
thats all i have for now i will update this guide even more til im finally finished
leave you thoughts plz its 3 am so im goin to bed ill get some more in tommorow


Reply With Quote

Donate to remove ads.
Reply

Donate to remove ads.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On




Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0
vBulletin Skin developed by: vBStyles.com


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342