Could someone give me a simple example of how to recognise the input from a Channel please? I just cant seem to get it working correctly and the documentation on the wiki doesn't explain it.
I can't seem to figure out which variables should be within the anonymous function for the speech callback
Edit: Here's some code I made while trying to get it to work. I had a look through the XenoLuaLib file and it looks like when someone speaks the speech callback is called with a variable 'message', but it still seems to print blank in the server log.
Code:
ConfigChannel = {}
function ConfigChannel:new()
local configChannel = {}
local thisChannel = nil
function configChannel:open(channelName)
thisChannel = Channel.New(channelName, function(message) self:inputReceived(message) end, function() print("closed") end)
end
function configChannel:stop()
thisChannel:Close()
end
function configChannel:inputReceived(message)
print(message)
end
configChannel:open("Config")
return configChannel
end
configChannel = ConfigChannel:new()
Here's the parts of the code from the XenoLuaLib file I'm referring to above:
Code:
function Channel:SpeakCallback(message)
if (self._speakCallback == nil) then return 0 end
return self._speakCallback(self, message)
end
Code:
function libOnCustomChannelSpeak(channel, message)
for i, c in ipairs(libChannels) do
if (c:ID() == math.floor(channel)) then
c:SpeakCallback(message)
break
end
end
end
Edit: Nevermind! I got it working after looking through the XenoLuaLib some more. I just needed another variable for the channel object. e.g.
Code:
function configChannel:open(channelName)
thisChannel = Channel.New(channelName, function(obj, message) self:inputReceived(message) end, function() print("closed") end)
end