mogoa 发表于 2023-11-18 20:19:03

求1.12版本可以用的tab键切换聊天频道

找了许久不知道1.12版本有没有这个功能的插件代码

目前找到这一段代码 但是不能再1.12版用 会报错

local typeCycle = {
    {
      chatType = 'SAY',
      allowFunc = function() return true end,
    },
    {
      chatType = 'PARTY',
      allowFunc = function() return GetNumSubgroupMembers() > 0 end,
    },
    {
      chatType = 'INSTANCE_CHAT',
      allowFunc = function() return WOW_PROJECT_ID == WOW_PROJECT_MAINLINE and IsInGroup(LE_PARTY_CATEGORY_INSTANCE) and IsInInstance() end,
    },
    {
      chatType = 'RAID',
      allowFunc = function() return GetNumGroupMembers() > 0 and IsInRaid() end,
    },
    {
      chatType = 'GUILD',
      allowFunc = function() return IsInGuild() end,
    },
}

function ChatEdit_CustomTabPressed(editBox)
    if strsub(tostring(editBox:GetText()), 1, 1) == '/' then return end

    local chatType = editBox:GetAttribute('chatType')
    if chatType == 'CHANNEL' or chatType == 'OFFICER' or chatType == 'WHISPER' then
      editBox:SetAttribute('chatType', 'SAY');
      ChatEdit_UpdateHeader(editBox);
    else
      local length = #typeCycle
      for index, tbl in pairs(typeCycle) do
            if chatType == tbl.chatType then
                local step = IsShiftKeyDown() and -1 or 1
                local curr = index + step
                while true do
                  if curr == 0 then
                        curr = length
                  elseif curr > length then
                        curr = 1
                  end
                  if typeCycle.allowFunc() then
                        editBox:SetAttribute('chatType', typeCycle.chatType);
                        ChatEdit_UpdateHeader(editBox);
                        break
                  end
                  curr = curr + step
                end
                break
            end
      end
    end
end
6&to=1
页: [1]
查看完整版本: 求1.12版本可以用的tab键切换聊天频道