Simple LUA Script Help menu

Shout-Out

User Tag List

Results 1 to 8 of 8
  1. #1
    Wolfly's Avatar Contributor
    Reputation
    96
    Join Date
    May 2007
    Posts
    325
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simple LUA Script Help

    I have this rather simple LUA script, it's my first as well so I used guides for this. So I can't really understand what's wrong, clicking on the object doesn't do anything.
    Code:
    function LesserWindStone_onUse(pUnit, Event)
    local Choice=math.random(1, 4)
    if Choice==1 then
    pUnit:SpawnCreature(15211, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    elseif Choice==2 then
    pUnit:SpawnCreature(15307, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    elseif Choice==3 then
    pUnit:SpawnCreature(15209, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    elseif Choice==4 then
    pUnit:SpawnCreature(15212, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    end
    
    RegisterGameObjectEvent (180456, 2, "LesserWindStone_onUse")
    Any help would be very appreciated and a nice 2x+Rep


    Simple LUA Script Help
  2. #2
    kreegoth's Avatar Contributor
    Reputation
    122
    Join Date
    Jun 2008
    Posts
    810
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this...

    Code:
    function LesserWindStone_onUse(pUnit, Event)
    local Choice=math.random(1, 4)
    if Choice==1 then
    pUnit:SpawnCreature(15211, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    if Choice==2 then
    pUnit:SpawnCreature(15307, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    if Choice==3 then
    pUnit:SpawnCreature(15209, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    if Choice==4 then
    pUnit:SpawnCreature(15212, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    end
    
    RegisterGameObjectEvent (180456, 2, "LesserWindStone_onUse")

  3. #3
    Wolfly's Avatar Contributor
    Reputation
    96
    Join Date
    May 2007
    Posts
    325
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Afraid it still didn't work.
    My script is in ArcEmu\Scripts folder as well so I doubt I placed it wrong.


  4. #4
    kreegoth's Avatar Contributor
    Reputation
    122
    Join Date
    Jun 2008
    Posts
    810
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok try this LOL if it doesnt work then i dont know i guess youll have to wait for a more experienced scripter


    function LesserWindStone_onUse(pUnit, Event)
    local Choice=math.random(1, 4)
    if Choice==1 then
    pUnit:SpawnCreature(15211, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    if Choice==2 then
    pUnit:SpawnCreature(15307, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    if Choice==3 then
    pUnit:SpawnCreature(15209, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    if Choice==4 then
    pUnit:SpawnCreature(15212, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    end

    RegisterGameObjectEvent (180456, 2, "LesserWindStone_onUse")

  5. #5
    Wolfly's Avatar Contributor
    Reputation
    96
    Join Date
    May 2007
    Posts
    325
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh I got it fixed. It was pretty simple really, I forgot to add "end" to close the if statements. +2Rep still for trying


  6. #6
    kreegoth's Avatar Contributor
    Reputation
    122
    Join Date
    Jun 2008
    Posts
    810
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CAn ya toss up the fixed one? i dont wanan copy it i just wanna See what the problem was

  7. #7
    Wolfly's Avatar Contributor
    Reputation
    96
    Join Date
    May 2007
    Posts
    325
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tbh I was a bit too optimistic..seems like the syntax is correct.
    Code:
    function LesserWindStone_onUse(pUnit, Event)
    local Choice=math.random(1, 4)
    if Choice==1 then
    pUnit:SpawnCreature(15211, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    elseif Choice==2 then
    pUnit:SpawnCreature(15307, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    elseif Choice==3 then
    pUnit:SpawnCreature(15209, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    elseif Choice==4 then
    pUnit:SpawnCreature(15212, -7964.16, 1826.29, 2.28, 2.84, 14, 240000)
    end
    end
    
    RegisterGameObjectEvent (180456, 2, "LesserWindStone_onUse")

    I get this error message in arcemu-world.exe tho:
    scripts\LesserWindStone.lua:4: attempt to call method ´SpawnCreature´
    <a nil value>

    The :4: is either 6, 8, 10 or 4. Obviously it's the faulty line. And apparently the if adding was wrong, back where I started.


  8. #8
    kreegoth's Avatar Contributor
    Reputation
    122
    Join Date
    Jun 2008
    Posts
    810
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Might be easier to do the same thing but using a Gossipmenu like with choices 1 thru 4 .. but it wouldnt be random then i guess...

Similar Threads

  1. Need help fixing some simple lua scripts :-)
    By kaato in forum WoW EMU Questions & Requests
    Replies: 7
    Last Post: 04-10-2009, 06:11 PM
  2. LuA Scripting Help
    By Jlp in forum World of Warcraft Emulator Servers
    Replies: 15
    Last Post: 06-27-2008, 03:33 AM
  3. 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
  4. Need LUA Scripting Help ?
    By Snailz in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 02-04-2008, 12:36 PM
  5. Simple Lua Script , not working need help!
    By Arugos in forum World of Warcraft Emulator Servers
    Replies: 16
    Last Post: 12-30-2007, 02:06 PM
All times are GMT -5. The time now is 11:57 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