Scripting LUA 101 menu

User Tag List

Page 1 of 9 12345 ... LastLast
Results 1 to 15 of 132
  1. #1
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Scripting LUA 101

    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:

    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:

    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:

    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.

    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:

    -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:
    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 08:58 PM.

    Scripting LUA 101
  2. #2
    Illidan1's Avatar Banned
    Reputation
    244
    Join Date
    Jul 2007
    Posts
    2,251
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wicked guide mate, great job, +Rep x5, ok nvm need to spread
    Great job mate!

  3. #3
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Illidan1!
    Feedback is appreciated.
    Did it help?
    Was it organized?
    Easy to read?
    Questions I need answered

  4. #4
    MysterioussouL's Avatar Banned
    Reputation
    339
    Join Date
    Feb 2008
    Posts
    431
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great job nice guide +Rep when i can

  5. #5
    biglew2k99's Avatar Member
    Reputation
    7
    Join Date
    Jun 2007
    Posts
    18
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very very nice intro to LUA, i hate LUA but this is a well structured tutorial so +REP

  6. #6
    j9sjam3's Avatar Member
    Reputation
    14
    Join Date
    Mar 2007
    Posts
    190
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks man! Helped alot.
    It was organized very well.
    It was very easy to read as well +Rep

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

    *working on a decent siggy*

  7. #7
    jakjaklol1337's Avatar Corporal
    Reputation
    1
    Join Date
    Oct 2007
    Posts
    33
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I Love It Thx Thx!!

  8. #8
    Ellenor's Avatar Active Member
    Reputation
    18
    Join Date
    Jan 2008
    Posts
    281
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    about spawn time... is there a choice of haveing the spawn (gameobject id) for ever until server restart?

  9. #9
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope...that would be database edits not lua

  10. #10
    Clain's Avatar Banned
    Reputation
    179
    Join Date
    Jan 2008
    Posts
    1,396
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This guide is great eagle =D. Organized, setup well, and everything. Got to spread meh 1, yes 1 thing of rep though lol.

  11. #11
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks mate

  12. #12
    Skype's Avatar Member
    Reputation
    133
    Join Date
    Dec 2007
    Posts
    116
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Very well done!
    =)


  13. #13
    runiker's Avatar Contributor
    Reputation
    105
    Join Date
    Nov 2007
    Posts
    501
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  14. #14
    SectorSeven's Avatar Banned
    Reputation
    444
    Join Date
    Oct 2007
    Posts
    1,948
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't care
    Just trying to teach people LUA

  15. #15
    nickeg's Avatar Member
    Reputation
    15
    Join Date
    Jan 2008
    Posts
    105
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    great guide + rep

Page 1 of 9 12345 ... LastLast

Similar Threads

  1. [Release] My Custom boss script (LUA)
    By Nilrac in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 06-17-2008, 03:57 AM
  2. [share] mini-tut on gossip scripts lua
    By b!atch in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 05-29-2008, 05:11 AM
  3. Need help with my script [lua]
    By Satzen in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 05-18-2008, 05:19 PM
  4. [Guide] Troubleshooting LUA 101
    By EcHoEs in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 04-10-2008, 08:23 AM
  5. script lua question
    By onilank in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 12-21-2007, 06:58 PM
All times are GMT -5. The time now is 02:47 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search