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

Discussion in 'Support' started by ochmar, Oct 12, 2018.

  1. ochmar

    ochmar Active Member

    Joined:
    Feb 27, 2016
    Messages:
    121
    Likes Received:
    65
    Best Answers:
    1
    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
    Code (Lua):
    1.  
    2. function doNPCTalkALot(msgs,interval)
    3.     local e={}
    4.     local ret={}
    5.     if interval==nil then
    6.         interval=3000 --3 seconds is default time between messages
    7.     end
    8.     for aux=1,table.getn(msgs) do
    9.         [I][COLOR=#ff0000]NpcHandler:updateFocus()[/COLOR][/I]
    10.         e[aux]={}
    11.         doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_SAY,(aux-1)*interval,e[aux])
    12.         table.insert(ret,e[aux])
    13.     end
    14.  
    15.     return(ret)
    16. end
    17.  
    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.
     
  2. Best Answer:
    Post #2 by ochmar, Oct 12, 2018
  3. ochmar

    ochmar Active Member

    Joined:
    Feb 27, 2016
    Messages:
    121
    Likes Received:
    65
    Best Answers:
    1
    Best Answer
    Self-solved.

    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.
     

Share This Page

Loading...