Originally Posted by Azul
What is wrong with this? It says that foo is global, and that it's nil.. when obviously it should be local (they all should), and not nil..
Code:
local frame=CreateFrame("Frame")
frame:SetScript("OnUpdate",function(self)
if not foo then local foo,bar,text="foo","bar","" end
text=foo..bar
end)
I'm really starting to hate lua with a passion. To bad there are no alternatives.
|
Ok, no offense mate, but don't edit a different code into it when people are trying to help you figure out the original. I was confused there for a sec...
Try separating the function out to test functionality better:
Code:
local f = CreateFrame("Blah")
f:SetScript("OnUpdate", testfunction(self))
function testfunction(frame)
if not foo then
local foo = "foo"
local bar = "bar"
end
text=foo..bar
DEFAULT_CHAT_FRAME:AddMessage(text) -- test to make sure everything goes smoothly
end
Also note that I removed
local text = "" as you don't need it. It's already going to be overridden each time without having to manually clear it. After you get it working how you want, then go back and optimize the code (as haste pointed out).