尝试对本地变量“tooltip”进行索引(而该变量的值为nil)
2014-10-18 0:5:10
收藏:0
阅读:97
评论:1
请帮忙,我正在尝试解决这个代码问题,但我确实没有看到错误。我非常没有经验,感谢您提供任何帮助。谢谢。
错误: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”,function(self,...)
-- 从全局变量到本地变量
local UBI_Hooks = UBI_Hooks;
-- 获取提示名称
local tooltipName = self:GetName();
-- 调用默认脚本
if(UBI_Hooks [“OnTooltipSetItem”] [tooltipName])then
UBI_Hooks [“OnTooltipSetItem”] [tooltipName](self,...);
end;
-- 调用新脚本(添加项目信息)
UberInventory_AddItemInfo(self);
-- 打开UberInventory指示器
self.UBI_InfoAdded = true;
end);
--设置新脚本以处理OnTooltipCleared
tooltip:SetScript(“OnTooltipCleared”,function(self,...)
-- 从全局变量到本地变量
local UBI_Hooks = UBI_Hooks;
-- 获取提示名称
local tooltipName = self:GetName();
-- 强制重置字体(maxlines是在UberInventory_AddItemInfo函数中添加的自定义属性)
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;
-- 调用默认脚本
if(UBI_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_HookTooltip(GameTooltip);
UberInventory_HookTooltip(ItemRefTooltip);
UberInventory_HookTooltip(ShoppingTooltip1);
UberInventory_HookTooltip(ShoppingTooltip2);
UberInventory_HookTooltip(ShoppingTooltip3);
-- Hook邮件内容
UBI_Hooks [“ReturnInboxItem”] = ReturnInboxItem;
ReturnInboxItem = UberInventory_ReturnInboxItem;
UBI_Hooks [“SendMail”] = SendMail;
SendMail = UberInventory_SendMail;
end;
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
你调用的函数(
UberInventory_HookTooltip)的toolkit参数得到一个nil值。当你尝试调用toolkit对象的方法(tooltip:GetName())时,会出现一个预期的错误,错误信息是:“attempt to index local 'tooltip'(a nil value)”。代码试图找到在tooltip表中应存储的GetName字段,但是由于值是nil,因此无法这样做(无法“索引”表)。你需要检查调用函数的代码,以确保它传递了正确的值。如果没有看到调用UberInventory_HookTooltip的代码,我们无法提供更多帮助。