You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have encountered a troublesome problem. This problem is most likely not AIO's problem, I hope you can get help.
server file name: myaddon_server.lua
Lua Code:
local AIO = AIO or require("AIO")
local ItemStateHandler = AIO.AddHandlers("ItemStateUI", {})
-- Receive messages from the client
function ItemStateHandler.GetItemBonus(player)
-- Handling messages here....
AIO.Handle(player, "ItemStateUI", "ModifyState", 10000) -- Send the message back to the client side
end
client file name: myaddon_client.lua
Lua Code:
local AIO = AIO or require("AIO")
if AIO.AddAddon() then
return
end
local ItemStateHandler = AIO.AddHandlers("ItemStateUI", {})
-- global GameTooltip Obj
local globalItemObj = nil
local function ModifyShow(tooltip)
if not tooltip then return end
local _, ItemLink = tooltip:GetItem()
if not ItemLink then
return
end
local typ, _, _, _, _, _, _, _, _, _ = strsplit(":", string.match(ItemLink, "item[%-?%d:]+"))
if typ ~= "item" then
return
end
globalItemObj = tooltip
AIO.Handle("ItemStateUI", "GetItemBonus"); -- req server
end
GameTooltip:HookScript("OnTooltipSetItem", function(self)
--getglobal("GameTooltipTextLeft1"):SetText("This is the newly added content.")
ModifyShow(self)
end)
ItemRefTooltip:HookScript("OnTooltipSetItem", function(self)
ModifyShow(self)
end)
function ItemStateHandler.ModifyState(player, serverStr)
if not globalItemObj then return end
local _, ItemLink = globalItemObj:GetItem()
if not ItemLink then
return
end
local typ, _, _, _, _, _, _, _, _, _ = strsplit(":", string.match(ItemLink, "item[%-?%d:]+"))
if typ ~= "item" then
return
end
for i = 1, globalItemObj:NumLines() do
local tooltip = getglobal(globalItemObj:GetName() .. "TextLeft" .. tostring(i)):GetText()
local tmpStr = tooltip .. serverStr
getglobal(globalItemObj:GetName() .. "TextLeft" .. tostring(i)):SetText(tmpStr)
end
end
At this point, when using the two previously created characters to view their own items, GameToolpoint is called, and everything works fine, but when viewing each other's items through the characters, the item text does not change.
However, the ItemRefToolTip object is valid. There are always changes.
The above are the problems encountered when using GameToolpoint.
To solve this problem, I added some print information. The code is as follows:
Lua Code:
GameTooltip:HookScript("OnTooltipSetItem", function(self)
--getglobal("GameTooltipTextLeft1"):SetText("This is the newly added content.")
print("this is gameTooltip", self)
ModifyShow(self, self:GetName())
end)
function ItemStateHandler.ModifyState(player, serverStr)
if not globalItemObj then return end
local _, ItemLink = globalItemObj:GetItem()
if not ItemLink then
return
end
local typ, _, _, _, _, _, _, _, _, _ = strsplit(":", string.match(ItemLink, "item[%-?%d:]+"))
if typ ~= "item" then
return
end
print("this is globalItemObj", globalItemObj, globalItemObj:GetName())
for i = 1, globalItemObj:NumLines() do
local tooltip = getglobal(globalItemObj:GetName() .. "TextLeft" .. tostring(i)):GetText()
local tmpStr = tooltip .. serverStr
getglobal(globalItemObj:GetName() .. "TextLeft" .. tostring(i)):SetText(tmpStr)
local printStr = getglobal(globalItemObj:GetName() .. "TextLeft" .. tostring(i)):GetText()
print("after str:", printStr)
end
end
The result after str is indeed appended, but it is not displayed (when character 1 views character 2 items, the tooltip display of character 1 is not updated.)
Thank you for listening to my long-winded. Any help I really appreciate :)
The text was updated successfully, but these errors were encountered:
I have encountered a troublesome problem. This problem is most likely not AIO's problem, I hope you can get help.
server file name: myaddon_server.lua
client file name: myaddon_client.lua
At this point, when using the two previously created characters to view their own items, GameToolpoint is called, and everything works fine, but when viewing each other's items through the characters, the item text does not change.
However, the ItemRefToolTip object is valid. There are always changes.
The above are the problems encountered when using GameToolpoint.
To solve this problem, I added some print information. The code is as follows:
The result after str is indeed appended, but it is not displayed (when character 1 views character 2 items, the tooltip display of character 1 is not updated.)
Thank you for listening to my long-winded. Any help I really appreciate :)
The text was updated successfully, but these errors were encountered: