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 > Ascent Guides
Reload this Page Scripting LUA 101
Ascent Guides This section is for WoW emulated server, Ascent guides.
[NO QUESTIONS HERE]

Reply
 
LinkBack Thread Tools
Scripting LUA 101
(#1)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,965
Join Date: Oct 2007
Scripting LUA 101 - 02-29-2008

This is a guide on understanding and applying the LUA coding language adapted for WoW. This guide is just covering the basics of LUA and you will actually learn the code if you follow this guide correctly.

Table of Contents:
I. What Is LUA?
II. How do I start?
III. Unit Commands
IV. How To Use Your Script

I. What Is LUA?
LUA is a code used for many different things. It, for one, is used in the scripting of World of Warcraft addons, which we all love. It is also used for something else that applies directly to Emulator servers, scripting our creatures. You may ask, this must be hard to learn? Well its not. I learned within a week and got good at it while I was a noob. LUA is a basically a unspoken requirement for being a
Contributer and above, or knowing some scripting language. So you might as well learn now.

II. How do I start?
You start by following these few basic steps to LUA coding.

First, when you start EVERY script your first line needs to look something like this:

Code:
function NPCname_Phaseorfunction (pUnit, Event) 
  • The function command must always start each section of your script.
  • The NPCname_Phaseorfunction must always be there also. You may change this to whatever you like maybe. MurlocBoss_Entercombat. The first part generally is the name of the creature, and the second part is generally what or when it is happening.
  • The (pUnit, Event) must always be there and will never change.
Second, you must always have some content to go with it. Thats what the first line does, prepare for your "work" part. Follow the example:

Quote:
function NPCname_Phaseorfunction (pUnit, Event)
pUnit:SendChatMessage(Type, Language, "Message")
  • The pUnit: must always be there if it is a unit command. I will explain these later. It is also formal to indent your pUnit lines.
  • The SendChatMessage is the unit command. This is just an example and I will show you later. It should have NO spaces and should always follow the colon.
  • The (Type, Language, "Message") part is just an example. It should describe the command you wish to do (SendChatMessage in this case). There shouldn't be any spaces between the unit command and the description.
Third, you must follow up all your scripts with the word "end". Follow the example:

Quote:
function NPCname_Phaseorfunction (pUnit, Event)
pUnit:SendChatMessage(Type, Language, "Message")
end
The final component to understanding LUA is the RegisterUnitEvent (NPCid, When, "UpperExplain") command. This signals the end of your units. Look at this example:

Quote:
function NPCname_Phaseorfunction (pUnit, Event)
pUnit:SendChatMessage(Type, Language, "Message")
end
RegisterUnitEvent (10000, 1, "NPCname_Phaseorfunction")
You know what the number in the "when" part is by picking the time that it occurs based off these numbers.

Quote:
1 = Enter Combat
2 = Leave Combat
3 = Killed Target
4 = Died
5 = AI Tick
6 = Spawn
7 = Gossip Talk
8 = Reach Waypoint
9 = On Leave Limbo
10 = Player Enters Range
So if you wanted it to happen after he died put the number 4 in the second blank of the parenthesis.

Then, for the "Stuff" part, put what you put on the first line (the words) with the _ in them. make sure its in quotation marks.

Thats all you need to know for the basics of writing LUA for your creature.

III. Unit Commands
This is the part that you actually stop get to add stuff to your LUA script. I'm going to give examples of useful unit commands that most people will use. Remember to put the pUnit before these.

:SendChatMessage(Type, Language, "Message")
Self explanitory; it makes the NPC talk.
For type put one of these numbers:

Quote:
-1 = ADDON
0 = SAY
1 = PARTY
2 = RAID
3 = GUILD
4 = OFFICER
5 = YELL
6 = WHISPER
7 = WHISPER_INFORM
8 = EMOTE
9 = TEXT_EMOTE
10 = SYSTEM
11 = MONSTER_SAY
12 = MONSTER_YELL
13 = MONSTER_WHISPER
14 = CHANNEL
16 = CHANNEL_JOIN
17 = CHANNEL_LEAVE
18 = CHANNEL_LIST
19 = CHANNEL_NOTICE
20 = CHANNEL_NOTICE_USER
21 = AFK
22 = DND
23 = COMBAT_LOG
24 = IGNORED
25 = SKILL
32 = LOOT
83 = BATTLEGROUND_EVENT
87 = RAIDLEADER
88 = RAIDWARNING
For language put one of these numbers:
Quote:
0 = UNIVERSAL
1 = ORCISH
2 = DARNASSIAN
3 = TAURAHE
6 = DWARVISH
7 = COMMON
8 = DEMONIC
9 = TITAN
10 = THELASSIAN
11 = DRACONIC
12 = KALIMAG
13 = GNOMISH
14 = TROLL
33 = GUTTERSPEAK
35 = DRAENEI
For the last part put your message, make sure that its in "" (parenthesis).

:CastSpell(ID)
This one is easy to understand. Simply put the spell id in for the spell ID number. This can be found using WoWhead, Thottbot, or any WoW database website.

:SpawnGameObject(entryID, x, y, z, o, duration)
This one is also pretty self-explanitory. You MUST have an SQL file for the gameobject you want to spawn. So put the ID of the gameobject first, then the coordinates for the location you want it to spawn using the .gps command. For duration, remember its in milliseconds. Example: 10 seconds = 10000.

:SpawnCreature(entryID, x, y, z, o, faction, duration)
This one is the exact same as the one above, exept your spawning a creature. Make sure the SQL is already made for it. Use the faction NUMBER for the faction part. There are too many to list here, so just search for a Faction ID thread.

:Emote(Id)
This command is currently not working in Ascent. I will let you know when it is. Simply put the emote id for the id part. You can search for a thread on this also.

:AddItem(itemID, count)
For this, you must have the item already made through SQL and it be in your database. Put the ID for that id part, put the number you wish to give the player in the count part.

:SetScale(Number)
Simply put the number that you want to multipy the creatures size by. Default is 1.

:SetModel(DisID)
For this, you need a display ID of a creature you want this creature to morph to. Its basically .morph exept on a creature.

:LearnSpell(ID)
This one is easy. Put the spell ID you want to teach the player, not NPC, in this ID slot.

:PlaySoundToSet(ID)
This command plays a sound to the sourrounding area. To find the id, search for Sound ID List.

IV: How to use your script
Now you must save your script. Save it as Boss_CreatureName.lua is the tipical setup. Place in your scripts folder with has other LUA files in it. Make sure your compile/repack has LUA enabled and that its enabled in your ascent-world. Also, make sure there is a LUA dll in your script_bin folder. Now restart your server and have fun!

Hope this guide helped many of you struggling with understanding LUA. If you have suggestions/feedback PLEASE leave them. Have fun and enjoy!

-Eagle

Last edited by SectorSeven; 04-12-2008 at 10:58 PM.
Reply With Quote

Donate to remove ads.
(#2)
Old
Illidan1's Avatar
Illidan1 is Offline
Shan'do
Rep Power: 4
Reputation: 243
Illidan1 has a spectacular aura aboutIllidan1 has a spectacular aura aboutIllidan1 has a spectacular aura about
 
Posts: 2,256
Join Date: Jul 2007
Location: New Zealand
02-29-2008

Wicked guide mate, great job, x5, ok nvm need to spread
Great job mate!


Reply With Quote
(#3)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,965
Join Date: Oct 2007
02-29-2008

Thanks Illidan1!
Feedback is appreciated.
Did it help?
Was it organized?
Easy to read?
Questions I need answered
Reply With Quote
(#4)
Old
MysterioussouL's Avatar
MysterioussouL is Offline
Contributor
Rep Power: 3
Reputation: 315
MysterioussouL is a jewel in the roughMysterioussouL is a jewel in the roughMysterioussouL is a jewel in the roughMysterioussouL is a jewel in the rough
 
Posts: 419
Join Date: Feb 2008
Location: HeaveN
02-29-2008

Great job nice guide when i can



Reply With Quote
(#5)
Old
biglew2k99 is Offline
Banned
Rep Power: 0
Reputation: 7
biglew2k99 is an unknown quantity at this point
 
Posts: 22
Join Date: Jun 2007
02-29-2008

Very very nice intro to LUA, i hate LUA but this is a well structured tutorial so +REP
Reply With Quote
(#6)
Old
j9sjam3's Avatar
j9sjam3 is Offline
Knight
Rep Power: 2
Reputation: 14
j9sjam3 is on a distinguished road
 
Posts: 188
Join Date: Mar 2007
Location: Wales, UK
02-29-2008

Thanks man! Helped alot.
It was organized very well.
It was very easy to read as well

Quote:
Originally Posted by wareagle920 View Post
Thanks Illidan1!
Feedback is appreciated.
Did it help?
Was it organized?
Easy to read?
Questions I need answered


[Only registered and activated users can see links. ] <--- please click.

*working on a decent siggy*
Reply With Quote
(#7)
Old
jakjaklol1337 is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 2
Reputation: 1
jakjaklol1337 is an unknown quantity at this point
 
Posts: 34
Join Date: Oct 2007
Location: sweden
02-29-2008

I Love It Thx Thx!!
Reply With Quote
(#8)
Old
Zenneth's Avatar
Zenneth is Offline
Knight-Lieutenant
Rep Power: 1
Reputation: 14
Zenneth is on a distinguished road
 
Posts: 254
Join Date: Jan 2008
Location: Somewhere in my home
02-29-2008

about spawn time... is there a choice of haveing the spawn (gameobject id) for ever until server restart?
Reply With Quote
(#9)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,965
Join Date: Oct 2007
02-29-2008

Nope...that would be database edits not lua
Reply With Quote
(#10)
Old
Clain's Avatar
Clain is Offline
Contributor
Rep Power: 1
Reputation: 105
Clain will become famous soon enoughClain will become famous soon enough
 
Posts: 975
Join Date: Jan 2008
02-29-2008

This guide is great eagle =D. Organized, setup well, and everything. Got to spread meh 1, yes 1 thing of rep though lol.


Visual Basic .NET Coder
Need a program made? Contact me on msn for more details and prices.
Reply With Quote
(#11)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,965
Join Date: Oct 2007
02-29-2008

Thanks mate
Reply With Quote
(#12)
Old
Skype's Avatar
Skype is Offline
Contributor
Rep Power: 1
Reputation: 110
Skype will become famous soon enoughSkype will become famous soon enough
 
Posts: 106
Join Date: Dec 2007
03-01-2008

Very well done!
=)



Reply With Quote
(#13)
Old
runiker's Avatar
runiker is Offline
Contributor
Rep Power: 2
Reputation: 92
runiker will become famous soon enough
 
Posts: 433
Join Date: Nov 2007
03-01-2008

Great guide mate bring on the compition because i made same thing on same day as you lol sorry if it was a repost but i searched for a while and did not see yours


Reply With Quote
(#14)
Old
SectorSeven's Avatar
SectorSeven is Offline
Banned
Rep Power: 0
Reputation: 444
SectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really niceSectorSeven is just really nice
 
Posts: 1,965
Join Date: Oct 2007
03-01-2008

I don't care
Just trying to teach people LUA
Reply With Quote
(#15)
Old
nickeg's Avatar
nickeg is Offline
Master Sergeant
Rep Power: 1
Reputation: 15
nickeg is on a distinguished road
 
Posts: 106
Join Date: Jan 2008
03-01-2008

great guide + rep
Reply With Quote
Reply

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.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.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