4

我一直在玩 Lua 和魔兽世界(AKA WoW)大约 2 天。

我的问题是,当我使用以下代码时(不是作为宏,而是作为插件)

TimeManagerClockButton:Hide()

它向我抛出以下错误消息。

消息:Interface\AddOns\WeakCloudUI\WeakCloudUI.lua:22:尝试索引全局“TimeManagerClockButton”(一个零值)
时间:07/04/15 21:38:16
计数:1
堆栈:Interface\AddOns\WeakCloudUI\WeakCloudUI .lua:22: 在主块中

本地人: (*temporary) = nil
(*temporary) = nil
(*temporary) =
(*temporary) = 13
(*temporary) = "OUTLINE"
(*temporary) = true
(*temporary) = 30
(*temporary) =
(*temporary) = nil
(*temporary) = nil
(*temporary) = "尝试索引全局 'TimeManagerClockButton' (一个 nil 值)"

它作为宏工作得很好,但是当我在 AddOn(lua 文件)上使用该代码时会出现问题。

有人可以告诉我问题是什么吗?

谢谢你。

4

1 回答 1

2

如建议的那样,您可能在 TimeManagerClockButton 存在之前运行代码,因为尚未加载插件代码。

您可以通过使用要求其他插件加载

assert(LoadAddOn("Blizzard_TimeManager"))

You may also try delaying your addon code to run later by using an event or a timer.

于 2015-11-18T00:08:36.853 回答