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: [Only registered and activated users can see links. ]
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: [Only registered and activated users can see links. ]. For those of you who can't, here is it in .ZIP format: [Only registered and activated users can see links. ]. 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:
Quote:
function On_Gossip (pUnit, event, player)
Third, we must create our Gossip Menu.
Quote:
pUnit:GossipCreateMenu(100, player)
Next, it is time to add the actual menus and lines.
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:
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.
Quote:
if(intid == 2) then
Now guess what? Thats right, we have to add the submenus. 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).
Quote:
if(intid == 10) then
player:Teleport(1, 1371.068970, -4370.801758, 26.052483)
end
Now just repeat this until your done adding all the submenu's teleport locations.
Then you should add this line at the end of all your teleports:
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.
Here is my TeleportNPC: [Only registered and activated users can see links. ]
If your having trouble see this guide: [Only registered and activated users can see links. ]
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...
Last edited by SectorSeven; 05-31-2008 at 03:21 PM.
SectorSeven, you are realy good in LUA it seems like this script, can i talk to you through MSN? you need to learn me some stuff and i want to ask you some stuff to
I wish to get more advanced with LUA's
add me : [Only registered and activated users can see links. ]
EDIT : i made a small version of this myself, i dont know if it works or not but :
Code:
function WarpNPC_On_Gossip (pUnit, event, player)
pUnit:GossipCreateMenu(100, player)
pUnit:GossipMenuAddItem(player, 0, "Horde Locations", 1, 0)
pUnit:GossipMenuAddItem(player, 0, "Alliance Locations", 2, 0)
pUnit:GossipSendMenu(player)
end
function WarpNPC_Submenus (pUnit, event, player, id, intid, code)
if(intid == 1) then
pUnit:GossipGossipMenuAddItem(99, player)
pUnit:GossipMenuAddItem(player, 5, "Mall", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Leveling Road", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Custom Instances", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu(player)
end
if(intid == 2) then
pUnit:GossipCreateMenu(99, player)
pUnit:GossipMenuAddItem(player, 5, "Mall", 10, 0)
pUnit:GossipMenuAddItem(player, 5, "Leveling Road", 11, 0)
pUnit:GossipMenuAddItem(player, 5, "Custom Instances", 12, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:MenuSendToPlayer(player)
end
if(intid == 10) then
player:Teleport(1, -1657.646973, 3096.333008, 32.558029)
end
if(intid == 11) then
player:Teleport(580, 1713.559937, 600.632690, 29.677027)
end
function WarpNPC_Submenus2 (pUnit, event, player, id, intid, code)
if(intid == 12) then
pUnit:GossipCreateMenu(99, player)
pUnit:GossipMenuAddItem(player, 5, "Malygos' Lair(10-15Man)", 13, 0)
pUnit:GossipMenuAddItem(player, 5, "Scarlet Monastery(5-10Man)", 14, 0)
pUnit:GossipMenuAddItem(player, 5, "The Deadmines(10Man)", 15, 0)
pUnit:GossipMenuAddItem(player, 5, "[Back]", 50, 0)
pUnit:GossipSendMenu(player)
end
if(intid == 13) then
player:Teleport(530, 3099.646729, 1513.975342, 192.195267)
end
if(intid == 14) then
player:Teleport(0, 2888.867188, -810.674438, 162.649765)
end
if(intid == 15) then
player:Teleport(0, -11211.107422, 1661.814087, 26.746098)
end
RegisterGossipEvent(32000 , 1, "WarpNPC_On_Gossip")(32000 , 2,"WarpNPC_Submenus")(32000 , 2,"WarpNPC_Submenus2")
Should this work or? and also is there any way to test the LUA's on if they work or not without hosting an actual server?
Hey SectorSeven i'd love to speak to you a bit to help me learn a bit more LUA im pretty advanced at it but theres alot you can teach me i believe (also i wanna ask something about ABD)
my msn is
[Only registered and activated users can see links. ]
i dont have MSN messenger on this comp and my other one is broke ok dude but i'll get on this one soon : )
Right before you begin your if statements, you have a function. Wouldn't you need two end's in order to close both the last if statement and then the function?
Site n00b.. (A leecher if I've been here for more than a month and can't earn 5 rep)
Rep Power: 1
Reputation: 2
Posts: 21
Join Date: Apr 2008
05-23-2008
Code:
3>SpellHandlers - 0 error(s), 1 warning(s)
5>------ Build started: Project: LUAScripting, Configuration: Release Win32 ------
5>Compiling...
5>cl : Command line warning D9035 : option 'Wp64' has been deprecated and will be removed in a future release
5>LUAEngine.cpp
4>Setup.cpp
5>..srcluascriptingLUAEngine.cpp(4) : fatal error C1083: Cannot open include file: 'ScriptSetup.h': No such file or directory
5>Build log was saved at "file://c:UsersChrilleDesktopNy mappsrcscriptsprojects2008_int_release_LUAScriptingBuildLog.htm"
5>LUAScripting - 1 error(s), 1 warning(s)