[Guide] Another LUA Scripting Guide menu

User Tag List

Results 1 to 14 of 14
  1. #1
    Bapes's Avatar Banned
    Reputation
    16
    Join Date
    Feb 2008
    Posts
    124
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Guide] Another LUA Scripting Guide

    I have noticed alot of LUA scripting guides out there. Well I tried all of them and never got it until I took a example and built off of that. I'm making this guide for people that were just like me, just can't figure scripting out.

    Understanding LUA -

    LUA is a type of a file (.lua) obviously. There are three parts to a LUA scripting

    1. Function - Function is basically the headline of the script you are going to make.
    2. Event - The actual event is what you want the mob to do. Each time you want
      a different even you must use a different function and registration.
    3. Registering - When you register the function.


    Note: Make sure you end every function with

    Code:
     end
    end
    Now that you understand LUA we will put our schema to the test!

    Note: Everything in red will be edited to your preferences.

    Step 1 - Creating a function (see above for definition).

    Open notepad. (Start, All programs, Accessories, Notepad). We will be using notepad to edit all of our scripts.

    Copy the following script intro your notepad.

    Code:
    function Phase_1(pUnit, Event)
    As said before everything in red will be edited to our preferences. So that is the starting of every script that is telling the registration what to register.
    You can make it what ever you want. DO NOT USE THE SAME FUNCTION NAME FOR ANY SCRIPT! If you do use the same one it will run the wrong script. I generally use Phase_(random number that is easy to remember).

    Note: Make sure you end every function with

    Code:
     end
    end
    Step 2 - Advance Commands (Example - if pUnit:GetHealthPct() < 90 then)

    These commands are for making the functions to start at a certain heath %.
    They also include what the mob you are scripting to target. I will have a list of all commands at the bottom of the page to save room.

    For example if you want the mob to do the function at 90% the code would be

    Code:
     if pUnit:GetHealthPct() < 90 then
    Note: I always put the following code after the code above.

    pUnit:RemoveEvents();
    The GetHealthPct you can change that to other advance commands I have at the bottom of the page.

    Step 3 - The Event (see above for definition).

    This is the actual "body" of the function. The event determines what you want the mob to do with that function. I will have a list at the end of this post with alot of commands you can do with this I will go into some detail now.

    If you want the mob to cast a spell at that phase you would use -

    Code:
      pUnit:CastSpell(SPELL ID HERE)
    You change the red park in brackets to the spell id you want. (You can wow head or thottbot.

    If you want the mob to say something in that phase you would use -

    Code:
      pUnit:SendChatMessage (Type, Language, "What you want mob to say.")
    Again, I will have a list of all the codes at the bottom of the post.

    Step 4 - Registering the function (see above for definition).

    This is the part were u tell the mob what you want it to do. I will have a list of them at the bottom of the post.

    Here is a example of registering the function we just made.

    Code:
      pUnit:RegisterEvent("Name of the function you are registering",Time in milliseconds, How many times usually 0)
    You put this at the bottom of your script or in the phase.

    Step 4 - Registering the mob.

    This is the part were you tell the script what mob to edit. The code for this is...

    Code:
    RegisterUnitEvent(NPC ID, 1, "Name of function")
    Step 6 - Adding this script to your server.

    On notepad go to File, Save As, save it in your C:\AC Web Ultimate Repack\Ascent\scripts folder as .lua MAKE SURE YOU SAVE AS ALL FILE TYPES!

    Congratulations you have just completed a script. Here is a example of a full script.

    Code:
    function Phase_1(pUnit, Event)
     if pUnit:GetHealthPct() < 95 then
      pUnit:RemoveEvents();
      pUnit:CastSpell(40737)
      pUnit:RegisterEvent("Phase_224",1000, 0)  -  NOTE:  ONLY IF YOU ARE GOING TO HAVE ANOTHER FUNCTION AFTER THIS YOU WOULD USE THAT TO REGISTER THE NEXT FUNCTION.  -Delete this
     end
    end
    
    function Warrior_start1(pUnit, Event)
     pUnit:RegisterEvent("Phase_114",1000, 0)
     pUnit:SendChatMessage (11, 0, ", you will not live to see the light of day!")
    end
    
    RegisterUnitEvent(11529, 1, "Warrior_start1")
    This script will have mob number 11529 cast spell 40737 at 95% and also make the mob say $N, you will not live to see the light of day! when he enters combat. The last registration is usually registering ones like entercombat or death.


    As I promised a list of commands -

    Advance commands -

    • pUnit:GetName()
    • pUnit:GetX()
    • pUnit:GetY()
    • pUnit:GetZ()
    • pUnit:GetO()
    • pUnit:IsPlayer() then
    • pUnit:IsCreature() then
    • pUnit:HasFinishedQuest(questID) then
    • pUnit:GetItemCount(itemID) < # then
    • pUnit:GetHealthPct() <% then
    • pUnit:GetUnitBySqlId(sqlID)then
    • pUnit:GetClosestPlayer() then
    • pUnit:GetRandomPlayer(flags)
    • pUnit:GetRandomFriend()
    • pUnit:GetMainTank()
    • pUnit:GetAddTank()
    • pUnit:GetTauntedBy()
    • pUnit:GetSoulLinkedWith()


    Event Commands - (Not all commands search for more).

    • pUnit:SendChatMessage(type, language, "message")
    • pUnit:MoveTo(x, y, z, o)
    • pUnit:FullCastSpell(spellID)
    • pUnit:SpawnGameObject(entryID, x, y, z, o, duration)
    • pUnit:SpawnCreature(entryID, x, y, z, o, faction, duration)
    • pUnit:CastSpell(spellID)
    • pUnit:PlaySoundToSet(soundID)
    • pUnit:SetMovementType(movementType)
    • pUnit:SetHealthPct(value)
    • pUnit:SetNPCFlags(flags)
    • pUnit:SetModel(modelID)
    • pUnit:SetScale(scale)
    • pUnit:SetFaction(factionID)


    Language Code -

    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<Talk>-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 = SKILL32 = LOOT
    83 = BATTLEGROUND_EVENT
    87 = RAIDLEADER
    88 = RAIDWARNING

    Thank you reading my guide and I hope that it helps everybody that reads it.
    If you need to contact me you can either send me a P.M. or send me a message at aim or msn... Aim - Bapesyo14 Msn - [email protected]


    Thanks again,

    Bapes
    Last edited by Bapes; 04-10-2008 at 07:34 PM.

    [Guide] Another LUA Scripting Guide
  2. #2
    MisterEMU's Avatar Banned
    Reputation
    38
    Join Date
    Feb 2008
    Posts
    307
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice +Rep filler

  3. #3
    Lich King's Avatar Contributor
    Reputation
    100
    Join Date
    May 2007
    Posts
    911
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice guide, easy to understand

  4. #4
    Bapes's Avatar Banned
    Reputation
    16
    Join Date
    Feb 2008
    Posts
    124
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys!

  5. #5
    Bapes's Avatar Banned
    Reputation
    16
    Join Date
    Feb 2008
    Posts
    124
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    60+ views 2 replies?!

  6. #6
    daniel4166's Avatar Member
    Reputation
    8
    Join Date
    Sep 2007
    Posts
    152
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Nice...

    Nice Guide +Rep

  7. #7
    Bapes's Avatar Banned
    Reputation
    16
    Join Date
    Feb 2008
    Posts
    124
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks,


    Bapes

  8. #8
    Cursed's Avatar Contributor
    Reputation
    270
    Join Date
    Jun 2007
    Posts
    1,380
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good guide for beginners to understand such a script +rep 2x

  9. #9
    reyintazmaster's Avatar Member
    Reputation
    1
    Join Date
    Nov 2007
    Posts
    12
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice guide, +rep
    But just one correction I saw now

    You said that you were supposed to use
    Code:
     end
    end
    at the end of all funtions, its only 2 end you are going to use.

    The using of the 2 ends in your funtions, is beacuse of the if-statement, it needs to be stoped with a "end", else you would get a error, its uncommon to not have a if-statement in a lua script, beacuse its kinda needed. But if you dont use it, and you use 2x ends. You will have a error
    Last edited by reyintazmaster; 04-16-2008 at 06:46 AM.

  10. #10
    spectrez's Avatar Member
    Reputation
    1
    Join Date
    Apr 2007
    Posts
    7
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    nice :)

    Nice work this helped alot

  11. #11
    Bapes's Avatar Banned
    Reputation
    16
    Join Date
    Feb 2008
    Posts
    124
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank


    Bapes

  12. #12
    JCL's Avatar Member
    Reputation
    2
    Join Date
    Apr 2008
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice, good tut!

  13. #13
    Bapes's Avatar Banned
    Reputation
    16
    Join Date
    Feb 2008
    Posts
    124
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys!

    Bapes

  14. #14
    dancol's Avatar Member
    Reputation
    1
    Join Date
    Mar 2008
    Posts
    14
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    good tut

    good tutor man, will use soon. Could hyou try to get a bigger list of event commands

    +Rep

Similar Threads

  1. [Lua Script] Another Lua script that won't work
    By tyeeeee1 in forum WoW EMU Questions & Requests
    Replies: 0
    Last Post: 03-09-2012, 02:24 PM
  2. [RELEASE] Yet another Lua script
    By Zaeran in forum WoW EMU General Releases
    Replies: 8
    Last Post: 12-06-2008, 09:12 PM
  3. [Guide] Lua Scripting Guide is here [Updating]
    By Illidan1 in forum WoW EMU Guides & Tutorials
    Replies: 93
    Last Post: 11-04-2008, 06:56 PM
  4. LuA SCRIPTING (guide)
    By Dee2001 in forum WoW EMU Guides & Tutorials
    Replies: 5
    Last Post: 03-05-2008, 11:43 AM
  5. [GUIDE] How to activate LUA scripts
    By ~SaiLyn~ in forum WoW EMU Guides & Tutorials
    Replies: 3
    Last Post: 12-25-2007, 11:52 AM
All times are GMT -5. The time now is 11:36 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search