Welcome to the MMOtop - Arcemu, Mangos, Trinity.
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    yvo
    Status : yvo is offline
    Join Date : Jul 2009
    Location : Under a roof
    Posts : 304
    Thanks: 10
    Thanked 11 Times in 10 Posts
    Rep Power : 3
    Reputation:71yvo will become famous soon enough

    Default What is lua ( Guide )

    What you need:

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

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

    Code:
    function Captain_Dementox_Enrage(pUnit, event)
        if pUnit:GetHealthPct() < 40 then
            pUnit:RemoveEvents()
            pUnit:PlaySoundToSet(11273)
            pUnit:CastSpell(33653)
            pUnit:CastSpell(36900)
            pUnit:SendChatMessage(12, 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
    end
    
    function Captain_Dementox_onCombat(pUnit, event)
        pUnit:PlaySoundToSet(11263)
        pUnit:SendChatMessage(12, 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(12, 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.
    Code:
     pUnit:PlaySoundToSet(####) <--Plays a sound to the surrounding area
    2.
    Code:
    pUnit:SendChatMessage(12, 0, "Forgive me my prince....I have..failed...")
    <---Makes the NPC say what is in quotes

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

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

    5.
    Code:
     pUnit:GetHealthPct()
    <--- This allows the script to get the current percentage of the mob's health at the time it is executed.[/li][/list]
    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:
    Code:
    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 function/event "Captain_Dementox_onCombat"
    2. Run the function/event "Captain_Dementox_onLeaveCombat"
    3. Run the function/event "Captain_Dementox_onDeath"

    Now how does the script know when these events occur? Well that is what the little numbers are:
    Code:
    RegisterUnitEvent (26, 1, "Captain_Dementox_onCombat")
    RegisterUnitEvent (26, 2, "Captain_Dementox_onLeaveCombat")
    RegisterUnitEvent (26, 4, "Captain_Dementox_onDeath")
    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.

    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 on ArcEmu, 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.
    Credits :
    Halestorm @ wow vendetta
    Yvoms @ Mmotop Guidelines.
    Last edited by yvo; 03-19-2011 at 06:09 AM.

  2. #2
    SephiZe's Avatar
    Status : SephiZe is offline
    Join Date : Feb 2010
    Location : Sweden
    Posts : 796
    Thanks: 51
    Thanked 25 Times in 19 Posts
    Rep Power : 3
    Reputation:85SephiZe will become famous soon enough

    Default

    Thanks for share! :) I have also been into Lua myself, i did also quit it because it became really booring :) (y)
    MMotop.org Moderator

  3. #3
    Truster's Avatar
    Status : Truster is offline
    Join Date : Apr 2010
    Location : Norway
    Posts : 3,341
    Thanks: 46
    Thanked 87 Times in 83 Posts
    Rep Power : 10
    Reputation:2014Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute Truster has a reputation beyond repute

    Default

    edited title. When you make guides don't play around with the thread titles. Make it sound professional as it can.


 

Visitors found this page by searching for:

whats LUA enabled?

SEO Blog

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts