PDA

View Full Version : Custom channel



xto94
12-01-2015, 11:34 PM
Hi, i have problem with custom channel

here's the code:

function onSpeak(channel, text)
channel:SendYellowMessage("Script",text)
if (text == '/help') then

channel:SendOrangeMessage('COMMANDS')
channel:SendYellowMessage('/quest - starts from the beginning')
channel:SendOrangeMessage('/task - get task from NPC')
elseif (text == 'quest') then
Walker.Start()
Targeting.Start()
elseif (text == 'task') then
gotoLabel("Task")
Walker.Start()
Targeting.Start()
elseif (text == 'testmsg') then
channel:SendYellowMessage('test message')
end

end

local channel = Channel.New("Script channel", onSpeak)
channel:SendYellowMessage('type /help')
channel:SendYellowMessage('testtesttesttesttest')




00:35 type /help: 0
00:35 testtesttesttesttest: 0
00:32 Script: /help
00:32 COMMANDS: 0
00:32 /quest - starts from the begi: 0 -- <<also here it cut some text
00:32 /task - get task from NPC: 0
and here's the result of trying commands... how to eliminate the "0"s and ":" at end of lines?

shadowart
12-02-2015, 12:56 AM
When you sent a message to a custom channel you have to supply two arguments: first the name of the speaker and then the actual message. You're sending your message as the speaker's name. That is both the reason why it gets truncated and why the 0 appears (print(nil) prints a 0).

So change "channel:SendYellowMessage('testtesttesttesttest')" to "channel:SendYellowMessage('Whatever name you want', 'testtesttesttesttest')".