首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WoW Lua错误;尝试调用全局值(零值)

问WoW Lua错误;尝试调用全局值(零值)
EN

Stack Overflow用户
提问于 2020-08-29 09:25:40
回答 1查看 1.6K关注 0票数 1

我刚开始学习Lua,并且一直在学习关于SetMapToCurrentZone()的教程,但是我无法让它工作;我已经复制了代码,但是我得到了错误消息“试图调用SetMapToCurrentZone()和GetPlayerMapPosition("player")函数上的全局'functionname‘(一个零值)”。

这是整个Lua文件;

代码语言:javascript
复制
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

我该怎么解决呢?

EN

回答 1

Stack Overflow用户

发布于 2020-08-30 09:00:01

这些函数在8.0中被重命名并移动到包装对象、Map.GetBestMapForUnit (需要"player“作为参数以获得相同的结果)和Map.GetPlayerMapPosition。

您可能希望稍后会调用更多的函数来抛出相同的错误,它们的行以前是无法到达的。当我再次在桌面上时,我可以检查整个代码示例,但是您可以简单地在Wowpedia上查找这些函数,特别是其他与地图相关的函数。

我建议使用Wowpedia而不是Wowwiki,这是个人的喜好/印象,前者似乎得到了更多的不断更新。(两人在10年前分手后,现在又开始合并了)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63645420

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档