My First Lua (Feedback requested) menu

User Tag List

Results 1 to 4 of 4
  1. #1
    Eddie12390's Avatar Member
    Reputation
    11
    Join Date
    May 2009
    Posts
    70
    Thanks G/R
    0/3
    Trade Feedback
    12 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    My First Lua (Feedback requested)

    I would like to know if this works, and if not, what can be done to fix it

    Code:
    function LichKing_OnCombat(Unit, Event) 
    pUnit:SendChatMessage(12, 0, "Do you think you can kill me?")
    pUnit:GetRandomPlayer(0) Unit:CastSpellOnTarget(60924, Unit:GetMainTank)
    pUnit:RegisterEvent("LichKing_MedHP", 1000, 0)
    pUnit:RegisterEvent("LichKing_LowHP", 1000, 0)
    end
    
    function LichKing_OnLeaveCombat(Unit, Event) 
    pUnit:RemoveEvents() 
    pUnit:SendChatMessage(12, 0, "Run, foolish mortal.") 
    end
    
    function LichKing_OnDied(Unit, Event) 
    pUnit:RemoveEvents() 
    pUnit:SendChatMessage(12, 0, "You think you have defeated the scourge!? You've barely damaged the Scourge. The true war has yet to begin.") 
    pUnit:CastSpell(53210)
    end
    
    function LichKing_OnKilledTarget(Unit, Event) 
    pUnit:SendChatMessage(12, 0, "Foolish Mortal.") 
    end
    
    function LichKing_MedHP(pUnit,Event)
    pUnit:CastSpell(58915)
    end
    
    function LichKing_MedHP(pUnit, Event)
    	if pUnit:GetHealthPct() == 50 then
                pUnit:CastSpell(58915)
                pUnit:RemoveEvents()
    	end
    end
    
    function LichKing_LowHP(Unit, Event)
    	if pUnit:GetHealthPct() == 50 then
                pUnit:CastSpell(58915)
                pUnit:CastSpell(58915)
                pUnit:CastSpell(58915)
                pUnit:RemoveEvents()
    	end
    end
    
    RegisterUnitEvent(70819, 1, "LichKing_OnCombat")
    RegisterUnitEvent(70819, 2, "LichKing_OnLeaveCombat")
    RegisterUnitEvent(70819, 3, "LichKing_OnKilledTarget")
    RegisterUnitEvent(70819, 4, "LichKing_OnDied")
    Thanks for your time,

    Eddie

    My First Lua (Feedback requested)
  2. #2
    Linkn's Avatar Contributor
    Reputation
    90
    Join Date
    Mar 2009
    Posts
    296
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It could work but you need to rename some of your functions and move some registers about.

    function LichKing_OnCombat(Unit, Event)
    pUnit:SendChatMessage(12, 0, "Do you think you can kill me?")
    pUnit:GetRandomPlayer(0) Unit:CastSpellOnTarget(60924, Unit:GetMainTank)
    pUnit:RegisterEvent("LichKing_MedHP", 1000, 0)
    pUnit:RegisterEvent("LichKing_LowHP", 1000, 0)
    end

    function LichKing_OnLeaveCombat(Unit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(12, 0, "Run, foolish mortal.")
    end

    function LichKing_OnDied(Unit, Event)
    pUnit:RemoveEvents()
    pUnit:SendChatMessage(12, 0, "You think you have defeated the scourge!? You've barely damaged the Scourge. The true war has yet to begin.")
    pUnit:CastSpell(53210)
    end

    function LichKing_OnKilledTarget(Unit, Event)
    pUnit:SendChatMessage(12, 0, "Foolish Mortal.")
    end

    function LichKing_MedHP(pUnit,Event)

    pUnit:CastSpell(58915)
    end

    function LichKing_MedHP(pUnit, Event)
    if pUnit:GetHealthPct() < 50 then
    pUnit:CastSpell(58915)
    pUnit:RemoveEvents()
    end
    end
    Take a look at the bold lines.
    Your registering a new phase and a spell to be cast with the same register. You need to rename the spell/phase and make two separate registers.

  3. #3
    Jotox's Avatar Contributor
    Reputation
    250
    Join Date
    Mar 2008
    Posts
    282
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There were a number of things wrong with it.

    Here, I fixed it all up for you:
    Code:
    function LichKing_OnCombat(pUnit, Event) 
    	pUnit:SendChatMessage(12, 0, "Do you think you can kill me?")
    	pUnit:CastSpellOnTarget(60924, pUnit:GetMainTank())
    	pUnit:RegisterEvent("LichKing_MedHP", 1000, 0)
    end
    
    function LichKing_OnLeaveCombat(pUnit, Event)
    	pUnit:RemoveEvents() 
    	pUnit:SendChatMessage(12, 0, "Run, foolish mortal.") 
    end
    
    function LichKing_OnDied(pUnit, Event) 
    	pUnit:RemoveEvents()
    	pUnit:SendChatMessage(12, 0, "You think you have defeated the scourge!? You've barely damaged the Scourge. The true war has yet to begin.") 
    	pUnit:CastSpell(53210)
    end
    
    function LichKing_OnKilledTarget(pUnit, Event)
    	pUnit:SendChatMessage(12, 0, "Foolish Mortal.") 
    end
    
    function LichKing_MedHP(pUnit, Event)
    	if pUnit:GetHealthPct() <= 50 then
                pUnit:CastSpell(58915)
                pUnit:RemoveEvents()
    	    pUnit:RegisterEvent("LichKing_LowHP", 1000, 0)
    	end
    end
    
    function LichKing_LowHP(pUnit, Event)
    	if pUnit:GetHealthPct() <= 30 then
                pUnit:RemoveEvents();
                for i=1,3 do pUnit:CastSpell(58915); end
    	end
    end
    
    RegisterUnitEvent(70819, 1, "LichKing_OnCombat")
    RegisterUnitEvent(70819, 2, "LichKing_OnLeaveCombat")
    RegisterUnitEvent(70819, 3, "LichKing_OnKilledTarget")
    RegisterUnitEvent(70819, 4, "LichKing_OnDied")
    first of all:
    the unit name in functions has to agree with the variable name in the function arguments.

    for example:
    Code:
    function LichKing_OnKilledTarget(Unit, Event)
    pUnit:SendChatMessage(12, 0, "Foolish Mortal.")
    end
    Will not work, because you declare the variable name as Unit in the arguments, but pUnit in the function.


    Secondly:
    Code:
    pUnit:GetRandomPlayer(0) Unit:CastSpellOnTarget(60924, Unit:GetMainTank)
    This doesn't work. You have two function calls on the same line, which... doesn't work.
    Also, Unit:GetMainTank is a function, so you have to put parenthases after it.

    The line pUnit:GetRandomPlayer(0) does nothing here, because you don't do anything with it. So it gets removed.

    The end result of this line is:
    Code:
    Unit:CastSpellOnTarget(60924, Unit:GetMainTank())
    Last edited by Jotox; 06-21-2009 at 12:20 AM.

  4. #4
    Linkn's Avatar Contributor
    Reputation
    90
    Join Date
    Mar 2009
    Posts
    296
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, I missed a lot of things but jotox1 covered it all.

Similar Threads

  1. My first ever Lua [feedback]
    By Warriar in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 06-16-2009, 11:51 AM
  2. LUA Help Request
    By erebos in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 09-26-2008, 01:54 PM
  3. [Release Lua] One of My First Lua Scripts
    By Juicyz in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 03-28-2008, 02:03 AM
  4. [Release] First LUA boss
    By Spartansp in forum World of Warcraft Emulator Servers
    Replies: 37
    Last Post: 02-25-2008, 08:27 PM
  5. [RELEASE] My First Lua Boss xD
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 15
    Last Post: 01-25-2008, 01:38 PM
All times are GMT -5. The time now is 03:16 AM. 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