+ Reply to Thread
Results 1 to 3 of 3

Thread: is it possible to send a chat message from a lua function in an addon?

  1. #1
    Soulwalker
    Join Date
    Oct 2012
    Posts
    24

    Default is it possible to send a chat message from a lua function in an addon?

    So, I'm just learning how to create an addon, and I'm stumped.

    this works:
    myUI.BackgroundTexture.Event.RightClick = "chat 4 hello world"

    it sends a chat message to channel 4, saying "hello world."

    but if I want to do it this way instead:
    function myMethodName()
    -- what goes here? "chat 4 hello world" sure doesnt work
    dump ("this code is running correctly")
    end
    function myUI.BackgroundTexture.Event:RightClick()
    myMethodName()
    end

    I have no idea what to put in there. The "dump" message works so I know that the event is firing. Can someone help me please?
    Thanks!

  2. #2
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    You can't do this. Consider:

    Code:
    while true do
      spamchannel()
    end
    Your first example works, because you are in effect running a macro, and macro's can send messages to channels.
    Last edited by Adelea; 03-04-2014 at 11:33 AM.
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  3. #3
    RIFT Guide Writer Noshei's Avatar
    Join Date
    Feb 2011
    Posts
    1,886

    Default

    Also, the example you gave that does with is using the old event system. It is not recommended to use the old event system as it will be getting phased out of the game shortly.

    Take a look at the following documentation for the new event system, this provides the same functionality that you got with the old version

    Code:
    EventMacroSet
    	Function documentation:
    		Sets the macro that will be triggered when this event occurs.
    		Permitted only on a frame with "restricted" SecureMode while the addon environment is not secured.
    			Layout:EventMacroSet(handle, macro)   -- eventFrame, string/nil
    	Parameters:
    		handle:	A handle to a frame event, usually pulled out of the "Event.UI." hierarchy.
    		macro:	The macro to trigger. nil to clear the macro.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts