Modding Cartograph_Notes to add some nice functionality to /note chat command. Just can't understand the general cause of variable scopes...
Subjected code is
Code:
if text:match("^%d%d?%.%d%d? [^%d].*$") or text:match("^%d%d?%.%d%d?$") then
text = text:gsub("^(%d%d?)%.(%d%d?)", "%1 %2", 1)
end
local x, y, title = (" "):split(text, 3)
x, y = tonumber(x), tonumber(y)
if not x or not y then
self:Print(L["Usage: /note <0-100> <0-100> [title]"])
return
end
x, y = x / 100, y / 100
around line 1338 in Cartographer_Notes/Notes.lua
What i'm doing, is basically that i'm retrieving actual player coords if no right coords were provided to command.
This way:
Code:
if text:match("^%d%d?%.%d%d? [^%d].*$") or text:match("^%d%d?%.%d%d?$") then
text = text:gsub("^(%d%d?)%.(%d%d?)", "%1 %2", 1)
local x, y, title = (" "):split(text, 3)
else
local title = text;
local x, y = GetPlayerMapPosition("player")
x, y = x * 100, y * 100
-- Some nice debudding printout
self:Print("Coords: " .. x .. ";" .. y)
end
x, y = tonumber(x), tonumber(y)
if (0 == x) or (0 == y) then
self:Print(L["Usage: /note <0-100> <0-100> [title]"])
return
end
x, y = x / 100, y / 100
Now tell me what i'm doing wrong why it every time telling me that i'm doing wrong things to global "y" in the last string?
The "x, y = x / 100, y / 100" one.