[Guide] Lua Gossip on Items (Average) menu

User Tag List

Results 1 to 9 of 9
  1. #1
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [Guide] Lua Gossip on Items (Average)

    Hello!

    It's time for my first guide evooor o.O

    I've been looking around and I didn't find any guides regarind this subject. So I thought I would make an easy guide on how to apply some Gossip Lua on an item!

    (NOTE: This guide is easy, for the average Lua scripter. Not a Newbie guide. Before you do this I suggest you make sure that you know how to work with Lua Gossip Menus first as it's not that different from that)

    Let's get started.
    First we set up our usual menu, when working with Gossip scripts (But adds a few modifications!):

    Code:
    function Item_Trigger(item, event, player)
        Item_menu(item, player)
    end
    function Item_menu(item, player)
        if (player:IsInCombat() == true) then
        	player:SendAreaTriggerMessage("I wont work before you get out of combat, silly!")
        	player:SendBroadcastMessage("I wont work before you get out of combat, silly!")
    else
    	item:GossipCreateMenu(XXX, player, 0)
        	item:GossipMenuAddItem(Y, "Mall", 1, 0)
        	item:GossipMenuAddItem(Y, "Heal me!", 2, 0)
    	item:GossipMenuAddItem(Y, "Remove Ressurection Sickness!", 3, 0)
        	item:GossipSendMenu(player)
        end
    end
    Ok, lets break it down.
    Code:
    function Item_Trigger(item, event, player)
        Item_menu(item, player)
    end
    When making Lua Scripts for Items which includes Gossip this function is essential. It defines that we want a menu to show up, as if you were talking with an NPC! Remember we work with items here so we wont use pUnit or Unit. We use item. (item, player)

    Code:
    function Item_menu(item, player)
        if (player:IsInCombat() == true) then
        	player:SendAreaTriggerMessage("I wont work before you get out of combat, silly!")
        	player:SendBroadcastMessage("I wont work before you get out of combat, silly!")
    else
    This function above should be pretty obvious. It checks if the player is in combat, and if he/she is then it wont work and give him or her the message that it wont work before he or she gets out of combat.

    Code:
    item:GossipCreateMenu(XXX, player, 0)
        	item:GossipMenuAddItem(Y, "Mall", 1, 0)
        	item:GossipMenuAddItem(Y, "Heal me!", 2, 0)
    	item:GossipMenuAddItem(Y, "Remove Ressurection Sickness!", 3, 0)
        	item:GossipSendMenu(player)
        end
    end
    So now we have the all familiar Gossip Menu, but with a twist. We use item:Gossip instead of pUnit- or Unit:Gossip, since it's an item and not a unit. The red X's is just the number that has to be unique on every single Gossip Script you ever make that is put into the same Script Folder. The red Y's is just Icons. I don't have a list for that.

    So the "body" of our Gossip Menu is now created. Now we have to "Linkt" those options to actions.

    Code:
    function OnSelect(item, event, player, id, intid, code)
    Now we need the function above. A Gossip always got at least two functions to register. This is no different. There is one difference tho. I am sure you can spot it.

    Code:
    function OnSelect(item, event, player, id, intid, code)
    if (intid == 1) then
    	player:Teleport(mapid,x,y,z,o)
    See. Here we don't need the item to do it for us. We continue.

    Code:
    function OnSelect(item, event, player, id, intid, code)
    if (intid == 1) then
    	player:Teleport(mapid,x,y,z,o)
    else
    if (intid == 2) then
    	player:CastSpell(1908) -- Uber Heal Over time
    else
    if (intid == 3) then
    		player:LearnSpell(15007) -- Learns Ressurection Sickness
    		player:UnlearnSpell(15007) -- Unlearns Ressurection Sickness
    	player:SendAreaTriggerMessage("Good as new!")
    	player:SendBroadcastMessage("Good as new!")
    end
    Now we are almost done. We just need the last two functions that will register this.

    Code:
    RegisterItemGossipEvent(ITEM ID,1,"Item_Trigger")
    RegisterItemGossipEvent(ITEM ID,2,"OnSelect")
    Remember that we have to use RegisterItemGossipEvent since this is not a Unit. The 1 is OnTalk (Which basically is pressing the item in this case) and 2 is OnSelect. Which is when we choose one of the stated options.

    The Result should look like this:
    Code:
    function Item_Trigger(item, event, player)
        Item_menu(item, player)
    end
    
    function Item_menu(item, player)
        if (player:IsInCombat() == true) then
        	player:SendAreaTriggerMessage("I wont work before you get out of combat, silly!")
        	player:SendBroadcastMessage("I wont work before you get out of combat, silly!")
    else
        	item:GossipCreateMenu(XXX, player, 0)
        	item:GossipMenuAddItem(Y, "Mall", 1, 0)
        	item:GossipMenuAddItem(Y, "Heal me!", 2, 0)
    	item:GossipMenuAddItem(Y, "Remove Ressurection Sickness!", 3, 0)
        	item:GossipSendMenu(player)
        end
    end
    
    function OnSelect(item, event, player, id, intid, code)
    if (intid == 1) then
    	player:Teleport(mapid,x,y,z,o)
    else
    if (intid == 2) then
    	player:CastSpell(1908) -- Uber Heal Over time
    else
    if (intid == 3) then
    		player:LearnSpell(15007) -- Learns Ressurection Sickness
    		player:UnlearnSpell(15007) -- Unlearns Ressurection Sickness
    	player:SendAreaTriggerMessage("Good as new!")
    	player:SendBroadcastMessage("Good as new!")
    end
    
    RegisterItemGossipEvent(ITEM ID,1,"Item_Trigger")
    RegisterItemGossipEvent(ITEM ID,2,"OnSelect")
    Now all you need to do, is having an item which can be right-clicked already. Else it wont work. Look around in your Database and check for like...Polar Bear Pet or something. Check what type or class the item is, and see if you can get the same right click function.

    I hope this can be used!

    [Guide] Lua Gossip on Items (Average)
  2. #2
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My last post was removed?
    Anyway..29 views yet still no comments -.-'

  3. #3
    makis5's Avatar Member
    Reputation
    2
    Join Date
    Sep 2008
    Posts
    17
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    First post I like this thanks +rep !!!You know i am new in lua and i like something like this!

  4. #4
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you =)

  5. #5
    Glorianglorre's Avatar Active Member
    Reputation
    40
    Join Date
    Feb 2009
    Posts
    340
    Thanks G/R
    1/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is good AngelSandy

  6. #6
    Found's Avatar Banned
    Reputation
    239
    Join Date
    Mar 2009
    Posts
    642
    Thanks G/R
    1/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Repost, should probably check your forums. Although it's nice.. Please look.

  7. #7
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is it a repost?
    I checked the forums and the "suggestions" it shows also =/

  8. #8
    Death_Master's Avatar Member
    Reputation
    4
    Join Date
    Mar 2009
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's a repost yes but this is a way better guide than most of the others.

  9. #9
    AngelSandy's Avatar Member
    Reputation
    19
    Join Date
    Jan 2009
    Posts
    330
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Death_Master View Post
    ...but this is a way better guide than most of the others.
    Why thank you ^^

Similar Threads

  1. [Lua] A Complete Guide To Gossip
    By Daimyo2704 in forum WoW EMU Guides & Tutorials
    Replies: 11
    Last Post: 07-12-2010, 03:30 AM
  2. [Lua] Gossip item not working -.-
    By Tikki100 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 08-03-2009, 01:11 PM
  3. 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
  4. Guide to gag/fun items in wow
    By raunchy in forum World of Warcraft Guides
    Replies: 10
    Last Post: 05-29-2007, 12:34 PM
  5. Quick and easy guide to unique instance items at lower levels :)
    By Shanka in forum World of Warcraft Guides
    Replies: 4
    Last Post: 08-01-2006, 04:41 PM
All times are GMT -5. The time now is 04:47 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search