Lua Script Help and tips needed menu

User Tag List

Results 1 to 3 of 3
  1. #1
    digger514's Avatar Member
    Reputation
    1
    Join Date
    Jun 2009
    Posts
    4
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lua Script Help and tips needed

    Hi I just looked at some tutorials and filled out some things in lua script, i named the sections for what i was doing. If anyone could tell me what I did wrong, (besides minor spelling problems because if it was a real script to post and use i would double check) any help would be appreciated, Lua scripting so far has been very enjoyable. Thank you.


    Basic Lua:

    function Creature_OnCombat(Unit,event)
    Unit"FrostboltSpam", 1000 0)
    end

    function FrostboltSpam(unit, event)
    Unit:FullCastSpellOnTarget(11, Unit:GetRandomPlayer(7))
    end

    function Creature_OnLeaveCombat(Unit, Event)
    Unit:RemoveEvents()
    end

    Function Creature_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end

    RegisterUnitEvent(11, 1, "Creature_OnCombat")
    RegisterUnitEvent(11, 2, "Creature_OnLeaveCombat")
    RegisterUnitEvent(11, 4, "Creature_OnDie")

    NPC Chat:

    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    end

    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end

    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end

    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")

    Summoning Npc to an npc:

    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    Unit:RegisterEvent("DavidNpc_Spawn", 120000, 10)
    end

    function DavidNpc_Spawn(Unit,Event)
    local x = Unit:GetX();
    local y = Unit:GetY():
    local z = Unit:GetZ():
    local o = Unit:GetO():
    Unit:SpawnCreature(100000, x, y, z, o, 14, 120000)
    end

    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end

    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end

    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")

    Summoning an Npc to a specific location:

    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    Unit:RegisterEvent("DavidNpc_Spawn", 120000, 10)
    Unit:RegisterEvent("David2Npc_Spawn", 360000, 2)
    end

    function David2Npc_Spawn(Unit, Event)
    Unit:SpawnCreature(100001, 1, 2, 3, 4, 14, 360000)
    end

    function DavidNpc_Spawn(Unit, Event)
    local x = Unit:GetX();
    local y = Unit:GetY():
    local z = Unit:GetZ():
    local o = Unit:GetO():
    Unit:SpawnCreature(100000, x, y, z, o, 14, 120000)
    end

    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end

    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end

    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")

    Phrases:

    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end

    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    Unit:RegisterEvent("DavidNpc_Spawn", 120000, 10)
    Unit:RegisterEvent("David2Npc_Spawn", 360000, 2)
    Unit:Registerevent("David_Phase1", 1000, 1)
    end

    function David_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 20 then
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    Unit:SetScale(3)
    Unit:SetModel(100002)
    end
    end

    function David2Npc_Spawn(Unit, Event)
    Unit:SpawnCreature(100001, 1, 2, 3, 4, 14, 360000)
    end

    function DavidNpc_Spawn(Unit, Event)
    local x = Unit:GetX();
    local y = Unit:GetY():
    local z = Unit:GetZ():
    local o = Unit:GetO():
    Unit:SpawnCreature(100000, x, y, z, o, 14, 120000)
    end

    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end

    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end

    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")

    Portal:

    function PortalTo_Boss(pUnit, Event, pMisc)
    pMisc:Teleport(1, -142, 235.135, 634.15) <-------------------------(MapID, X-Coord, Y-Coord, Z-Coord)
    end
    RegisterGameObjectEvent(1500, 2, "PortalTo_Boss")

    Teleport NPC:

    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(0, "Main Alliance Teleport Locations", 0, 0)
    unit:GossipSendMenu(player)
    end

    function Gossip_Submenus(unit, event, player, id, intid, code)
    if(intid == 0) then
    unit:GossipCreateMenu(101, player, 0)
    unit:GossipMenuAddItem(0, "Mall", 50, 0)
    unit:GossipMenuAddItem(0, "Leveling Road", 51, 0)
    unit:GossipMenuAddItem(0, "Boss Area", 52, 0)
    unit:GossipMenuAddItem(0, "Event Area", 53, 0)
    unit:GossipSendMenu(player)
    end

    if(intid == 50) then
    player:Teleport(mapid, x, y, z)
    end
    end

    RegisterUnitEvent(npcid, 1, "On_Gossip")
    RegisterUnitEvent(npcid, 2, "Gossip_Submenus")

    Making healer + Buffer+Morpher:

    function Buff_Gossip(unit, event, player)
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipAddMenuItem(0, "Buffs", 0, 0)
    unit:GossipAddMenuItem(0, "Heals", 1, 0)
    unit:GossipAddMenuItem(0, "Morpher", 2, 0)
    unit:GossipSendMenu(player)
    end

    function Buffs_Submenus(unit, event, player, id, intid, code)
    if(intid == 0) then
    unit:FullCastSpellOnTarger(20217, player)
    player:GossipComplete()
    end
    if(intid == 1) then
    unit:FullCastSpellOnTarget(27136, player)
    player:GossipComplete()
    end
    if(intid ==2) then
    unit:SetModel(morpheridhere)
    player:GossipComplete()
    end

    RegisterUnitEvent(npcid, 1, "Buffs_Gossip")
    RegisterUnitEvent(npcid, 2, "Buffs_Sebmenus")
    lol sorry about the sad face, it is supposed to be the two symbols without the face but it automaticly switched it.
    Last edited by digger514; 09-12-2009 at 12:11 AM.

    Lua Script Help and tips needed
  2. #2
    MaGiiKz's Avatar Member
    Reputation
    1
    Join Date
    Sep 2009
    Posts
    7
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not much of an LUA expert but you shouldn't have all this in one file you should have them in different files after every RegisterUnitEvent

  3. #3
    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)
    Originally Posted by MaGiiKz View Post
    I'm not much of an LUA expert but you shouldn't have all this in one file you should have them in different files after every RegisterUnitEvent
    No you don't need to.
    Here is your script fixed:


    Code:
    --Basic Lua:
    
    function Creature_OnCombat(Unit,event)
    Unit:RegisterEvent("FrostboltSpam", 1000 0)
    end
    
    function FrostboltSpam(unit, event)
    Unit:FullCastSpellOnTarget(11, Unit:GetRandomPlayer(7))
    end
    
    function Creature_OnLeaveCombat(Unit, Event)
    Unit:RemoveEvents()
    end
    
    Function Creature_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end
    
    RegisterUnitEvent(11, 1, "Creature_OnCombat")
    RegisterUnitEvent(11, 2, "Creature_OnLeaveCombat")
    RegisterUnitEvent(11, 4, "Creature_OnDie")
    
    --NPC Chat:
    
    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    end
    
    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end
    
    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end
    
    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")
    
    --Summoning Npc to an npc:
    
    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    Unit:RegisterEvent("DavidNpc_Spawn", 120000, 10)
    end
    
    function DavidNpc_Spawn(Unit,Event)
    local x = Unit:GetX();
    local y = Unit:GetY():
    local z = Unit:GetZ():
    local o = Unit:GetO():
    Unit:SpawnCreature(100000, x, y, z, o, 14, 120000)
    end
    
    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end
    
    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end
    
    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")
    
    --Summoning an Npc to a specific location:
    
    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    Unit:RegisterEvent("DavidNpc_Spawn", 120000, 10)
    Unit:RegisterEvent("David2Npc_Spawn", 360000, 2)
    end
    
    function David2Npc_Spawn(Unit, Event)
    Unit:SpawnCreature(100001, 1, 2, 3, 4, 14, 360000)
    end
    
    function DavidNpc_Spawn(Unit, Event)
    local x = Unit:GetX();
    local y = Unit:GetY():
    local z = Unit:GetZ():
    local o = Unit:GetO():
    Unit:SpawnCreature(100000, x, y, z, o, 14, 120000)
    end
    
    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end
    
    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end
    
    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")
    
    --Phrases:
    
    function David_OnLeaveCombat(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnDie(Unit,Event)
    Unit:RemoveEvents()
    end
    
    function David_OnCombat(Unit,Event)
    Unit:SendChatMessage(14, 0, "I Am Beast!")
    Unit:RegisterEvent("DavidSpellCast_OnCombat", 15000, 1)
    Unit:RegisterEvent("DavidNpc_Spawn", 120000, 10)
    Unit:RegisterEvent("David2Npc_Spawn", 360000, 2)
    Unit:Registerevent("David_Phase1", 1000, 1)
    end
    
    function David_Phase1(Unit, Event)
    if Unit:GetHealthPct() <= 20 then
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    Unit:SetScale(3)
    Unit:SetModel(100002)
    end
    end
    
    function David2Npc_Spawn(Unit, Event)
    Unit:SpawnCreature(100001, 1, 2, 3, 4, 14, 360000)
    end
    
    function DavidNpc_Spawn(Unit, Event)
    local x = Unit:GetX()
    local y = Unit:GetY()
    local z = Unit:GetZ()
    local o = Unit:GetO()
    Unit:SpawnCreature(100000, x, y, z, o, 14, 120000)
    end
    
    function David_OnTargetDie(Unit, Event)
    Unit:RemoveEvents()
    end
    
    function DavidSpellCast_OnCombat(Unit, Event)
    Unit:FullCastSpellOnTarget(5, Unit:GetRandomPlayer())
    end
    
    RegisterUnitEvent(100000, 1, "David_OnCombat")
    RegisterUnitEvent(100000, 2, "David_OnLeaveCombat")
    RegisterUnitEvent(100000, 4, "David_OnDie")
    RegisterUnitEvent(100000, 3, "David_OnTargetDie")
    
    --Portal:
    
    function PortalTo_Boss(pUnit, Event, pMisc)
    pMisc:Teleport(1, -142, 235.135, 634.15) --<-------------------------(MapID, X-Coord, Y-Coord, Z-Coord)
    end
    RegisterGameObjectEvent(1500, 2, "PortalTo_Boss")
    
    --Teleport NPC:
    
    function On_Gossip(unit, event, player)
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipMenuAddItem(0, "Main Alliance Teleport Locations", 0, 0)
    unit:GossipSendMenu(player)
    end
    
    function Gossip_Submenus(unit, event, player, id, intid, code)
    if(intid == 0) then
    unit:GossipCreateMenu(101, player, 0)
    unit:GossipMenuAddItem(0, "Mall", 50, 0)
    unit:GossipMenuAddItem(0, "Leveling Road", 51, 0)
    unit:GossipMenuAddItem(0, "Boss Area", 52, 0)
    unit:GossipMenuAddItem(0, "Event Area", 53, 0)
    unit:GossipSendMenu(player)
    end
    
    if(intid == 50) then
    player:Teleport(1, 0, 0, 0)
    end
    end
    
    RegisterUnitEvent(111, 1, "On_Gossip")
    RegisterUnitEvent(111, 2, "Gossip_Submenus")
    
    Making healer + Buffer+Morpher:
    
    function Buff_Gossip(unit, event, player)
    unit:GossipCreateMenu(100, player, 0)
    unit:GossipAddMenuItem(0, "Buffs", 0, 0)
    unit:GossipAddMenuItem(0, "Heals", 1, 0)
    unit:GossipAddMenuItem(0, "Morpher", 2, 0)
    unit:GossipSendMenu(player)
    end
    
    function Buffs_Submenus(unit, event, player, id, intid, code)
    if(intid == 0) then
    unit:FullCastSpellOnTarger(20217, player)
    player:GossipComplete()
    end
    if(intid == 1) then
    unit:FullCastSpellOnTarget(27136, player)
    player:GossipComplete()
    end
    if(intid ==2) then
    player:SetModel(100)
    player:GossipComplete()
    end
    
    RegisterUnitEvent(555, 1, "Buffs_Gossip")
    RegisterUnitEvent(555, 2, "Buffs_Sebmenus")
    It won't error now but half the stuff wasn't filled in so it still won't work as intended till you fill in the correct fields.

    Edit: Just read that it's not going to be a real script, was just trying stuff out. Yes it looks good and you got the general idea, you just need to check spelling as you said. Put -- infront of all comments though.

Similar Threads

  1. LUA script got a question, need help asap.
    By yespleasemate in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 02-15-2009, 07:09 PM
  2. Lua Script Help needed
    By denniskramer in forum WoW EMU Questions & Requests
    Replies: 3
    Last Post: 11-29-2008, 07:04 PM
  3. LuA Scripting Help
    By Jlp in forum World of Warcraft Emulator Servers
    Replies: 15
    Last Post: 06-27-2008, 03:33 AM
  4. Lua script help and general questions from beginner
    By WinKIller0 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 02-23-2008, 04:38 AM
  5. Need LUA Scripting Help ?
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 02-04-2008, 12:36 PM
All times are GMT -5. The time now is 10:49 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