[Tutorial] LUA Scripting menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Syrup's Avatar Member
    Reputation
    55
    Join Date
    Jul 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Tutorial] LUA Scripting

    [Tutorial: LUA Scripting]


    =========================================================

    I'm here to teach you about LUA Scripting. LUA is a nice program where you can let NPC's talk and cast spells. I'm going to learn you the basic tactics of LUA Scripting, sit and relax and enjoy the LUA!

    First of all, I'm going to show you a basic script.


    function phase_1(pUnit, Event)
    if pUnit:GetHealthPct() < 72 then
    pUnit:RemoveEvents();
    pUnit:SendChatMessage(12, 0, "Burning Fire!")
    pUnit:FullCastSpellOnTarget(30926)
    pUnit:RegisterEvent("phase_2",1000, 0)
    end
    end

    function phase_2(pUnit, Event)
    if pUnit:GetHealthPct() < 39 then
    pUnit:RemoveEvents();
    pUnit:FullCastSpellOnTarget(40877)
    end
    end

    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RegisterEvent(“phase_1”,1000, 1)
    end

    RegisterpUnitEvent(ID, 1, "Mr_Ilk_OnCombat")


    function is needed in every script, it tells what you are going to do.
    pUnit is a basic name in the script, you can change it in whatever you want but remember to keep with one name.
    Event means what it is.

    Now I'm going to explain about a basic phase.


    function phase_1(pUnit, Event)
    if pUnit:GetHealthPct() < 72 then
    pUnit:RemoveEvents();
    pUnit:SendChatMessage(12, 0, "Burning Fire!")
    pUnit:FullCastSpellOnTarget(30926)
    pUnit:RegisterEvent("phase_2",1000, 0)
    end
    end
    This is a basic phase, here are the meanings of the functions.

    function phase_1(pUnit, Event) Means that this is phase_1. You can change it in your own words, like function Cone_of_Fire(pUnit, Event)
    if pUnit:GetHealthPct() 72 then Is really simple, if the pUnit (NPC) is on 72%, he will do the phase.

    pUnit:RemoveEvents(); Means that the pUnit(NPC) stops casting the spells and stops sending the chat messages. Otherwise he would spawn chat messages and keeps casting spells.

    pUnit:SendChatMessage(12, 0, "Burning Fire!") Means that the pUnit(NPC) yells something. 12 and 0 are basic numbers for yelling. 12 = yell, 0 is that everyone understands it. (Further information is at the end of the tutorial)

    pUnit:FullCastSpellOnTarget(30926) Means that the pUnit(NPC) casts a spell on the Target. FullCastSpellOnTarget means that he will cast a spell with casting speed on a target. (Further information is at the end of the tutorial)

    pUnit:RegisterEvent("phase_2",1000, 0) Means that you will register the event of phase 2. If you don't register the phase, he won't do the phase. 1000 means 1000 milliseconds, so he will register the phase in 10 seconds.

    endMeans the end of the phase. Remember, always do an extra end when there is if pUnit:GetHealthPct.

    This was a basic phase of Mr Ilk. Lets go on with the events.

    There are different events, the most used events are:

    OnCombat Means that when the boss or NPC gets in combat with players.
    OnLeaveCombat Means that when players are leaving combat with the boss or NPC.
    OnKilledTarget Means that when the boss or NPC killed a player.
    OnDeath Means that when the boss or NPC died.

    Those events are the basic events. One of the most important things are REGISTERING the events, means that events will work. Not using this ability will ruin your hole script.


    RegisterUnitEvent (ID, 1, "Mr_Ilk_OnCombat")
    RegisterUnitEvent (ID, 2, "Mr_Ilk_OnLeaveCombat")
    RegisterUnitEvent (ID, 3, "Mr_Ilk_OnKilledTarget")
    RegisterUnitEvent (ID, 4, "Mr_Ilk_OnDeath")
    Now I will show you how it will look like in a script.



    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RemoveEvents()
    end

    function Mr_Ilk_OnLeaveCombat(pUnit, Event)
    pUnit:RemoveEvents()
    end

    function Mr_Ilk_OnKilledTarget(pUnit, Event)
    pUnit:RemoveEvents()
    end

    function Mr_Ilk_OnDeath(pUnit, Event)
    pUnit:RemoveEvents()
    end
    You can let them talk in the events to.


    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(12, 0, Haha, here are the weaklings!")
    end
    You don't need to do all the events in one script. If you don't use the events, you don't need to put them in the script.

    If we mix the hole script, we will get this as result.


    function phase_1(pUnit, Event)
    if pUnit:GetHealthPct() < 72 then
    pUnit:RemoveEvents();
    pUnit:SendChatMessage(12, 0, "Burning Fire!")
    pUnit:FullCastSpellOnTarget(30926)
    pUnit:RegisterEvent("phase_2",1000, 0)
    end
    end

    function phase_2(pUnit, Event)
    if pUnit:GetHealthPct() < 39 then
    pUnit:RemoveEvents();
    pUnit:FullCastSpellOnTarget(40877)
    pUnit:RegisterEvent("phase_3",1000, 0)
    end
    end

    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(12, 0, Haha, here are the weaklings!")
    pUnit:RegisterEvent(“phase_1”,1000, 1)
    end

    RegisterpUnitEvent(ID, 1, "Mr_Ilk_OnCombat")
    Here are some more things you could use for scripting.


    SendChatMessage Events:
    11 – npc say
    12 – npc yell
    13 – npc whisper

    Language:
    0 = UNIVERSAL
    1 = ORCISH
    2 = DARNASSIAN
    3 = TAUREN
    6 = DWARVISH
    7 = COMMON
    8 = DEMONIC
    9 = TITAN
    10 = THELASSIAN
    11 = DRAGONIC
    12 = KALIMAG
    13 = GNOMISH
    14 = TROLL
    33 = GUTTERSPEAK
    35 = DRAENEI

    RegisterUnitEvents events:
    eventtype:
    1 = On Combat
    2 = On Leave Combat
    3 = On Killed Target
    4 = On Died
    5 = On AI Tick
    6 = On Spawn
    7 = On Gossip Talk
    8 = On Reach Waypoint
    9 = On Leave Limbo
    10 = On Player Enters Range

    Credits:

    -[Tutorial: LUA Scripting]


    =========================================================

    I'm here to teach you about LUA Scripting. LUA is a nice program where you can let NPC's talk and cast spells. I'm going to learn you the basic tactics of LUA Scripting, sit and relax and enjoy the LUA!

    First of all, I'm going to show you a basic script.


    function phase_1(pUnit, Event)
    if pUnit:GetHealthPct() < 72 then
    pUnit:RemoveEvents();
    pUnit:SendChatMessage(12, 0, "Burning Fire!")
    pUnit:FullCastSpellOnTarget(30926)
    pUnit:RegisterEvent("phase_2",1000, 0)
    end
    end

    function phase_2(pUnit, Event)
    if pUnit:GetHealthPct() < 39 then
    pUnit:RemoveEvents();
    pUnit:FullCastSpellOnTarget(40877)
    end
    end

    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RegisterEvent(“phase_1”,1000, 1)
    end

    RegisterpUnitEvent(ID, 1, "Mr_Ilk_OnCombat")


    function is needed in every script, it tells what you are going to do.
    pUnit is a basic name in the script, you can change it in whatever you want but remember to keep with one name.
    Event means what it is.

    Now I'm going to explain about a basic phase.


    function phase_1(pUnit, Event)
    if pUnit:GetHealthPct() < 72 then
    pUnit:RemoveEvents();
    pUnit:SendChatMessage(12, 0, "Burning Fire!")
    pUnit:FullCastSpellOnTarget(30926)
    pUnit:RegisterEvent("phase_2",1000, 0)
    end
    end
    This is a basic phase, here are the meanings of the functions.

    function phase_1(pUnit, Event) Means that this is phase_1. You can change it in your own words, like function Cone_of_Fire(pUnit, Event)
    if pUnit:GetHealthPct() 72 then Is really simple, if the pUnit (NPC) is on 72%, he will do the phase.

    pUnit:RemoveEvents(); Means that the pUnit(NPC) stops casting the spells and stops sending the chat messages. Otherwise he would spawn chat messages and keeps casting spells.

    pUnit:SendChatMessage(12, 0, "Burning Fire!") Means that the pUnit(NPC) yells something. 12 and 0 are basic numbers for yelling. 12 = yell, 0 is that everyone understands it. (Further information is at the end of the tutorial)

    pUnit:FullCastSpellOnTarget(30926) Means that the pUnit(NPC) casts a spell on the Target. FullCastSpellOnTarget means that he will cast a spell with casting speed on a target. (Further information is at the end of the tutorial)

    pUnit:RegisterEvent("phase_2",1000, 0) Means that you will register the event of phase 2. If you don't register the phase, he won't do the phase. 1000 means 1000 milliseconds, so he will register the phase in 10 seconds.

    endMeans the end of the phase. Remember, always do an extra end when there is if pUnit:GetHealthPct.

    This was a basic phase of Mr Ilk. Lets go on with the events.

    There are different events, the most used events are:

    OnCombat Means that when the boss or NPC gets in combat with players.
    OnLeaveCombat Means that when players are leaving combat with the boss or NPC.
    OnKilledTarget Means that when the boss or NPC killed a player.
    OnDeath Means that when the boss or NPC died.

    Those events are the basic events. One of the most important things are REGISTERING the events, means that events will work. Not using this ability will ruin your hole script.


    RegisterUnitEvent (ID, 1, "Mr_Ilk_OnCombat")
    RegisterUnitEvent (ID, 2, "Mr_Ilk_OnLeaveCombat")
    RegisterUnitEvent (ID, 3, "Mr_Ilk_OnKilledTarget")
    RegisterUnitEvent (ID, 4, "Mr_Ilk_OnDeath")
    Now I will show you how it will look like in a script.



    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RemoveEvents()
    end

    function Mr_Ilk_OnLeaveCombat(pUnit, Event)
    pUnit:RemoveEvents()
    end

    function Mr_Ilk_OnKilledTarget(pUnit, Event)
    pUnit:RemoveEvents()
    end

    function Mr_Ilk_OnDeath(pUnit, Event)
    pUnit:RemoveEvents()
    end
    You can let them talk in the events to.


    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(12, 0, Haha, here are the weaklings!")
    end
    You don't need to do all the events in one script. If you don't use the events, you don't need to put them in the script.

    If we mix the hole script, we will get this as result.


    function phase_1(pUnit, Event)
    if pUnit:GetHealthPct() < 72 then
    pUnit:RemoveEvents();
    pUnit:SendChatMessage(12, 0, "Burning Fire!")
    pUnit:FullCastSpellOnTarget(30926)
    pUnit:RegisterEvent("phase_2",1000, 0)
    end
    end

    function phase_2(pUnit, Event)
    if pUnit:GetHealthPct() < 39 then
    pUnit:RemoveEvents();
    pUnit:FullCastSpellOnTarget(40877)
    pUnit:RegisterEvent("phase_3",1000, 0)
    end
    end

    function Mr_Ilk_OnCombat(pUnit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(12, 0, Haha, here are the weaklings!")
    pUnit:RegisterEvent(“phase_1”,1000, 1)
    end

    RegisterpUnitEvent(ID, 1, "Mr_Ilk_OnCombat")
    Here are some more things you could use for scripting.


    SendChatMessage Events:
    11 – npc say
    12 – npc yell
    13 – npc whisper

    Language:
    0 = UNIVERSAL
    1 = ORCISH
    2 = DARNASSIAN
    3 = TAUREN
    6 = DWARVISH
    7 = COMMON
    8 = DEMONIC
    9 = TITAN
    10 = THELASSIAN
    11 = DRAGONIC
    12 = KALIMAG
    13 = GNOMISH
    14 = TROLL
    33 = GUTTERSPEAK
    35 = DRAENEI

    RegisterUnitEvents events:
    eventtype:
    1 = On Combat
    2 = On Leave Combat
    3 = On Killed Target
    4 = On Died
    5 = On AI Tick
    6 = On Spawn
    7 = On Gossip Talk
    8 = On Reach Waypoint
    9 = On Leave Limbo
    10 = On Player Enters Range
    Credits:

    -sjoerdman



    I hope you enjoyed and learned about LUA Scripting now.
    Last edited by Syrup; 09-07-2008 at 10:41 AM.

    [Tutorial] LUA Scripting
  2. #2
    suicidewarpig's Avatar Active Member
    Reputation
    19
    Join Date
    Sep 2007
    Posts
    161
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what do you do after that?

  3. #3
    Syrup's Avatar Member
    Reputation
    55
    Join Date
    Jul 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by suicidewarpig View Post
    So what do you do after that?
    Well, now, you can start the basic part of LUA scripting.

  4. #4
    matydunkk's Avatar Member
    Reputation
    5
    Join Date
    Jul 2008
    Posts
    32
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice Guide.
    Last edited by matydunkk; 09-08-2008 at 06:51 AM.

  5. #5
    halostorm's Avatar Member
    Reputation
    3
    Join Date
    Oct 2007
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice Guide +rep but i dont understand lua :S how should i make an custom npc with it ?? or teleporter ? and where do i choose what npc should say that ?
    Last edited by halostorm; 09-08-2008 at 09:41 AM.

  6. #6
    Aelus's Avatar Active Member
    Reputation
    72
    Join Date
    Jan 2007
    Posts
    687
    Thanks G/R
    0/2
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quick question. How do I make it so the NPC will yell something every 1 minute. I'm going to make a beggar NPC.



  7. #7
    matydunkk's Avatar Member
    Reputation
    5
    Join Date
    Jul 2008
    Posts
    32
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by halostorm View Post
    Nice Guide +rep but i dont understand lua :S how should i make an custom npc with it ?? or teleporter ? and where do i choose what npc should say that ?
    You change "ID" at the event at the very bottem to the npc entry id of the mob you want to use the script on. Also change the names to your npc's name.

    As for a teleporter the functions are slightly different, download a teleporter lua and compare the difference with this scripting and try and work out how to do it yourself. i may make a guide.

  8. #8
    _DEFiANT's Avatar Member
    Reputation
    44
    Join Date
    Aug 2008
    Posts
    240
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good Job. I needed to see some other LUA scripts.
    All I know is how to script a Teleporter NPC
    I am actually working on one right now. I uploaded to my site so other people can see it so they can see what is coming.

    Click here to see the one I am working on.

    EDIT: Wow. Sorry. I forgot to say +rep!


    Last edited by _DEFiANT; 09-08-2008 at 07:02 PM.

    Need help? add me on MSN - [email protected]
    Have questions? email me - [email protected]

  9. #9
    halostorm's Avatar Member
    Reputation
    3
    Join Date
    Oct 2007
    Posts
    139
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do i spawn the npc ?? no entry id ?

  10. #10
    ViND_'s Avatar Contributor
    Reputation
    156
    Join Date
    Apr 2008
    Posts
    1,134
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hello. I know its a little old thread but I found it on search, so I want to ask something. What program do you use to save your LUA? I mean what program do you do it with. Or do you do it in notepad? I'm very interested in LUA. I want to start as soon as I can.

  11. #11
    sonny181's Avatar Member
    Reputation
    8
    Join Date
    Nov 2006
    Posts
    15
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice i might learning LUA, this could be a great start

  12. #12
    ViND_'s Avatar Contributor
    Reputation
    156
    Join Date
    Apr 2008
    Posts
    1,134
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So what program do you use? I found this LUA FOR WINDOWS thing. Is it that?

  13. #13
    spikedzzilm's Avatar Member
    Reputation
    1
    Join Date
    Oct 2008
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there a way to make a script to make the ships and zeplins work right? or any way for that mater?

  14. #14
    ViND_'s Avatar Contributor
    Reputation
    156
    Join Date
    Apr 2008
    Posts
    1,134
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please answer my question, I really want to script.

  15. #15
    spikedzzilm's Avatar Member
    Reputation
    1
    Join Date
    Oct 2008
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i use notepad for lua :/

Page 1 of 2 12 LastLast

Similar Threads

  1. [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
  2. [GUIDE] How to activate LUA scripts
    By ~SaiLyn~ in forum WoW EMU Guides & Tutorials
    Replies: 3
    Last Post: 12-25-2007, 11:52 AM
  3. Lua Scripts!
    By danis in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 12-15-2007, 03:16 PM
  4. How To LUA Script
    By Skuxta in forum WoW EMU Guides & Tutorials
    Replies: 1
    Last Post: 12-13-2007, 04:24 AM
  5. New LUA Scripts
    By 777devil777 in forum World of Warcraft Emulator Servers
    Replies: 8
    Last Post: 11-26-2007, 05:58 PM
All times are GMT -5. The time now is 08:17 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