GHI_ChannelComm

Pilus edited this page Aug 11, 2015 · 1 revision

Syntax

obj = GHI_ChannelComm() obj.function()

'''Note:'''GHI_ChanelComm() uses the xtensionxtooltip2 channel, a common channel used by addon communications. When naming your Prefixes, be unique to not interfere with other users.

Functions

AddRecieveFunc(prefix, rcvFunc)

Arguments

prefix
''String''
This is a string used to identify a command sent for processing by a function.
rcvFunc
''Function''
The receiving function has arguments it is passed automatically. Argument one is the name of the sender. Argument two is "..." which passes any additional data that was sent.
When the prefix is received it will execute this function.
'''Note:''' This function can process arguments passed with GHI_ChannelComm().Send() The arguments are passed in order to the rcvFunc.

Send(prio, prefix, ...)

Arguments

prio
''String''
This is a string that states the priority of the message. Generally it should be set to "NORMAL" or left blank.
prefix
''String''
This is the prefix string being sent to trigger a function.
...
''Any''
These are additional arguments to be passed when sending.

Example

local name = UnitName("player")

local targ = UnitName("target")

local pingComm = GHI_ChannelComm()

local pinger = function(name, ...)

local a,b = select(1, ...)

print(name.." pinged you.")

print("Do you have a ".. a .. " or ".. b .."?")

end

pingComm.AddRecieveFunc("GHI_COMTEST_PING",pinger)

pingComm.Send("NORMAL", "GHI_COMTEST_PING", "Moose", "Dog")

This script acts as a sender and receiver for pinging anyone in the channel who has activated your item.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.