我刚开始学习Lua,并且一直在学习关于SetMapToCurrentZone()的教程,但是我无法让它工作;我已经复制了代码,但是我得到了错误消息“试图调用SetMapToCurrentZone()和GetPlayerMapPosition("player")函数上的全局'functionname‘(一个零值)”。
这是整个Lua文件;
local zone = nil
local TimeSinceLastUpdate = 0
local function UpdateCoordinates(self, elapsed)
if zone ~= GetRealZoneText() then
zone = GetRealZoneText()
SetMapToCurrentZone()
end
TimeSinceLastUpdate = TimeSinceLastUpdate + elapsed
if TimeSinceLastUpdate > .5 then
TimeSinceLastUpdate = 0
local posX, posY = GetPlayerMapPosition("player");
local x = math.floor(posX * 10000)/100
local y = math.floor(posY*10000)/100
eCoordinatesFontString:SetText("|c98FB98ff("..x..", "..y..")")
end
end
function eCoordinates_OnLoad(self, event,...)
self:RegisterEvent("ADDON_LOADED")
end
function eCoordinates_OnEvent(self, event, ...)
if event == "ADDON_LOADED" and ... == "eCoordinates" then
self:UnregisterEvent("ADDON_LOADED")
eCoordinates:SetSize(100, 50)
eCoordinates:SetPoint("TOP", "Minimap", "BOTTOM", 5, -5)
eCoordinates:SetScript("OnUpdate", UpdateCoordinates)
local coordsFont = eCoordinates:CreateFontString("eCoordinatesFontString", "ARTWORK", "GameFontNormal")
coordsFont:SetPoint("CENTER", "eCoordinates", "CENTER", 0, 0)
coordsFont:Show()
eCoordinates:Show()
end
end我该怎么解决呢?
发布于 2020-08-30 09:00:01
这些函数在8.0中被重命名并移动到包装对象、Map.GetBestMapForUnit (需要"player“作为参数以获得相同的结果)和Map.GetPlayerMapPosition。
您可能希望稍后会调用更多的函数来抛出相同的错误,它们的行以前是无法到达的。当我再次在桌面上时,我可以检查整个代码示例,但是您可以简单地在Wowpedia上查找这些函数,特别是其他与地图相关的函数。
我建议使用Wowpedia而不是Wowwiki,这是个人的喜好/印象,前者似乎得到了更多的不断更新。(两人在10年前分手后,现在又开始合并了)
https://stackoverflow.com/questions/63645420
复制相似问题