• 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!

OTClient NPC Highlight speech blue

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
686
Solutions
15
Reaction score
52
Location
Brazil
You know when you put any words into "{ }" in a NPC phrase and it gets highlighted in a deeper blue? Well, I'm looking for the code that make this works. Had a look in the npc lua system and in the some sources, but haven't found anything. Could you help me deploy this on my server? It's an OTX 2 (TFS 0.3.7) and using OTCv8.

1635958857867.png
1635958878199.png
 
Last edited:
Solution
just changed

Change: if speaktype.npcChat and (g_game.getCharacterName() ~= creatureName or g_game.getCharacterName() == 'Account Manager') then
To: if (g_game.getCharacterName() ~= creatureName or g_game.getCharacterName() == 'Account Manager') then

Thank you @margoh

Evil Puncker

I know nothing
TFS Developer
Joined
May 30, 2009
Messages
8,117
Solutions
218
Reaction score
4,037
that only works at npc channel (where messages are light blue), since you use "old" npc way that use the default channel it wont be possible
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
686
Solutions
15
Reaction score
52
Location
Brazil
Maybe that can help You.
Works in parts...text in default channel still the same, there's a way to fix? Thanks for help!

1635966811797.png
Post automatically merged:

In page one it tells to find in "addTabText(text, speaktype, tab, creatureName) function" following text:

Lua:
if not labelHighlight then
        labelHighlight = g_ui.createWidget('ConsolePhantomLabel', label)
        labelHighlight:fill('parent')
        labelHighlight:setId('consoleLabelHighlight')
        labelHighlight:setColor("#1f9ffe")
      end

but mine is like that:

Lua:
function addTabText(text, speaktype, tab, creatureName)
  if not tab or tab.locked or not text or #text == 0 then return end

  if modules.client_options.getOption('showTimestampsInConsole') then
    text = os.date('%H:%M') .. ' ' .. text
  end

  local panel = consoleTabBar:getTabPanel(tab)
  local consoleBuffer = panel:getChildById('consoleBuffer')

  local label = nil
  if consoleBuffer:getChildCount() > MAX_LINES then
    label = consoleBuffer:getFirstChild()
    consoleBuffer:moveChildToIndex(label, consoleBuffer:getChildCount())
  end

  if not label then
    label = g_ui.createWidget('ConsoleLabel', consoleBuffer)
  end
  label:setId('consoleLabel' .. consoleBuffer:getChildCount())
  label:setText(text)
  label:setColor(speaktype.color)
  consoleTabBar:blinkTab(tab)

  if speaktype.npcChat and (g_game.getCharacterName() ~= creatureName or g_game.getCharacterName() == 'Account Manager') then
    local highlightData = getNewHighlightedText(text, speaktype.color, "#1f9ffe")
    if #highlightData > 2 then
      label:setColoredText(highlightData)
    end
  end

  label.name = creatureName
  consoleBuffer.onMouseRelease = function(self, mousePos, mouseButton)
    processMessageMenu(mousePos, mouseButton, nil, nil, nil, tab)
  end
  label.onMouseRelease = function(self, mousePos, mouseButton)
    processMessageMenu(mousePos, mouseButton, creatureName, text, self, tab)
  end
  label.onMousePress = function(self, mousePos, button)
    if button == MouseLeftButton then clearSelection(consoleBuffer) end
  end
  label.onDragEnter = function(self, mousePos)
    clearSelection(consoleBuffer)
    return true
  end
  label.onDragLeave = function(self, droppedWidget, mousePos)
    local text = {}
    for selectionChild = consoleBuffer.selection.first, consoleBuffer.selection.last do
      local label = self:getParent():getChildByIndex(selectionChild)
      table.insert(text, label:getSelection())
    end
    consoleBuffer.selectionText = table.concat(text, '\n')
    return true
  end
  label.onDragMove = function(self, mousePos, mouseMoved)
    local parent = self:getParent()
    local parentRect = parent:getPaddingRect()
    local selfIndex = parent:getChildIndex(self)
    local child = parent:getChildByPos(mousePos)

    -- find bonding children
    if not child then
      if mousePos.y < self:getY() then
        for index = selfIndex - 1, 1, -1 do
          local label = parent:getChildByIndex(index)
          if label:getY() + label:getHeight() > parentRect.y then
            if (mousePos.y >= label:getY() and mousePos.y <= label:getY() + label:getHeight()) or index == 1 then
              child = label
              break
            end
          else
            child = parent:getChildByIndex(index + 1)
            break
          end
        end
      elseif mousePos.y > self:getY() + self:getHeight() then
        for index = selfIndex + 1, parent:getChildCount(), 1 do
          local label = parent:getChildByIndex(index)
          if label:getY() < parentRect.y + parentRect.height then
            if (mousePos.y >= label:getY() and mousePos.y <= label:getY() + label:getHeight()) or index == parent:getChildCount() then
              child = label
              break
            end
          else
            child = parent:getChildByIndex(index - 1)
            break
          end
        end
      else
        child = self
      end
    end

    if not child then return false end

    local childIndex = parent:getChildIndex(child)

    -- remove old selection
    clearSelection(consoleBuffer)

    -- update self selection
    local textBegin = self:getTextPos(self:getLastClickPosition())
    local textPos = self:getTextPos(mousePos)
    self:setSelection(textBegin, textPos)

    consoleBuffer.selection = { first = math.min(selfIndex, childIndex), last = math.max(selfIndex, childIndex) }

    -- update siblings selection
    if child ~= self then
      for selectionChild = consoleBuffer.selection.first + 1, consoleBuffer.selection.last - 1 do
        parent:getChildByIndex(selectionChild):selectAll()
      end

      local textPos = child:getTextPos(mousePos)
      if childIndex > selfIndex then
        child:setSelection(0, textPos)
      else
        child:setSelection(string.len(child:getText()), textPos)
      end
    end

    return true
  end
end
 
Last edited:
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
686
Solutions
15
Reaction score
52
Location
Brazil
just changed

Change: if speaktype.npcChat and (g_game.getCharacterName() ~= creatureName or g_game.getCharacterName() == 'Account Manager') then
To: if (g_game.getCharacterName() ~= creatureName or g_game.getCharacterName() == 'Account Manager') then

Thank you @margoh
 
Solution
Top