2014-10-17 94 views
-1

请帮忙。我正在尝试修复此代码,但我没有看到该错误。我很缺乏经验,并感谢您可以给我的任何帮助。谢谢。尝试索引本地'工具提示'(一个零值)

错误: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至87年,其中 “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; 

回答

1

您呼叫的函数(UberInventory_HookTooltip)获得一个niltoolkit PARAMET呃。当您尝试调用tookit对象(tooltip:GetName())的方法时,您会收到如下所示的预期错误:“尝试索引本地'工具提示'(一个零值)”。该代码尝试在表中找到应存储在tooltip中的字段GetName,并且因为值为零而无法执行此操作(以“索引”表)。您需要检查调用函数的代码以确保它传递正确的值。没有看到调用UberInventory_HookTooltip的代码,无法给您任何进一步的帮助。

+0

我相信,以下是其中的代码调用它... – Chorthee 2014-10-18 00:00:53

+0

功能UberInventory_Install_Hooks() - 胡克的工具提示(OnTooltipSetItem,OnTooltipCleared) UberInventory_HookTooltip(GameTooltip); UberInventory_HookTooltip(ItemRefTooltip); UberInventory_HookTooltip(ShoppingTooltip1); UberInventory_HookTooltip(ShoppingTooltip2); UberInventory_HookTooltip(ShoppingTooltip3); - 钩邮件 UBI_Hooks [“ReturnInboxItem”] = ReturnInboxItem; ReturnInboxItem = UberInventory_ReturnInboxItem; UBI_Hooks [“SendMail”] = SendMail; SendMail = UberInventory_SendMail; 结束; – Chorthee 2014-10-18 00:03:24

+0

其中一个调用将'nil'作为其值。如果你想弄清楚哪一个,在函数调用的第一行添加如下内容:'if tooltip == nil then error('pass nil'..debug.traceback())end'。 – 2014-10-18 02:06:55

相关问题