Monday, April 16, 2012

LUA help - concatenate error

Hi there, I'm trying to fix this mod that broke after the patch came out. Was hoping a simple toc update would do it but nope, no dice. The error I get is:


Code:
urlcopy.lua line 105: attempt to concatenate field "Color" (a nil value)

Line 105 includes this code:


Code:
function URLCopy_Link (link)
if (URLCopy.Brackets == 1) then
link = " |cff" .. URLCopy.Color .. "|Hurl:" .. link .. "|h[" .. link .. "]|h|r "
else
link = " |cff" .. URLCopy.Color .. "|Hurl:" .. link .. "|h" .. link .. "|h|r "
end
return link
end

I really don't know lua that well and have exhausted my resources available to me, so now I'm here for help. At the top of the LUA file is URLCOPY_COLOR = "FFFF55". I don't see that that's ever set until at the bottom of the code below which is part of URLCopy_OnLoad()


Code:
URLCopy_SetItemRef_Original = SetItemRef
SetItemRef = URLCopy_SetItemRef

RegisterForSave("URLCopy");

SlashCmdList["URLCOPYBRACKETS"] = URLCopy_SlashBrackets;
SLASH_URLCOPYBRACKETS1 = "/ucb";
SlashCmdList["URLCOPYCOLOR"] = URLCopy_SlashColor;
SLASH_URLCOPYCOLOR1 = "/ucc";

if not URLCopy.Brackets then
URLCopy.Brackets = 1
end
if not URLCopy.Color then
URLCopy.Color = URLCOPY_COLOR
end

I don't see anywhere else where URLCopy.Color is set. Is the problem obvious to someone familiar with LUA and if so, is the fix an easy one? I'm praying its just a matter of editing the LUA file and not have to be a complete rewrite.

Thanks,

Ben|||Bored so answering old-ish posts

When do you get the error, when you log in or when you take some action ?

I'd have to guess that the OnLoad function is not executing, or is exiting BEFORE the actual code you reference is executed.... not really enough info to guess what's causing the issue.

As an absolute last resort of bad-hackery you could simply insert the lines


Code:
 if not URLCopy.Color then
URLCopy.Color = URLCOPY_COLOR
end

at the start of the function URLCopy_Link(link)|||Quote:








Bored so answering old-ish posts

When do you get the error, when you log in or when you take some action ?

I'd have to guess that the OnLoad function is not executing, or is exiting BEFORE the actual code you reference is executed.... not really enough info to guess what's causing the issue.

As an absolute last resort of bad-hackery you could simply insert the lines


Code:
 if not URLCopy.Color then
URLCopy.Color = URLCOPY_COLOR
end

at the start of the function URLCopy_Link(link)




wow...this was a while back lol :) you must really be bored but thx for replying.

as to my problem above, disregard this entire thread! I was under the impression this addon was the one that was doing ingame what I wanted, but I found the original addon and turns out it's called ReURL that does the web address copying. Not sure if all I did was a toc update or found a new version somewhere.

No comments:

Post a Comment