Checking Lua script! menu

User Tag List

Results 1 to 6 of 6
  1. #1
    mantor4's Avatar Member
    Reputation
    2
    Join Date
    Aug 2006
    Posts
    31
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Checking Lua script!

    I've been reading up on Lua boss fights recently, and came up with a very basic boss script. If anyone could check it for errors and whatnot, that would be fantastic! Thanks!


    function Boss_Say(pUnit, event)
    pUnit:SendChatMessage(12, 0, "Prepare for Annihilation!")
    pUnit:RegisterEvent("Boss_Phase1",1000, 0)
    end

    function Boss_Phase1(pUnit, event)
    if pUnit:GetHealthPct() < 70 then
    pUnit:CastSpell(11)
    pUnit:RegisterEvent("Boss_Phase2",1000, 0)
    end
    end

    function Boss_Phase2(pUnit, event)
    if pUnit:GetHealthPct() < 30 then
    pUnit:RemoveEvents()
    end
    end

    function Boss_Start(pUnit, Event)
    pUnit:RegisterEvent("Boss_Say",1000, 0)
    end
    RegisterUnitEvent(999989, 1, "Boss_Start")
    Last edited by stoneharry; 07-05-2011 at 01:59 AM. Reason: Changed prefix.

    Checking Lua script!
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    You have the basic idea, but there's one flaw your making:

    :RemoveEvents()

    This is used to stop any RegisterEvents you currently have running attached to that creature.

    RegisterEvent("name", time, repeat)

    Setting repeat to 0 will make it check infinite times.

    So currently, it starts, does Boss_Say every second, Boss_Phase1 every second (which is correct as it may not be < 70% on Phase1), then does phase 2 till <30%, then stops everything.

    Maybe you want to change Boss_Say to only happen once, and to add a RemoveEvents() in phase 1?

  3. #3
    choweyiii's Avatar Contributor
    Reputation
    91
    Join Date
    Aug 2010
    Posts
    127
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you're new to lua, take a look at Arcemu Unit Commands it's very, very helpful!

  4. #4
    mantor4's Avatar Member
    Reputation
    2
    Join Date
    Aug 2006
    Posts
    31
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :RemoveEvents()

    Thanks for the help! So, what you're saying I should do is add the line pUnit:RemoveEvents() into phase 1? Because right now, I added it in right here:

    function Boss_Phase1(pUnit, event)
    if pUnit:GetHealthPct() < 70 then
    pUnit:CastSpell(11)
    pUnit:RegisterEvent("Boss_Phase2",1000, 0)
    pUnit:RemoveEvents()
    end
    end

  5. #5
    newtech's Avatar Active Member
    Reputation
    57
    Join Date
    Aug 2008
    Posts
    308
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nono, always add it as the first line after the function is initiated. Otherwise its gonna remove the RegisterEvent xD In this case, as it looks now, you have registered the event Boss_Phase2, but by putting a RemoveEvents right after, its gonna stop repeating the event Boss_Phase2 x)
    Oh yes, and could you please use [Code] tag?

    Thanks
    Newtech
    LuaHypArc Lua scripter - 3.3.5a World Builder.

  6. #6
    mantor4's Avatar Member
    Reputation
    2
    Join Date
    Aug 2006
    Posts
    31
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    reply!

    Alright, thanks. Change has been made. Thanks again for the advice!

Similar Threads

  1. How to detect a Lua script permission-checking place
    By alex-mech in forum World of Warcraft General
    Replies: 2
    Last Post: 12-04-2014, 04:28 AM
  2. [Lua Script] can some check my lua script over
    By towaly in forum WoW EMU Questions & Requests
    Replies: 1
    Last Post: 08-06-2010, 10:40 AM
  3. [Help] LUA script check it please
    By Strupantwn in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 06-09-2008, 12:52 PM
  4. [Help] Need someone to check LUA script
    By stealthpyro in forum World of Warcraft Emulator Servers
    Replies: 5
    Last Post: 05-21-2008, 09:50 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:16 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