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 Lua Scripting Guide
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
Lua Scripting Guide
(#1)
Old
Soularis's Avatar
Soularis is Offline
Contributor
Rep Power: 2
Reputation: 106
Soularis will become famous soon enoughSoularis will become famous soon enough
 
Posts: 408
Join Date: Apr 2007
Location: <Hell>
Lua Scripting Guide - 06-08-2008

LUA SCRIPTING GUIDE


What you need:


=======================
1. Notepad
2. Lua Enabled on your server
=======================



Alirte. I will give you a basic example of an Lua code and explain it to you.



function Captain_Dementox_Enrage(pUnit, event)
if pUnit:GetHealthPct() < 40 then
pUnit:RemoveEvents()
pUnit:PlaySoundToSet(11273)
pUnit:CastSpell(33653)
pUnit:CastSpell(36900)
pUnit:SendChatMessage(11,0,"I have not come this far to be stopped! The future I have planned will not be jepordized! Now you will taste true power!")

end

function Captain_Dementox_onCombat (pUnit, Event)
pUnit:PlaySoundToSet(11263)
pUnit:SendChatMessage(11, 0, "Alas, sometimes one must take matters into one's own hands.")
pUnit:RegisterEvent("Captain_Dementox_Enrage",1000,0)
end

function Captain_Dementox_onLeaveCombat(pUnit, Event)
pUnit:RemoveAura(33653)
pUnit:RemoveAura(36900)
pUnit:RemoveEvents()
end

function Captain_Dementox_onDeath(pUnit, Event)
pUnit:PlaySoundToSet(11204)
pUnit:SendChatMessage(11,0,"Forgive me my prince....I have..failed...")
pUnit:RemoveAura(33653)
pUnit:RemoveAura(36900)
pUnit:RemoveEvents()
end

RegisterUnitEvent (26, 1, "Captain_Dementox_onCombat")
RegisterUnitEvent (26, 2, "Captain_Dementox_onLeaveCombat")
RegisterUnitEvent (26, 4, "Captain_Dementox_onDeath")



1. Alrite the word function is always needed. What it does is basically tell the script what you are GOING to do. The names can be whatever you want.

2. The parenthesis (pUnit, Event) declares what you ARE doing.
pUnit means npc/player, event means what it is. They are not so important. You just have to know they have to be there.

3. Now I will list the basic commands in this code:

1. pUnit:PlaySoundToSet(####) <--Plays a sound to the surrounding area

2.pUnit:SendChatMessage(11,0,"Forgive me my prince....I have..failed...") <---Makes the NPC say what is in quotes

3. pUnit:RemoveAura(####) <---Removes the spell ID that is on the unit

4. punit:CastSpell(####) <---Casts the spell ID number on itself NOT on a player

5. pUnit:GetHealthPct() <--- This allows the script to get the current percentage of the mob's health at the time it is executed.





REGISTERING YOUR EVENTS


Okay that is is a breakdown of the code. However in order to run these functions you need to tell the script when to run them and how to run them. This goes at the end of your code. In this example:


RegisterUnitEvent (26, 1, "Captain_Dementox_onCombat")
RegisterUnitEvent (26, 2, "Captain_Dementox_onLeaveCombat")
RegisterUnitEvent (26, 4, "Captain_Dementox_onDeath")

What we are telling the script to do is:

1. run the event Captain_Dementox_onComat
2. run the event Captain_Dementox_onLeaveCombat
3. run the event Captain_Dementox_onDeath



Now how does the script know when these events occur? Well that is what the little numbers are:


[qoute]
RegisterUnitEvent (26, 1, "Captain_Dementox_onCombat")
RegisterUnitEvent (26, 2, "Captain_Dementox_onLeaveCombat")
RegisterUnitEvent (26, 4, "Captain_Dementox_onDeath")
[/qoute]

The number 1 signifies that this will run once the mob enters combat
The number 2 signifies that this will run when you run from a mob
4. signifies that this will run when the mob is killed.

These numbers are hard coded into your Lua engine. You can't just go making numbers up as the engine will not recognize what you are doing.

That about does it for the explanation. I have requested for an Lua section to be created on the site so that all of you may post your scripts or ask for help on them. We will see if it is done. For now I will do the best I can to help you out from here. Lua is not very easy to explain. The best way to learn is by trial and error. I will post some smaller scripts as well that you can look at.

Once you create a code in notepad you must save it as a .lua file. and then put it into the scripts folder in your ascent directory NOT the scripts_bin folder.

By default Lua is disabled in ascent, you must enable it if you compile your own version. So you will find out if your server has it when you put scripts into the script folder of ascent and see if it loads up. Many repacks do have it enabled however.

________________________________________________________________________________
__________________

First we will find the mob we want to use for our script. Lets take the Kobold Vermin. Its creature ID in thottbot is 6. So lets say we want to Kobold to say "You can kiss my ass." when you aggro it. So here we go. Let start off with opening notepad. Here is the script:

We want to first make the event or function so lets give it a simple name like "Kobold Aggro" so here is how we will write the event:



function koboldAggro(pUnit, event)This is the name of the function. All your events/functions will have the word function before it. The (pUnit,event) is the type of function it is. This is going to be the majority of all your scripts. When more advaced stuff comes later on these will change.


Okay now for the next part. We want to make the Kobold yell out his line rite? So here is how we do this:


pUnit:SendChatMessage(12, 0, "You can kiss my ass.")Now for the breakdown.

pUnit: is used becasue that is what you called it at the top in the (pUnit,event). This will be your most common pUnit

Now the SendChatMessage(12, 0, "You can kiss my ass.") is broken down as follows.

SendChatMessage -- this is the command we want to use to make the mob speak.
12 -- means yell. So it will appear in yell
0 -- means Universal language. Basically everyone can understand it
"You can kiss my ass" -- what the mob will say.



Now for the last part of the code.




endThis is simply as it seems. This ends the function. Make sure your ends are placed properly or your script won't work. Generally speaking you only need 1 end at the end of your function. When you get into if statements and nested statements you will need more.


So lets look at the script as a whole.

function koboldAggro(pUnit, event)
pUnit:SendChatMessage(12, 0, "You can kiss my ass.")
end



Spacing is very particular in Lua so is captials so make sure you don't make any mistakes with this. Plus everyone likes a neat code it makes things easier to read. Well we are almost done. So now we need to call this function rite? So here is how we do this.

We make a special function. I made up a name for these type of functions. I call them Primary Functions. (I don't know if that is what they are really called. ) But I call these primary functions becasue you need them to intiate your script. So lets take a look at one primary function rite now.

We call this one EnterCombat. Basically what it does is when you aggro a mob it will run the appropriate script so here is how we write this function.


CODE
CODE
RegisterUnitEvent (6, 1, "koboldAggro")Now what is this? Alrite well this as you can see doesnt have the word function written before it. That is becasue it is a special function that is loaded when the server starts. There are only 10 of these that can be used. Check the Commands sticky for examples.


Now the numbers in the code are these. the 6 is the entry ID of Kobold Vermin. The 1 means OnAggro or EnterCombat and the "koboldAggro" is the name of the function we made up top. So now ALL Kobold Vermins will do this function when you aggro them. Well I hope you understood this and it helped you out a bit. If you have more questions feel free to make a thread.

Here is your end product:

CODE
CODE
function koboldAggro(pUnit, event)
pUnit:SendChatMessage(12, 0, "You can kiss my ass.")
end


RegisterUnitEvent (6, 1, "koboldAggro")
Now save your script as Kobold.LUA and stick it in the scripts folder of your ascent server and restart your server. It is important that you save it as an lua or LUA file or it won't work.



Good Luck
Happy Scripting!

Here are things to remember about Lua:

It is EXTREMLY case sensative.
It is Precise
And you must be neat.


All Made By Halestorm And if someone else from wow-v kills me bc of its there work then blame hale



Reply With Quote

Donate to remove ads.
(#2)
Old
Power of Illuminati's Avatar
Power of Illuminati is Offline
Contributor
Rep Power: 2
Reputation: 168
Power of Illuminati has a spectacular aura aboutPower of Illuminati has a spectacular aura about
 
Posts: 1,369
Join Date: May 2008
Location: Pyramid of Anubis
06-08-2008

Wrong section. Move it!


Reply With Quote
(#3)
Old
TheSpidey's Avatar
TheSpidey is Offline
Emulator Server Specialist

Rep Power: 2
Reputation: 229
TheSpidey has a spectacular aura aboutTheSpidey has a spectacular aura aboutTheSpidey has a spectacular aura about
 
Posts: 1,731
Join Date: Jan 2008
06-08-2008

You didn't even bother adding proper code boxes eh?


Reply With Quote
(#4)
Old
LordDarkling is Offline
Master Sergeant
Rep Power: 2
Reputation: 15
LordDarkling is on a distinguished road
 
Posts: 85
Join Date: Jul 2007
Location: In your pants
06-08-2008

... umm why do people keep making LUA guides? there are so many, such as mine, gastric's and SEVERAL others... also wrong section


Zenkotsu: Umm do you really think we can kill that thing?
Sesshomaru: Yes... trust me Gruul is EASY for two people
Reply With Quote
(#5)
Old
runiker's Avatar
runiker is Offline
Contributor
Rep Power: 1
Reputation: 89
runiker will become famous soon enough
 
Posts: 415
Join Date: Nov 2007
06-09-2008

Wrong section - repost - and no code boxes - bad color i give this thread a 1/10 jsut for trying. I have made a lua guide but it has not been active for while i guess i will update soon and bump it...


Reply With Quote
(#6)
Old
Soularis's Avatar
Soularis is Offline
Contributor
Rep Power: 2
Reputation: 106
Soularis will become famous soon enoughSoularis will become famous soon enough
 
Posts: 408
Join Date: Apr 2007
Location: <Hell>
06-09-2008

Quote:
Originally Posted by runiker View Post
Wrong section - repost - and no code boxes - bad color i give this thread a 1/10 jsut for trying. I have made a lua guide but it has not been active for while i guess i will update soon and bump it...


because people need help some people r noobs 2 privte servers
thats why...



Reply With Quote
(#7)
Old
kajdzas's Avatar
kajdzas is Offline
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 1
Reputation: 1
kajdzas is an unknown quantity at this point
 
Posts: 13
Join Date: Mar 2008
Location: Azeroth (Mulgore)
06-16-2008

Soularis, can you teach me "spell lua scripts"??? (if i aggro mob (kobold) he will cast some spell every 5 sec) pls send me guide to a MMOwned mail, THX!
Reply With Quote
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