• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua NPC Multiline Chat

celogds

New Member
Joined
Dec 7, 2016
Messages
10
Reaction score
0
Hello everyone,

I'm creating a spell teacher npc. When I say "spell" I want him to list all the spells I'm able to learn from him. For that, I need the NPC to say 2 lines of texts (as shown below). But it's not working. He only says the second line.

Can anyone help please? Thanks.
_______________________________________________________________________

elseif msgcontains(msg, 'spell') or msgcontains(msg, 'Spell') then
if getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 then

npcHandler:say("... I teach... 'Find Person', 'Light', 'Create Food', 'Light Healing', 'Ligh Magic Missile', 'Antidote', 'Intense Healing', 'Poison Field', 'Great Light', 'Fire Field', 'Heavy Magic Missile', 'Magic Shield', 'Intense Healing Rune', 'Fireball' and..",1)
npcHandler:say("'Energy Field', 'Destroy Field', 'Ultimate healing', 'Great Fireball', 'Firebomb', 'Creature Illusion', 'Convince Creature', 'Ultimate Healing Rune', 'Chameleon', 'Poison Wall', 'Explosion', 'Fire Wall', 'Invisible', 'Summon Creature' and 'Energy Wall'.", 5)

smiley_talk_state = 0
else
npcHandler:say("I'm sorry but I can only teach druids..", 5)
smiley_talk_state = 0
end
end
return 1
end

_______________________________________________________________________
 
Code:
elseif msgcontains(msg, 'spell') or msgcontains(msg, 'Spell') then
   if getPlayerVocation(cid) == 2 or getPlayerVocation(cid) == 6 then

       npcHandler:say("... I teach... 'Find Person', 'Light', 'Create Food', 'Light Healing', 'Ligh Magic Missile', 'Antidote', 'Intense Healing', 'Poison Field', 'Great Light', 'Fire Field', 'Heavy Magic Missile', 'Magic Shield', 'Intense Healing Rune', 'Fireball' and..",1)
       selfSay("'Energy Field', 'Destroy Field', 'Ultimate healing', 'Great Fireball', 'Firebomb', 'Creature Illusion', 'Convince Creature', 'Ultimate Healing Rune', 'Chameleon', 'Poison Wall', 'Explosion', 'Fire Wall', 'Invisible', 'Summon Creature' and 'Energy Wall'.", 5)

       smiley_talk_state = 0
   else
       npcHandler:say("I'm sorry but I can only teach druids..", 5)
       smiley_talk_state = 0
   end
end
return 1
end

Try this.
I did have similar problem but changing every line after the first one to selfSay instead of npcHandler:say did work out for me.
There is no delay between the msg's tho
 
Last edited:
I googled this:
Code:
site:otland.net long npc chat
And I found this thing:
Code:
selfSay("first text.", cid)
wait(1000)
selfSay("second text.", cid)
wait(1000)
selfSay("third text.", cid)

Long msgs should appear like in real Tibia.
If not, this topic may help you: https://otland.net/threads/how-to-make-npcs-tell-stories.157308/
 
Code:
local function delayedMsg(text) -- put this at the beggining of file
    return npcHandler:say(text, 1)
end


[...]


addEvent(delayedMsg, 1000, "text") -- 1000 means after 1 second

Also you can change this:
Code:
elseif msgcontains(msg, 'spell') or msgcontains(msg, 'Spell') then
To this:
Code:
elseif msgcontains(string.lower(msg), 'spell') then
string.lower will change all letters to lowercase. So, it will work even if player say SPELL or SpElL
 
Last edited:
Code:
local function delayedMsg(text) -- put this at the beggining of file
    return npcHandler:say(text, 1)
end


[...]


addEvent(delayedMsg, 1000, "text") -- 1000 means after 1 second

Also you can change this:
Code:
elseif msgcontains(msg, 'spell') or msgcontains(msg, 'Spell') then
To this:
Code:
elseif msgcontains(string.lower(msg), 'spell') then
string.lower will change all letters to lowercase. So, it will work even if player say SPELL or SpElL

This one was the best example. Worked perfectly for me.
 
Back
Top