Jack Parsons
Member
I'm having difficulties finding how to access the answer that I gave to the NPC. Let us use this script as an example:
Pretty straightfoward. As you can see, I say "creature" to the NPC and that triggers the function tell, and then he just asks me to say the name of some creature. The problem is, I want to use the name that I gave him as an answer to be the trigger-word for the next function. How can I access the answer that I gave to the NPC through the node that is returned by the addKeyword()?
Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid)
npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg)
npcHandler:onCreatureSay(cid, type, msg)
end
function onThink()
npcHandler:onThink()
end
function tell(cid, message, keywords, parameters, node)
local npcHandler = parameters.npcHandler
if npcHandler == nil then
error("tell called without any npcHandler instance.")
end
if not npcHandler:isFocused(cid) then
return false
end
npcHandler:say(parameters.text, cid)
npcHandler:resetNpc(cid)
return true
end
local node = keywordHandler:addKeyword({'creature'}, tell, {npcHandler = npcHandler, onlyFocus = true, text = 'Tell me the name of a {creature}, and I'll repeat it to you...'})
node:addChildKeyword({ANSWER_THAT_I_GAVE}, someFunc, {})
npcHandler:addModule(FocusModule:new())
Pretty straightfoward. As you can see, I say "creature" to the NPC and that triggers the function tell, and then he just asks me to say the name of some creature. The problem is, I want to use the name that I gave him as an answer to be the trigger-word for the next function. How can I access the answer that I gave to the NPC through the node that is returned by the addKeyword()?