In this guide, you will learn to use Gossip Menus correctly. I will be using the WarpNPC LUA script as my example. You will need to read my guide on Basic LUA before you move on to this guide, as I call it, my LUA 1.5 guide before the advanced guide is released.
Prerisque: http://www.mmowned.com/forums/ascent-guides/96215-scripting-lua-101-a.html
This guide is currently being revamped - meaning its being rewritten in a better format. I will be doing guards in LUA as my example.
Ok, lets get started!
First, your going to need the patch for this. I recommend that you do not use it as it does not work with the latest OpenAscent or Ascent revisions. I would simply recommend that you use LUA++'s LUA folder, which has all these cool LUA patches applied. For those of you who can compile, here is their SVN address: http://mmoforge.org/svn/luaplusplus. For those of you who can't, here is it in .ZIP format: http://filebeam.com/e955415d274d74d7bcadec8344299506. Simply replace this LUAScripting folder with the current one.
Second, we need to look at the commands that are included that we will need to create our Gossip Menu.
Here they are:
:GossipCreateMenu
:GossipMenuAddItem
:GossipSendMenu
:GossipComplete
:GossipSendPOI
Second, it is time to start our script off with the usual "function" line.
Example:
Third, we must create our Gossip Menu.function On_Gossip (pUnit, event, player)
Next, it is time to add the actual menus and lines.pUnit:GossipCreateMenu(100, player)
Third, Make sure that you are labeling the "" part with the Menu's name and then the number following that, the number of the menu.pUnit:GossipMenuAddItem(player, 0, "Horde Cities", 1, 0)
pUnit:GossipMenuAddItem(player, 0, "Alliance Cities", 2, 0)
Fourth, we need to send the menu with the function :GossipSendMenu.
Code:pUnit::GossipSendMenu(player)
Fifth, we need to end that function. So it should look something like this:
Now to start on the submenus! Start it off with function line:function On_Gossip (pUnit, event, player)
pUnit:GossipCreateMenu(100, player)
pUnit:GossipMenuAddItem(player, 0, "Horde Cities", 1, 0)
pUnit:GossipMenuAddItem(player, 0, "Alliance Cities", 2, 0)
pUnit:GossipSendMenu(player)
end
Sixth, we need to declare that we are using the menu 1, or "Horde Cities". We will do this by using this statement:function Gossip_Submenus (pUnit, event, player, id, intid, code)
This says that if the menu number is 1, then we will recall the following until we hit the "end" statement.if(intid == 1) then
Now, we need to add our submenus for "Horde Cities". We also need to add the :GossipSendMenu to the bottom.
Take note that the 99 is 1 number less than the 100 we used in the first function. This is consistant for all submenus. Now add the "end" statement to the end of that group of Menus and you should have something like this:pUnit:GossipGossipMenuAddItem(99, player)
pUnit:GossipMenuAddItem(player, 5, "Orgrimmar", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Undercity", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Thunder Bluff", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "Silvermoon", 13, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu
function On_Gossip (pUnit, event, player)
pUnit:GossipCreateMenu(100, player)
pUnit:GossipGossipMenuAddItem(player, 0, "Horde Cities", 1, 0)
pUnit:GossipGossipMenuAddItem(player, 0, "Alliance Cities", 2, 0)
pUnit:GossipSendMenu(player)
end
function Gossip_Submenus (pUnit, event, player, id, intid, code)
if(intid == 1) then
pUnit:GossipGossipMenuAddItem(99, player)
pUnit:GossipMenuAddItem(player, 5, "Orgrimmar", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Undercity", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Thunder Bluff", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "Silvermoon", 13, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu(player)
end
Seventh, its time to do the submenu for the number 2, or "Alliance Cities". We have to use the "if" statement again to recall this menu.
Now guess what? Thats right, we have to add the submenus.if(intid == 2) then
So repeat the steps from step six, exept this time we need to change the numbers after the Menu name because they will be recalled later. It should look something like this:
Eighth, we need to add the locations for the teleporting. Use this format and simply repeat. After the == signs, add the number after the submenu name for the teleportion. Of course the format is (Map, X, Y, Z).pUnit:GossipCreateMenu(99, player)
pUnit:GossipMenuAddItem(player, 5, "Stormwind", 14, 0)
pUnit:GossipMenuAddItem(player, 5, "Ironforge", 15, 0)
pUnit:GossipMenuAddItem(player, 5, "Darnassus", 16, 0)
pUnit:GossipMenuAddItem(player, 5, "Exodar", 17, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:MenuSendToPlayer(player)
end
Now just repeat this until your done adding all the submenu's teleport locations.if(intid == 10) then
player:Teleport(1, 1371.068970, -4370.801758, 26.052483)
end
Then you should add this line at the end of all your teleports:
Finally, register the events:intid = 0
end
For 32000, you simply put the NPC ID. You will then need to create an NPC with the flags set to gossip flags, or 1.RegisterGossipEvent(32000 , 1, "On_Gossip")(32000 , 2,"Gossip_Submenus")
Here is my TeleportNPC:
http://s7guide.pastebin.com/f2137e665
If your having trouble see this guide: Getting NPC Gossip Stuff Working[Mini-tut] - General discussion - Temp - Lua++ Forums
I hope this guide helped you and will keep you busy until my LUA: For Advanced Users guide is released. I will, in the meantime, be doing some XML and LUA tutorials related to WoW addons. So if you wanna check those out feel free.
-SectorSeven
Credits: To whoever has the time to find the coords. for these places...