[Lua] Gossip Dropdown Menus menu

User Tag List

Results 1 to 10 of 10
  1. #1
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Lua] Gossip Dropdown Menus

    Gossip Dropdown Menus
    What will we be learning to create?
    In this guide I will explain how one can create a gossip script which contains dropdown menus. What are dropdown menus, I hear you ask? They're not commonly used, because not many people know they exist nor do they know how to create one. However, they can greatly enhance your gossip script, if properly used. This is what we will end up with:



    Okay, alright, let's start! Ho-ho, hold on, young padawan! I will not be explaining the basics of a gossip script in this guide as I will be only explaining the new bits. If you want to learn how to script a gossip I point you in the direction of the guides section.

    I will explain it with this script, however keep in mind that I will be only explaining the dropdown and therefore the rest of the menu items and the script isn't included. Thus if you see a [...] something's been taken away to make it easier to understand.
    Code:
    function Test_Unit_Gossip(pUnit, event, player, pMisc, intid)
    	pUnit:GossipCreateMenu(50, player, 0)
    	pUnit:GossipMenuAddItem(0, "|cff3060B5Current status:|r Looking for Racers!", 1, 0)
    	pUnit:GossipMenuAddItem(9, "Sign me up for this race!", 2, 0)
    	[...] -- skipping out this bit as we don't need it for this guide
    	pUnit:GossipMenuAddItem(0, "   > Racer 3", 3, 0)
    	if (intid == 3) then
    		pUnit:GossipMenuAddItem(0, "|cff095F0B     > Races won: 0", 0)
    		pUnit:GossipMenuAddItem(0, "|cFFFF0000     > Races lost: 0", 0)
    	end
    	pUnit:GossipMenuAddItem(7, "[Exit]", 50, 0)
    	pUnit:GossipSendMenu(player)
    end
    
    function Test_Unit_Select(pUnit, event, player, id, intid, code, pMisc)
    	if (intid == 50) then
    		player:GossipComplete()
    	end
    	
    	if (intid == 3) then
    		Test_Unit_Gossip(pUnit, player, intid)
    	end
    end
    
    RegisterUnitGossipEvent(50, 1, "Test_Unit_Gossip")
    RegisterUnitGossipEvent(50, 2, "Test_Unit_Select")
    Alright, there's the script we'll be using! Now for the real work.
    Code:
    function Test_Unit_Gossip(pUnit, event, player, pMisc, intid)
    You should've noticed something immediately in the parameters of this function. Yes, that's right! We have included an 'intid' parameter in the gossip function which normally isn't there. We'll be needing this parameter later on.

    Code:
    pUnit:GossipMenuAddItem(0, "   > Racer 3", 3, 0)
    [...]
    function Test_Unit_Select(pUnit, event, player, id, intid, code, pMisc)
    	if (intid == 3) then
    		Test_Unit_Gossip(pUnit, player, intid)
    	end
    end
    So we press the " > Racer 3" item with intid 3. The Test_Unit_Select function is ran and we have a match. What happens then? Lua calls the Test_Unit_Gossip function again, huh? Does that mean we get back to the menu selection screen then? Yep, that's correct. The script sends us back to the gossip menu, but with some extra information this time. Namely, it's sending the intid to the gossip menu , too! Remember the parameter 'intid' in our gossip menu? It's ready for use, sir!

    Notice how it also sends the pUnit and player. If we wouldn't be including these we would get an error in the script, as the Test_Unit_Gossip function requires those variables to run, which normally are generated on the fly due to the RegisterEvent.

    Code:
    function Test_Unit_Gossip(pUnit, event, player, pMisc, intid)
    [...]
    	if (intid == 3) then
    		pUnit:GossipMenuAddItem(0, "|cff095F0B     > Races won: 0", 0)
    		pUnit:GossipMenuAddItem(0, "|cFFFF0000     > Races lost: 0", 0)
    	end
    If we're sent back from the selection with the intid it means we can check what value the intid contains. Considering we were sent back with intid as 3, we would have a match here. In case we have a match two additional menu items are displayed, these will appear under the racer! If it's done doing this it'll continue with the rest of the script thus we end up with the menu as displayed in the picture. I have added the spaces (not tabs) in the menu item name so it really looks like it's part of the item above it.

    And that basically wraps it up! Thank you for reading and may it help you in your future gossips.


    If any question arise, please do not hesitate to ask me or send me a PM.


    PS. I'm not writing any race script at the moment so don't ask for the "full" script, this script was created for the purpose of this guide.
    Last edited by Dynashock; 01-02-2010 at 05:32 AM.

    [Lua] Gossip Dropdown Menus
  2. #2
    slade1000's Avatar Active Member

    Reputation
    66
    Join Date
    Jun 2008
    Posts
    99
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats nice work I did not know you could do this thanks

  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)
    Solid guide, explains it well and actually goes beyond basic Lua unlike the other guides I have seen. It is also actually useful. Hope to see more from you.

  4. #4
    Link_S's Avatar Member
    Reputation
    125
    Join Date
    Dec 2008
    Posts
    293
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Finally you unreveal your Lua skills, :P
    I hope to see a lot more of this my friend

    By the way is it really necessary to check the intid in the selection also, cause I don't think it is if you call the function wheter the intid is that or that?
    Last edited by Link_S; 01-02-2010 at 11:09 AM.
    Why do I need a signature?

  5. #5
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Link_S View Post
    Finally you unreveal your Lua skills, :P
    I hope to see a lot more of this my friend

    By the way is it really necessary to check the intid in the selection also, cause I don't think it is if you call the function wheter the intid is that or that?
    Given the current script it's not neccesary no, considering we always want to return to the gossip menu, but with multiple menu items you don't always want every menu item to send you back to the gossip menu.

  6. #6
    Reflection's Avatar Legendary
    Reputation
    783
    Join Date
    Mar 2008
    Posts
    3,377
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Amazing work Dynashock, keep it up!

    Freelance Digital Artist
    https://reflectionartwork.deviantart.com
    You did not desert me
    My brothers in arms


  7. #7
    Confucius's Avatar Super Moderator Don't Look Back in Anger

    CoreCoins Purchaser Authenticator enabled
    Reputation
    1418
    Join Date
    Oct 2007
    Posts
    2,808
    Thanks G/R
    302/311
    Trade Feedback
    7 (100%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Great guide +Rep 3 if I can from me

  8. #8
    thebigman's Avatar Contributor Reliable Trader
    CoreCoins Purchaser
    Reputation
    89
    Join Date
    Dec 2008
    Posts
    605
    Thanks G/R
    2/0
    Trade Feedback
    26 (96%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So technically we did not even need that, you could just have another page/option. This is for vanity ><

  9. #9
    Dynashock's Avatar Contributor

    Reputation
    176
    Join Date
    Nov 2007
    Posts
    203
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by thebigman View Post
    So technically we did not even need that, you could just have another page/option. This is for vanity ><
    Of course, it's just eye candy and easier accessibility. Another page would do the same, but by showing a different kind of approach it might open one's eye. You could say you could use it as a source of inspiration and it's fun to try some new things once in a while.

    Performance wise dependant on exactly what you are trying to do you might be better off with a new page though.
    Ignorance is bliss.

  10. #10
    XatoA's Avatar Active Member
    Reputation
    25
    Join Date
    Nov 2007
    Posts
    128
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thats great, im just learning lua but will use this +1 rep

    edit- says i cant give reputation here?

Similar Threads

  1. [Lua] Gossip item not working -.-
    By Tikki100 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 08-03-2009, 01:11 PM
  2. [Guide] Lua Gossip on Items (Average)
    By AngelSandy in forum WoW EMU Guides & Tutorials
    Replies: 8
    Last Post: 06-20-2009, 07:15 PM
  3. Gossip Lua + Gossip Text
    By cello1993 in forum WoW EMU Questions & Requests
    Replies: 17
    Last Post: 05-12-2009, 07:29 PM
  4. Beginner's Guide to Lua Gossip
    By Dr. Livingstone in forum WoW EMU Guides & Tutorials
    Replies: 13
    Last Post: 10-22-2008, 05:33 PM
  5. [Lua] Gossip Script
    By LJN in forum World of Warcraft Emulator Servers
    Replies: 9
    Last Post: 07-20-2008, 04:38 AM
All times are GMT -5. The time now is 09:17 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