尝试对本地变量“tooltip”进行索引(而该变量的值为nil)

请帮忙,我正在尝试解决这个代码问题,但我确实没有看到错误。我非常没有经验,感谢您提供任何帮助。谢谢。

错误:UberInventory-6.8.lua:1325:尝试索引本地变量“tooltip”(空值)

代码 - 从第1320行开始

function UberInventory_HookTooltip(tooltip)
    -- 从全局变量到本地变量
    local UBI_Hooks = UBI_Hooks;

    -- 存储默认脚本
    local tooltipName = tooltip:GetName();
    UBI_Hooks [“OnTooltipSetItem”] [tooltipName] = tooltip:GetScript(“OnTooltipSetItem”);
    UBI_Hooks [“OnTooltipCleared”] [tooltipName] = tooltip:GetScript(“OnTooltipCleared”);

    --设置新脚本以处理OntooltipSetItem
    tooltip:SetScript(“OnTooltipSetItem”,functionself,...)
        -- 从全局变量到本地变量
        local UBI_Hooks = UBI_Hooks;

        -- 获取提示名称
        local tooltipName = selfGetName();

        -- 调用默认脚本
        ifUBI_Hooks [“OnTooltipSetItem”] [tooltipName])then
            UBI_Hooks [“OnTooltipSetItem”] [tooltipName](self,...);
        end;

        -- 调用新脚本(添加项目信息)
        UberInventory_AddItemInfoself);

        -- 打开UberInventory指示器
        self.UBI_InfoAdded = true;
    end);

    --设置新脚本以处理OnTooltipCleared
    tooltipSetScript(“OnTooltipCleared”,functionself,...)
        -- 从全局变量到本地变量
        local UBI_Hooks = UBI_Hooks;

        -- 获取提示名称
        local tooltipName = selfGetName();

        -- 强制重置字体(maxlines是在UberInventory_AddItemInfo函数中添加的自定义属性)
        ifself.maxlinesthen
            local txtLefttxtRight;
            for i = 1,self.maxlines do
                txtLeft = _G [selfGetName()..“TextLeft”..i];
                txtRight = _G [selfGetName()..“TextRight”..i];
                iftxtLeftthen txtLeftSetFontObjectGameTooltipText); end;
                iftxtRightthen txtRightSetFontObjectGameTooltipText); end;
            end;
        end;

        -- 调用默认脚本
        ifUBI_Hooks [“OnTooltipCleared”] [tooltipName])then
            UBI_Hooks [“OnTooltipCleared”] [tooltipName](self,...);
        end;

        -- 关闭UberInventory指示器
        self.UBI_InfoAdded = false;
    end);
end;

这是从第2074行到第2087行的代码,其中调用了“HookTooltip”

function UberInventory_Install_Hooks()
    --挂钩工具提示(OnTooltipSetItem,OnTooltipCleared)
    UberInventory_HookTooltipGameTooltip);
    UberInventory_HookTooltipItemRefTooltip);
    UberInventory_HookTooltipShoppingTooltip1);
    UberInventory_HookTooltipShoppingTooltip2);
    UberInventory_HookTooltipShoppingTooltip3);

    -- Hook邮件内容
    UBI_Hooks [“ReturnInboxItem”] = ReturnInboxItem;
    ReturnInboxItem = UberInventory_ReturnInboxItem;
    UBI_Hooks [“SendMail”] = SendMail;
    SendMail = UberInventory_SendMail;
end;
点赞
用户1442917
用户1442917

你调用的函数(UberInventory_HookTooltip)的toolkit参数得到一个nil值。当你尝试调用toolkit对象的方法(tooltip:GetName())时,会出现一个预期的错误,错误信息是:“attempt to index local 'tooltip'(a nil value)”。代码试图找到在tooltip表中应存储的GetName字段,但是由于值是nil,因此无法这样做(无法“索引”表)。你需要检查调用函数的代码,以确保它传递了正确的值。如果没有看到调用UberInventory_HookTooltip的代码,我们无法提供更多帮助。

2014-10-17 06:39:12