WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Addon does not display messages in chat (https://www.wowinterface.com/forums/showthread.php?t=59619)

Galseb 06-18-23 09:48 PM

Addon does not display messages in chat
 
In general, in a nutshell. I wanted to make an addon on WotLK, which does the calculation of the number of circles in Dalaran. But the problem is that when you enter the command, it writes that it is unknown
code:
Code:

lua
local points = {
    A = {x1 = 58, y1 = 46, x2 = 80, y2 = 49},
    B = {x1 = 47, y1 = 28, x2 = 49, y2 = 36},
    C = {x1 = 39, y1 = 48, x2 = 47, y2 = 52},
    D = {x1 = 50, y1 = 58, x2 = 52, y2 = 63},
}
local currentPoint = "A"
local lapCount = 0
local DalaranID = 4395

SLASH_LAPCOUNT1 = "/lapcount"

lua
function SlashCmdList.LAPCOUNT(msg, editbox
    print(lapCount)
end
end

local function CheckPlayerPosition()
    local x, y = GetPlayerMapPosition("player")
    local mapId = GetCurrentMapAreaID()

    if mapId ~= DalaranID then
        return
    end

    if x >= points[currentPoint].x1 and x <= points[currentPoint].x2 and y >= points[currentPoint].y1 and y <= points[currentPoint].y2 then
        if currentPoint == "A" then
            currentPoint = "B"
        elseif currentPoint == "B" then
            currentPoint = "C"
        elseif currentPoint == "C" then
            currentPoint = "D"
        elseif currentPoint == "D" then
            currentPoint = "A"
            lapCount = lapCount + 1
        end
    end
end

local frame = CreateFrame("Frame")
frame:SetScript("OnUpdate", CheckPlayerPosition)

I have a problem with the output of information, the game does not register the command. Help me fix the code please. ty for attention:rolleyes:

Dridzt 06-19-23 02:22 AM

Quote:

Originally Posted by Galseb (Post 342580)
In general, in a nutshell. I wanted to make an addon on WotLK, which does the calculation of the number of circles in Dalaran. But the problem is that when you enter the command, it writes that it is unknown
code:
Code:

local points = {
    A = {x1 = 58, y1 = 46, x2 = 80, y2 = 49},
    B = {x1 = 47, y1 = 28, x2 = 49, y2 = 36},
    C = {x1 = 39, y1 = 48, x2 = 47, y2 = 52},
    D = {x1 = 50, y1 = 58, x2 = 52, y2 = 63},
}
local currentPoint = "A"
local lapCount = 0
local DalaranID = 125

SLASH_LAPCOUNT1 = "/lapcount"

function SlashCmdList.LAPCOUNT(msg, editbox)
    print(lapCount)
end

local function CheckPlayerPosition()
    local mapId = C_Map.GetBestMapForUnit("player")

    if mapId ~= DalaranID then
        return
    end
    local x, y = C_Map.GetPlayerMapPosition(mapId, "player")

    if x >= points[currentPoint].x1 and x <= points[currentPoint].x2 and y >= points[currentPoint].y1 and y <= points[currentPoint].y2 then
        if currentPoint == "A" then
            currentPoint = "B"
        elseif currentPoint == "B" then
            currentPoint = "C"
        elseif currentPoint == "C" then
            currentPoint = "D"
        elseif currentPoint == "D" then
            currentPoint = "A"
            lapCount = lapCount + 1
        end
    end
end

local frame = CreateFrame("Frame")
frame:SetScript("OnUpdate", CheckPlayerPosition)

I have a problem with the output of information, the game does not register the command. Help me fix the code please. ty for attention:rolleyes:

I fixed the problems visible to the naked eye (no testing)
You need to enable Lua errors from interface options to even see what's happening.
There's no way that code even run.

Galseb 06-19-23 04:08 AM

Quote:

Originally Posted by Dridzt (Post 342581)
I fixed the problems visible to the naked eye (no testing)
You need to enable Lua errors from interface options to even see what's happening.
There's no way that code even run.

The output is now working, at least 0 shows, thanks!:D But it does not count, and shows such script errors, the number of which is growing every second .. Can you tell me how to fix it? Thank you:rolleyes:

Code:

Message: ...ace\AddOns\DalaranLoopCounter\DalaranLoopCounter.lua:18: attempt to call field 'GetBestMapForUnit' (a nil value)
Time: 06/19/23 13:00:02
Count: 139
Stack: ...ace\AddOns\DalaranLoopCounter\DalaranLoopCounter.lua:18: in function <...ace\AddOns\DalaranLoopCounter\DalaranLoopCounter.lua:17>

Locals: (*temporary) = nil
(*temporary) = "player"
(*temporary) = "attempt to call field 'GetBestMapForUnit' (a nil value)"
DalaranID = 125
points = <table> {
 A = <table> {
 }
 D = <table> {
 }
 C = <table> {
 }
 B = <table> {
 }
}
currentPoint = "A"
lapCount = 0

Lines 17 and 18 are
Code:

local function CheckPlayerPosition()
    local mapId = C_Map.GetBestMapForUnit("player")


Dridzt 06-19-23 04:52 AM

Ah.. well the only possible reason for that error is you're not playing on official servers.

Which means you can't get help on this forum.


All times are GMT -6. The time now is 02:15 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI