请帮忙。我正在尝试修复此代码,我只是没有看到错误。我很缺乏经验,感谢你能给我的任何帮助。感谢。
错误:UberInventory-6.8.lua:1325:尝试索引本地'工具提示'(零值)
代码 - 从第1320行开始
function UberInventory_HookTooltip( tooltip )
-- From global to local
local UBI_Hooks = UBI_Hooks;
-- Store default script
local tooltipName = tooltip:GetName();
UBI_Hooks["OnTooltipSetItem"][tooltipName] = tooltip:GetScript( "OnTooltipSetItem" );
UBI_Hooks["OnTooltipCleared"][tooltipName] = tooltip:GetScript( "OnTooltipCleared" );
-- Set new script to handle OntooltipSetItem
tooltip:SetScript( "OnTooltipSetItem", function( self, ... )
-- From global to local
local UBI_Hooks = UBI_Hooks;
-- Get tooltip name
local tooltipName = self:GetName();
-- Call default script
if ( UBI_Hooks["OnTooltipSetItem"][tooltipName] ) then
UBI_Hooks["OnTooltipSetItem"][tooltipName]( self, ... );
end;
-- Call new script (adds the item information)
UberInventory_AddItemInfo( self );
-- Turn on UberInventory indicator
self.UBI_InfoAdded = true;
end );
-- Set new script to handle OnTooltipCleared
tooltip:SetScript( "OnTooltipCleared", function( self, ... )
-- From global to local
local UBI_Hooks = UBI_Hooks;
-- Get tooltip name
local tooltipName = self:GetName();
-- Force reset of fonts (maxlines is a custom attribute added within the UberInventory_AddItemInfo function)
if ( self.maxlines ) then
local txtLeft, txtRight;
for i = 1, self.maxlines do
txtLeft = _G[self:GetName().."TextLeft"..i];
txtRight = _G[self:GetName().."TextRight"..i];
if ( txtLeft ) then txtLeft:SetFontObject( GameTooltipText ); end;
if ( txtRight ) then txtRight:SetFontObject( GameTooltipText ); end;
end;
end;
-- Call default script
if ( UBI_Hooks["OnTooltipCleared"][tooltipName] ) then
UBI_Hooks["OnTooltipCleared"][tooltipName]( self, ... );
end;
-- Turn off UberInventory indicator
self.UBI_InfoAdded = false;
end );
end;
这是2074到2087行的代码,其中称为“HookTooltip”
function UberInventory_Install_Hooks()
-- Hook the Tooltips (OnTooltipSetItem, OnTooltipCleared)
UberInventory_HookTooltip( GameTooltip );
UberInventory_HookTooltip( ItemRefTooltip );
UberInventory_HookTooltip( ShoppingTooltip1 );
UberInventory_HookTooltip( ShoppingTooltip2 );
UberInventory_HookTooltip( ShoppingTooltip3 );
-- Hook mail stuff
UBI_Hooks["ReturnInboxItem"] = ReturnInboxItem;
ReturnInboxItem = UberInventory_ReturnInboxItem;
UBI_Hooks["SendMail"] = SendMail;
SendMail = UberInventory_SendMail;
end;
答案 0 :(得分:1)
您呼叫的功能(UberInventory_HookTooltip
)获取nil
值作为toolkit
参数。当您尝试调用该tookit
对象(tooltip:GetName()
)的方法时,您会收到预期的错误:"尝试索引本地'工具提示' (零值)"。代码尝试在表中找到一个应该存储在GetName
中的字段tooltip
,但是没有这样做(对于"索引"表),因为值为nil。您需要检查调用该函数的代码,以确保它传递正确的值。如果没有看到调用UberInventory_HookTooltip
的代码,就无法向您提供任何进一步的帮助。