Solved npcHandler:updateFocus() does not "update" focus.

ochmar

Active Member
Joined
Feb 27, 2016
Messages
184
Reaction score
94
Hello,
So I'm having this trouble that npcHandler does not update focus when I try to trigger it manually.
When I use NpcHandler: onThink() he naturally updates focus (as part of onThink function makes "self:updateFocus()").
This would not be a problem, as talking writing NPC with npcHandler:say('x') extends NPC's focus, but I'm using doNPCTalkALot(texts, delay) function instead.
This function get table of texts, and says them "after delay" time. Something like storytelling.
This is doNPCTalkALot from lib\npc.lua
Lua:
function doNPCTalkALot(msgs,interval)
    local e={}
    local ret={}
    if interval==nil then
        interval=3000 --3 seconds is default time between messages
    end
    for aux=1,table.getn(msgs) do
        [I][COLOR=#ff0000]NpcHandler:updateFocus()[/COLOR][/I]
        e[aux]={}
        doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_SAY,(aux-1)*interval,e[aux])
        table.insert(ret,e[aux])
    end
 
    return(ret)
end
And I would like this function to update the focus each time it continues to say something.
I tried to use this in npc_name.lua but got no effect what-so-ever.
Yes, of course, I can extend npcHandler.idleTime or use npcHandler:say(x) but I would like to make it right.

My question then, is how to manually updateFocus() then? Either in that function or in NPC talks.
 
OP
ochmar

ochmar

Active Member
Joined
Feb 27, 2016
Messages
184
Reaction score
94
Self-solved.

For god-knows-what reason, each and every creature callback has to return value.
In my loop, I returned else false or none.
Had to return true instead of none.
 
Last edited:
Top